On Fri, May 06, 2016 at 07:17:50PM +0100, Stuart Henderson wrote:
> 
> Personally, my preferred course of action would be to switch to
> looking for /dev/bpf0 for now (bpf0 only: *not* revert to the old
> loop, that's not necessary), and then switch to /dev/bpf
> immediately after 6.0 is released. The recent few version
> upgrades have been relatively painful, with good reason, but
> this is something where we can easily reduce the pain with
> minimal downside.

I agree, this sounds like a good plan. Diff below implements it.

Ok?


Index: sbin/dhclient/bpf.c
===================================================================
RCS file: /cvs/src/sbin/dhclient/bpf.c,v
retrieving revision 1.39
diff -u -p -r1.39 bpf.c
--- sbin/dhclient/bpf.c 3 May 2016 07:47:26 -0000       1.39
+++ sbin/dhclient/bpf.c 7 May 2016 08:04:03 -0000
@@ -77,13 +77,13 @@ if_register_bpf(void)
        struct ifreq ifr;
        int sock;
 
-       if ((sock = open("/dev/bpf", O_RDWR | O_CLOEXEC)) == -1)
+       if ((sock = open("/dev/bpf0", 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 /dev/bpf: %s",
+               error("Can't attach interface %s to /dev/bpf0: %s",
                    ifi->name, strerror(errno));
 
        return (sock);
Index: lib/libpcap/pcap-bpf.c
===================================================================
RCS file: /cvs/src/lib/libpcap/pcap-bpf.c,v
retrieving revision 1.33
diff -u -p -r1.33 pcap-bpf.c
--- lib/libpcap/pcap-bpf.c      3 May 2016 07:38:38 -0000       1.33
+++ lib/libpcap/pcap-bpf.c      7 May 2016 08:04:04 -0000
@@ -216,9 +216,9 @@ bpf_open(pcap_t *p)
 {
        int fd;
 
-       fd = open("/dev/bpf", O_RDWR);
+       fd = open("/dev/bpf0", O_RDWR);
        if (fd == -1 && errno == EACCES)
-               fd = open("/dev/bpf", O_RDONLY);
+               fd = open("/dev/bpf0", O_RDONLY);
 
        if (fd == -1) {
                if (errno == EACCES)
Index: usr.sbin/tcpdump/privsep_pcap.c
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/privsep_pcap.c,v
retrieving revision 1.20
diff -u -p -r1.20 privsep_pcap.c
--- usr.sbin/tcpdump/privsep_pcap.c     3 May 2016 07:41:24 -0000       1.20
+++ usr.sbin/tcpdump/privsep_pcap.c     7 May 2016 08:04:04 -0000
@@ -182,7 +182,7 @@ pcap_live(const char *device, int snaple
        if (device == NULL || snaplen <= 0)
                return (-1);
 
-       if ((fd = open("/dev/bpf", O_RDONLY)) == -1)
+       if ((fd = open("/dev/bpf0", O_RDONLY)) == -1)
                return (-1);
 
        v = 32768;      /* XXX this should be a user-accessible hook */
Index: usr.sbin/tcpdump/tcpdump.8
===================================================================
RCS file: /cvs/src/usr.sbin/tcpdump/tcpdump.8,v
retrieving revision 1.90
diff -u -p -r1.90 tcpdump.8
--- usr.sbin/tcpdump/tcpdump.8  3 May 2016 07:41:24 -0000       1.90
+++ usr.sbin/tcpdump/tcpdump.8  7 May 2016 08:04:04 -0000
@@ -44,7 +44,7 @@
 prints out the headers of packets on a network interface that match the boolean
 .Ar expression .
 You must have read access to
-.Pa /dev/bpf .
+.Pa /dev/bpf0 .
 .Pp
 The options are as follows:
 .Bl -tag -width "-c count"

Reply via email to