]> xenbits.xensource.com Git - libvirt.git/commitdiff
nwfilter: Discard class D,E IP addresses when sniffing pkts
authorStefan Berger <stefanb@us.ibm.com>
Fri, 13 Aug 2010 20:41:39 +0000 (16:41 -0400)
committerStefan Berger <stefanb@us.ibm.com>
Fri, 13 Aug 2010 20:41:39 +0000 (16:41 -0400)
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.

src/nwfilter/nwfilter_learnipaddr.c

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