OpenBSD only has identical /dev/bpf and /dev/bpf0, nothing in base uses
bpf0 anymore and bpf(4) is clonable, meaning you can open it up to
1024(?) times.

This should eventually allow us to remove bpf0.

Builds fine.
OK?

Index: 1.0/Makefile
===================================================================
RCS file: /cvs/ports/net/libnet/1.0/Makefile,v
retrieving revision 1.24
diff -u -p -r1.24 Makefile
--- 1.0/Makefile        11 Mar 2022 19:46:14 -0000      1.24
+++ 1.0/Makefile        23 Aug 2022 15:07:28 -0000
@@ -1,7 +1,7 @@
 REV=           1.0
 VERSION=       ${REV}.2a
 EPOCH=         0
-REVISION=      6
+REVISION=      7
 SHARED_LIBS=   net     0.0
 PKGSPEC =      libnet->=1.0v0,<1.1v0
 FIX_EXTRACT_PERMISSIONS=Yes
Index: 1.0/patches/patch-src_libnet_link_bpf_c
===================================================================
RCS file: /cvs/ports/net/libnet/1.0/patches/patch-src_libnet_link_bpf_c,v
retrieving revision 1.5
diff -u -p -r1.5 patch-src_libnet_link_bpf_c
--- 1.0/patches/patch-src_libnet_link_bpf_c     11 Mar 2022 19:46:14 -0000      
1.5
+++ 1.0/patches/patch-src_libnet_link_bpf_c     23 Aug 2022 15:13:41 -0000
@@ -1,5 +1,6 @@
---- src/libnet_link_bpf.c.orig Mon Jan  8 02:13:48 2001
-+++ src/libnet_link_bpf.c      Thu Dec  5 19:24:59 2013
+Index: src/libnet_link_bpf.c
+--- src/libnet_link_bpf.c.orig
++++ src/libnet_link_bpf.c
 @@ -28,7 +28,6 @@
   */
  
@@ -16,17 +17,39 @@
  #include "../include/gnuc.h"
  #include "../include/bpf.h"
  
