BIND 10 trac2902, updated. 1ca6a3ac00cdf22e6fea1157bc887dd44e1f87a7 [2902] Do not use the broadcast address as source in server's response.

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Apr 25 18:43:11 UTC 2013


The branch, trac2902 has been updated
       via  1ca6a3ac00cdf22e6fea1157bc887dd44e1f87a7 (commit)
      from  8b0cb0ded8035fcfb9cdd483ab3936db6690b97e (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 1ca6a3ac00cdf22e6fea1157bc887dd44e1f87a7
Author: Marcin Siodelski <marcin at isc.org>
Date:   Thu Apr 25 20:42:53 2013 +0200

    [2902] Do not use the broadcast address as source in server's response.

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

Summary of changes:
 src/lib/dhcp/pkt_filter_lpf.cc                |   14 ++++++++++++++
 src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc |    7 ++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcp/pkt_filter_lpf.cc b/src/lib/dhcp/pkt_filter_lpf.cc
index 6202219..a86be04 100644
--- a/src/lib/dhcp/pkt_filter_lpf.cc
+++ b/src/lib/dhcp/pkt_filter_lpf.cc
@@ -110,6 +110,20 @@ PktFilterLPF::send(const Iface& iface, uint16_t sockfd, const Pkt4Ptr& pkt) {
     }
     writeEthernetHeader(iface.getMac(), &dest_addr[0], buf);
 
+    // It is likely that the local address in pkt object is set to
+    // broadcast address. This is the case if server received the
+    // client's packet on broadcast address. Therefore, we need to
+    // correct it here and assign the actual source address.
+    if (pkt->getLocalAddr().toText() == "255.255.255.255") {
+        const Iface::SocketCollection& sockets = iface.getSockets();
+        for (Iface::SocketCollection::const_iterator it = sockets.begin();
+             it != sockets.end(); ++it) {
+            if (sockfd == it->sockfd_) {
+                pkt->setLocalAddr(it->addr_);
+            }
+        }
+    }
+
     // IP and UDP header
     writeIpUdpHeader(pkt, buf);
 
diff --git a/src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc b/src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc
index d74c3a7..dd98840 100644
--- a/src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc
+++ b/src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc
@@ -139,7 +139,12 @@ TEST_F(PktFilterLPFTest, DISABLED_send) {
     ASSERT_TRUE(pkt);
 
     // Set required fields.
-    pkt->setLocalAddr(IOAddress("127.0.0.1"));
+    // By setting the local address to broadcast we simulate the
+    // typical scenario when client's request was send to broadcast
+    // address and server by default used it as a source address
+    // in its response. The send() function should be able to detect
+    // it and correct the source address.
+    pkt->setLocalAddr(IOAddress("255.255.255.255"));
     pkt->setRemotePort(PORT);
     pkt->setLocalPort(PORT + 1);
     pkt->setIndex(ifindex_);



More information about the bind10-changes mailing list