Diff below simplifies the device open path and removes an explanation
about bpf device nodes from the manpage.

Ok?

natano


Index: bpf.c
===================================================================
RCS file: /cvs/src/sbin/dhclient/bpf.c,v
retrieving revision 1.38
diff -u -p -r1.38 bpf.c
--- bpf.c       6 Feb 2016 19:30:52 -0000       1.38
+++ bpf.c       2 May 2016 07:27:46 -0000
@@ -64,8 +64,6 @@
 #include "dhcp.h"
 #include "dhcpd.h"
 
-#define BPF_FORMAT "/dev/bpf%d"
-
 int if_register_bpf(void);
 
 /*
@@ -76,29 +74,17 @@ int if_register_bpf(void);
 int
 if_register_bpf(void)
 {
-       char filename[50];
        struct ifreq ifr;
-       int sock, b;
+       int sock;
 
-       /* Open a BPF device */
-       for (b = 0; 1; b++) {
-               snprintf(filename, sizeof(filename), BPF_FORMAT, b);
-               sock = open(filename, O_RDWR | O_CLOEXEC, 0);
-               if (sock < 0) {
-                       if (errno == EBUSY)
-                               continue;
-                       else
-                               error("Can't find free bpf: %s",
-                                   strerror(errno));
-               } else
-                       break;
-       }
+       if ((sock = open("/dev/bpf", O_RDWR | O_CLOEXEC)) == -1)
+               error("Can't open bpf: %s", strerror(errno));
 
        /* Set the BPF device to point at this interface. */
        strlcpy(ifr.ifr_name, ifi->name, IFNAMSIZ);
        if (ioctl(sock, BIOCSETIF, &ifr) < 0)
-               error("Can't attach interface %s to %s: %s",
-                   ifi->name, filename, strerror(errno));
+               error("Can't attach interface %s to /dev/bpf: %s",
+                   ifi->name, strerror(errno));
 
        return (sock);
 }
Index: dhclient.8
===================================================================
RCS file: /cvs/src/sbin/dhclient/dhclient.8,v
retrieving revision 1.26
diff -u -p -r1.26 dhclient.8
--- dhclient.8  15 Nov 2014 00:12:52 -0000      1.26
+++ dhclient.8  2 May 2016 07:27:46 -0000
@@ -249,14 +249,6 @@ In that case, it may be advantageous to
 arrange with the network administrator for an entry on the BOOTP
 database, so that the host can boot quickly on that network rather
 than cycling through the list of old leases.
-.Pp
-.Nm
-requires at least one
-.Pa /dev/bpf*
-file for each broadcast network interface.
-See
-.Xr bpf 4
-for more information.
 .Sh SIGNALS
 While running,
 .Nm
@@ -306,7 +298,6 @@ interface-specific configuration files
 database of acquired leases
 .El
 .Sh SEE ALSO
-.Xr bpf 4 ,
 .Xr dhclient.conf 5 ,
 .Xr dhclient.leases 5 ,
 .Xr hostname.if 5 ,

Reply via email to