Browse Source

[3437] Filter out packets sent to global unicast address.

On BSD the multicast packets are received on the socket bound to any
address. So, the packets sent to global unicast address must be filtered
out by the DHCP server.
Marcin Siodelski 11 years ago
parent
commit
1ea0e90778
1 changed files with 11 additions and 0 deletions
  1. 11 0
      src/lib/dhcp/pkt_filter_inet6.cc

+ 11 - 0
src/lib/dhcp/pkt_filter_inet6.cc

@@ -181,6 +181,17 @@ PktFilterInet6::receive(const SocketInfo& socket_info) {
         isc_throw(SocketReadError, "failed to receive data");
     }
 
+    // Filter out packets sent to global unicast address (not link local and
+    // not multicast) if the socket is set to listen multicast traffic and
+    // is bound to in6addr_any. The traffic sent to global unicast address is
+    // received via dedicated socket.
+    IOAddress local_addr = IOAddress::fromBytes(AF_INET6,
+                      reinterpret_cast<const uint8_t*>(&to_addr));
+    if ((socket_info.addr_ == IOAddress("::")) &&
+        !(local_addr.isV6Multicast() || local_addr.isV6LinkLocal())) {
+        return (Pkt6Ptr());
+    }
+
     // Let's create a packet.
     Pkt6Ptr pkt;
     try {