nwfilter: Discard class D,E IP addresses when sniffing pkts

When sniffing the network traffic, discard class D and E IP addresses when sniffing traffic. This was a reason why filters were not correctly rebuilt on VMs on the local 192.* network when libvirt was restarted and those VMs did not use a DHCP request to get its IP address.
This commit is contained in:
Stefan Berger 2010-08-13 16:41:39 -04:00
parent bed3a217f6
commit 753d76e0cd

View File

@ -546,9 +546,11 @@ learnIPAddressThread(void *arg)
struct iphdr *iphdr = (struct iphdr*)(packet + struct iphdr *iphdr = (struct iphdr*)(packet +
ethHdrSize); ethHdrSize);
vmaddr = iphdr->saddr; vmaddr = iphdr->saddr;
// skip eth. bcast and mcast addresses, // skip mcast addresses (224.0.0.0 - 239.255.255.255),
// and zero address in DHCP Requests // class E (240.0.0.0 - 255.255.255.255, includes eth.
if ((ntohl(vmaddr) & 0xc0000000) || vmaddr == 0) { // bcast) and zero address in DHCP Requests
if ( (ntohl(vmaddr) & 0xe0000000) == 0xe0000000 ||
vmaddr == 0) {
vmaddr = 0; vmaddr = 0;
continue; continue;
} }