PATCH: DISCOVER_UNCONFIGURED restricted to broadcast capable interfaces on Linux

Jason Vas Dias jvdias at redhat.com
Tue Nov 16 21:51:33 UTC 2004


There have been some complaints about dhcpd / dhclient
emitting messages for interfaces that they shouldn't
be looking at on Linux, like:
' Listening on LPF/sit0/
  Sending on   LPF/sit0/
' ( IPV6-in-IPV4 tunnel)

' Listening on LPF/lo/
  Sending on   LPF/lo/
' ( Loopback )

And then logging messages like:
' dhclient: sit0: unknown hardware address type 776
'

To forestall these annoying messages, here is a patch
against dhcp-3.0.2rc2/common/discover.c :

--- BEGIN PATCH
--- dhcp-3.0.2rc2/common/discover.c.restrict-unconfigured-IFs  
2004-06-10 13:59:16.000000000 -0400
+++ dhcp-3.0.2rc2/common/discover.c     2004-11-16 16:27:55.878445000
-0500
@@ -392,6 +392,18 @@
                        if (tmp)
                                continue;

+                       strncpy (ifr.ifr_name, name, IFNAMSIZ);
+
+                       /* Skip non broadcast interfaces (plus loopback
and
+                          point-to-point in case an OS incorrectly
marks them
+                          as broadcast).
+                       */
+                        if (  (ioctl (sock, SIOCGIFFLAGS, &ifr) < 0)
+                            ||(!(ifr.ifr_flags & IFF_BROADCAST))
+                            ||(ifr.ifr_flags & IFF_LOOPBACK )
+                            ||(ifr.ifr_flags & IFF_POINTOPOINT)
+                           ) continue;
+
                        /* Otherwise, allocate one. */
                        tmp = (struct interface_info *)0;
                        status = interface_allocate (&tmp, MDL);

--- END PATCH





-- Attached file included as plaintext by Ecartis --
-- File: restrict-discover-unconfigured-IFs-patch.txt

--- dhcp-3.0.2rc2/common/discover.c.restrict-unconfigured-IFs	2004-06-10 13:59:16.000000000 -0400
+++ dhcp-3.0.2rc2/common/discover.c	2004-11-16 16:27:55.878445000 -0500
@@ -392,6 +392,18 @@
 			if (tmp)
 				continue;
 
+			strncpy (ifr.ifr_name, name, IFNAMSIZ);
+
+			/* Skip non broadcast interfaces (plus loopback and
+			   point-to-point in case an OS incorrectly marks them
+			   as broadcast).
+			*/
+			 if (  (ioctl (sock, SIOCGIFFLAGS, &ifr) < 0)
+			     ||(!(ifr.ifr_flags & IFF_BROADCAST))
+			     ||(ifr.ifr_flags & IFF_LOOPBACK )
+			     ||(ifr.ifr_flags & IFF_POINTOPOINT)
+		            ) continue;
+
 			/* Otherwise, allocate one. */
 			tmp = (struct interface_info *)0;
 			status = interface_allocate (&tmp, MDL);




More information about the dhcp-hackers mailing list