]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3437] Filter out packets sent to global unicast address.
authorMarcin Siodelski <marcin@isc.org>
Mon, 23 Jun 2014 17:02:46 +0000 (19:02 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 23 Jun 2014 17:02:46 +0000 (19:02 +0200)
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.

src/lib/dhcp/pkt_filter_inet6.cc

index c6d7b97090d9fcfe4ad74a31927a798505b91adb..686b709dbfe4fca8fae765f15fbe07d8c0cac6c3 100644 (file)
@@ -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 {