BIND 10 trac1959, updated. 45ca30e42d6f87bd1039cbcd7f83dfa15ebdcfa0 [1959] Test opening socket from remote broadcast address on Linux only.

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Sep 12 09:21:05 UTC 2012


The branch, trac1959 has been updated
       via  45ca30e42d6f87bd1039cbcd7f83dfa15ebdcfa0 (commit)
      from  1a4c5a70d4917bd1942d5f940bfaf0a1e35b6a0f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 45ca30e42d6f87bd1039cbcd7f83dfa15ebdcfa0
Author: Marcin Siodelski <marcin at isc.org>
Date:   Wed Sep 12 11:16:17 2012 +0200

    [1959] Test opening socket from remote broadcast address on Linux only.
    
    In order to run this test interface detection is required. Since it is
    right now implemented on Linux only it had to be disabled on every other
    OS.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcp/iface_mgr.cc                |    5 +++++
 src/lib/dhcp/tests/iface_mgr_unittest.cc |    6 ++++++
 2 files changed, 11 insertions(+)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/iface_mgr.cc b/src/lib/dhcp/iface_mgr.cc
index 9c03794..be17b09 100644
--- a/src/lib/dhcp/iface_mgr.cc
+++ b/src/lib/dhcp/iface_mgr.cc
@@ -513,6 +513,7 @@ IfaceMgr::getLocalAddress(const IOAddress& remote_addr, const uint16_t port) {
         }
         sock.set_option(asio::socket_base::broadcast(true), err_code);
         if (err_code) {
+            sock.close();
             isc_throw(Unexpected, "failed to enable broadcast on the socket");
         }
     }
@@ -520,6 +521,7 @@ IfaceMgr::getLocalAddress(const IOAddress& remote_addr, const uint16_t port) {
     // Try to connect to remote endpoint and check if attempt is successful.
     sock.connect(remote_endpoint->getASIOEndpoint(), err_code);
     if (err_code) {
+        sock.close();
         isc_throw(Unexpected,"failed to connect to remote endpoint.");
     }
 
@@ -528,6 +530,9 @@ IfaceMgr::getLocalAddress(const IOAddress& remote_addr, const uint16_t port) {
         sock.local_endpoint();
     asio::ip::address local_address(local_endpoint.address());
 
+    // Close the socket.
+    sock.close();
+
     // Return address of local endpoint.
     return IOAddress(local_address);
 }
diff --git a/src/lib/dhcp/tests/iface_mgr_unittest.cc b/src/lib/dhcp/tests/iface_mgr_unittest.cc
index 7f8555c..ad8dba9 100644
--- a/src/lib/dhcp/tests/iface_mgr_unittest.cc
+++ b/src/lib/dhcp/tests/iface_mgr_unittest.cc
@@ -407,6 +407,11 @@ TEST_F(IfaceMgrTest, socketsFromRemoteAddress) {
     EXPECT_GT(socket2, 0);
     close(socket2);
 
+    // The following test is currently disabled for OSes other than
+    // Linux because interface detection is not implemented on them.
+    // @todo enable this test for all OSes once interface detection
+    // is implemented.
+#if defined(OS_LINUX)
     // Open v4 socket to connect to broadcast address.
     int socket3  = 0;
     IOAddress bcastAddr("255.255.255.255");
@@ -415,6 +420,7 @@ TEST_F(IfaceMgrTest, socketsFromRemoteAddress) {
     );
     EXPECT_GT(socket3, 0);
     close(socket3);
+#endif
 }
 
 // TODO: disabled due to other naming on various systems



More information about the bind10-changes mailing list