-@@ -61,7 +61,7 @@ libnet_bpf_open(char *errbuf)
-      */
-     for (i = 0;;i++)
-     {
+@@ -54,36 +54,13 @@ int
+ libnet_bpf_open(char *errbuf)
+ {
+     int i, fd;
+-    char device[sizeof "/dev/bpf000"];
++    char device[sizeof "/dev/bpf"];
+ 
+-    /*
+-     *  Go through all the minors and find one that isn't in use.
+-     */
+-    for (i = 0;;i++)
+-    {
 -        sprintf(device, "/dev/bpf%d", i);
-+        snprintf(device, sizeof(device), "/dev/bpf%d", i);
- 
-         fd = open(device, O_RDWR);
-         if (fd == -1 && errno == EBUSY)
-@@ -83,7 +83,7 @@ libnet_bpf_open(char *errbuf)
++    fd = open(device, O_RDWR);
  
+-        fd = open(device, O_RDWR);
+-        if (fd == -1 && errno == EBUSY)
+-        {
+-            /*
+-             *  Device is busy.
+-             */
+-            continue;
+-        }
+-        else
+-        {
+-            /*
+-             *  Either we've got a valid file descriptor, or errno is not
+-             *  EBUSY meaning we've probably run out of devices.
+-             */
+-            break;
+-        }
+-    }
+-
      if (fd == -1)
      {
 -        sprintf(errbuf, "%s: %s", device, ll_strerror(errno));
@@ -34,7 +57,7 @@
      }
      return (fd);
  }
-@@ -104,7 +104,7 @@ libnet_open_link_interface(char *device, char *ebuf)
+@@ -104,7 +81,7 @@ libnet_open_link_interface(char *device, char *ebuf)
      l = (struct libnet_link_int *)malloc(sizeof(*l));
      if (!l)
      {
@@ -43,7 +66,7 @@
  #if (__DEBUG)
          libnet_error(LN_ERR_CRITICAL, "bpf libnet_open_link_interface: malloc 
%s",
                  ll_strerror(errno));
-@@ -125,13 +125,13 @@ libnet_open_link_interface(char *device, char *ebuf)
+@@ -125,13 +102,13 @@ libnet_open_link_interface(char *device, char *ebuf)
       */
      if (ioctl(l->fd, BIOCVERSION, (caddr_t)&bv) < 0)
      {
@@ -59,7 +82,7 @@
          goto bad;
      }
  
-@@ -141,7 +141,7 @@ libnet_open_link_interface(char *device, char *ebuf)
+@@ -141,7 +118,7 @@ libnet_open_link_interface(char *device, char *ebuf)
      strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
      if (ioctl(l->fd, BIOCSETIF, (caddr_t)&ifr) == -1)
      {
@@ -68,7 +91,7 @@
          goto bad;
      }
  
-@@ -150,7 +150,7 @@ libnet_open_link_interface(char *device, char *ebuf)
+@@ -150,7 +127,7 @@ libnet_open_link_interface(char *device, char *ebuf)
       */
      if (ioctl(l->fd, BIOCGDLT, (caddr_t)&v) == -1)
      {
@@ -77,7 +100,7 @@
          goto bad;
      }
  
-@@ -161,7 +161,7 @@ libnet_open_link_interface(char *device, char *ebuf)
+@@ -161,7 +138,7 @@ libnet_open_link_interface(char *device, char *ebuf)
  #if defined(BIOCGHDRCMPLT) && defined(BIOCSHDRCMPLT)
      if (ioctl(l->fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1)
      {
@@ -86,7 +109,7 @@
          goto bad;
      }
  #endif
-@@ -278,9 +278,13 @@ libnet_get_hwaddr(struct libnet_link_int *l, const cha
+@@ -278,9 +255,13 @@ libnet_get_hwaddr(struct libnet_link_int *l, const cha
      for (next = buf ; next < end ; next += ifm->ifm_msglen)
      {
          ifm = (struct if_msghdr *)next;
Index: 1.1/Makefile
===================================================================
RCS file: /cvs/ports/net/libnet/1.1/Makefile,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile
--- 1.1/Makefile        11 Mar 2022 19:46:14 -0000      1.21
+++ 1.1/Makefile        23 Aug 2022 15:14:30 -0000
@@ -1,5 +1,6 @@
 REV=           1.1
 VERSION=       ${REV}.6
+REVISION=      0
 EPOCH=         0
 SHARED_LIBS=   net     11.1
 PKGSPEC=       libnet->=1.1v0,<1.2v0
Index: 1.1/patches/patch-src_libnet_link_bpf_c
===================================================================
RCS file: /cvs/ports/net/libnet/1.1/patches/patch-src_libnet_link_bpf_c,v
retrieving revision 1.4
diff -u -p -r1.4 patch-src_libnet_link_bpf_c
--- 1.1/patches/patch-src_libnet_link_bpf_c     11 Mar 2022 19:46:14 -0000      
1.4
+++ 1.1/patches/patch-src_libnet_link_bpf_c     23 Aug 2022 15:15:24 -0000
@@ -9,3 +9,38 @@ Index: src/libnet_link_bpf.c
  #include <sys/file.h>
  #include <sys/ioctl.h>
  
+@@ -56,32 +55,9 @@ int
+ libnet_bpf_open(char *err_buf)
+ {
+     int i, fd;
+-    char device[] = "/dev/bpf000";
++    char device[] = "/dev/bpf";
+ 
+-    /*
+-     *  Go through all the minors and find one that isn't in use.
+-     */
+-    for (i = 0;;i++)
+-    {
+-        sprintf(device, "/dev/bpf%d", i);
+-
+-        fd = open(device, O_RDWR);
+-        if (fd == -1 && errno == EBUSY)
+-        {
+-            /*
+-             *  Device is busy.
+-             */
+-            continue;
+-        }
+-        else
+-        {
+-            /*
+-             *  Either we've got a valid file descriptor, or errno is not
+-             *  EBUSY meaning we've probably run out of devices.
+-             */
+-            break;
+-        }
+-    }
++    fd = open(device, O_RDWR);
+ 
+     if (fd == -1)
+     {

Reply via email to