git: 5e444deec055 - main - Revert "bpf: Add IfAPI analogue for bpf_peers_present()"

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Fri, 13 Oct 2023 18:28:46 UTC
The branch main has been updated by jhibbits:

URL: https://cgit.FreeBSD.org/src/commit/?id=5e444deec055c495069988dfcba23a1e08b0f0d0

commit 5e444deec055c495069988dfcba23a1e08b0f0d0
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2023-10-13 18:29:02 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-10-13 18:33:31 +0000

    Revert "bpf: Add IfAPI analogue for bpf_peers_present()"
    
    This reverts commit c81dd8e5fe72d0c7ec055c8621bb2da3a3627abf.
    
    Commit message needs revised.
---
 sys/dev/firewire/if_fwip.c    |  4 ++--
 sys/dev/hyperv/netvsc/if_hn.c |  4 ++--
 sys/dev/my/if_my.c            |  2 +-
 sys/dev/usb/usb_pf.c          |  4 +++-
 sys/net/bpf.c                 | 14 --------------
 sys/net/bpf.h                 |  1 -
 6 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c
index b698db6c9620..5237c555d999 100644
--- a/sys/dev/firewire/if_fwip.c
+++ b/sys/dev/firewire/if_fwip.c
@@ -780,7 +780,7 @@ fwip_stream_input(struct fw_xferq *xferq)
 		 * Record the sender ID for possible BPF usage.
 		 */
 		src = ntohl(p[1]) >> 16;
-		if (bpf_peers_present_if(ifp)) {
+		if (bpf_peers_present(if_getbpf(ifp))) {
 			mtag = m_tag_alloc(MTAG_FIREWIRE,
 			    MTAG_FIREWIRE_SENDER_EUID,
 			    2*sizeof(uint32_t), M_NOWAIT);
@@ -880,7 +880,7 @@ fwip_unicast_input(struct fw_xfer *xfer)
 		goto done;
 	}
 
-	if (bpf_peers_present_if(ifp)) {
+	if (bpf_peers_present(if_getbpf(ifp))) {
 		/*
 		 * Record the sender ID for possible BPF usage.
 		 */
diff --git a/sys/dev/hyperv/netvsc/if_hn.c b/sys/dev/hyperv/netvsc/if_hn.c
index f6f885873a79..7d8e1914163e 100644
--- a/sys/dev/hyperv/netvsc/if_hn.c
+++ b/sys/dev/hyperv/netvsc/if_hn.c
@@ -3262,7 +3262,7 @@ hn_txpkt(if_t ifp, struct hn_tx_ring *txr, struct hn_txdesc *txd)
 	int error, send_failed = 0, has_bpf;
 
 again:
-	has_bpf = bpf_peers_present_if(ifp);
+	has_bpf = bpf_peers_present(if_getbpf(ifp));
 	if (has_bpf) {
 		/*
 		 * Make sure that this txd and any aggregated txds are not
@@ -5972,7 +5972,7 @@ hn_transmit(if_t ifp, struct mbuf *m)
 			omcast = (m->m_flags & M_MCAST) != 0;
 
 			if (sc->hn_xvf_flags & HN_XVFFLAG_ACCBPF) {
-				if (bpf_peers_present_if(ifp)) {
+				if (bpf_peers_present(if_getbpf(ifp))) {
 					m_bpf = m_copypacket(m, M_NOWAIT);
 					if (m_bpf == NULL) {
 						/*
diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c
index 631c38df9dca..2bf4573d337b 100644
--- a/sys/dev/my/if_my.c
+++ b/sys/dev/my/if_my.c
@@ -1152,7 +1152,7 @@ my_rxeof(struct my_softc * sc)
 		 * broadcast packet, multicast packet, matches our ethernet
 		 * address or the interface is in promiscuous mode.
 		 */
-		if (bpf_peers_present_if(ifp)) {
+		if (bpf_peers_present(if_getbpf(ifp))) {
 			bpf_mtap_if(ifp, m);
 			if (if_getflags(ifp) & IFF_PROMISC &&
 			    (bcmp(eh->ether_dhost, if_getlladdr(sc->my_ifp),
diff --git a/sys/dev/usb/usb_pf.c b/sys/dev/usb/usb_pf.c
index 4da59419a7c6..43e819684857 100644
--- a/sys/dev/usb/usb_pf.c
+++ b/sys/dev/usb/usb_pf.c
@@ -408,7 +408,9 @@ usbpf_xfertap(struct usb_xfer *xfer, int type)
 	bus = xfer->xroot->bus;
 
 	/* sanity checks */
-	if (bus->ifp == NULL || !bpf_peers_present_if(bus->ifp))
+	if (bus->ifp == NULL || if_getbpf(bus->ifp) == NULL)
+		return;
+	if (!bpf_peers_present(if_getbpf(bus->ifp)))
 		return;
 
 	totlen = usbpf_xfer_precompute_size(xfer, type);
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 96420b709911..8ca6e941e646 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -2879,14 +2879,6 @@ bpfdetach(struct ifnet *ifp)
 	BPF_UNLOCK();
 }
 
-bool
-bpf_peers_present_if(struct ifnet *ifp)
-{
-	struct bpf_if *bp = ifp->if_bpf;
-
-	return (bpf_peers_present(bp) > 0);
-}
-
 /*
  * Get a list of available data link type of the interface.
  */
@@ -3170,12 +3162,6 @@ bpfdetach(struct ifnet *ifp)
 {
 }
 
-bool
-bpf_peers_present_if(struct ifnet *ifp)
-{
-	return (false);
-}
-
 u_int
 bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
 {
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index 31968445aac1..924dea5fc9f4 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -428,7 +428,6 @@ void	 bpf_mtap2_if(struct ifnet *, void *, u_int, struct mbuf *);
 void	 bpfattach(struct ifnet *, u_int, u_int);
 void	 bpfattach2(struct ifnet *, u_int, u_int, struct bpf_if **);
 void	 bpfdetach(struct ifnet *);
-bool	 bpf_peers_present_if(struct ifnet *);
 #ifdef VIMAGE
 int	 bpf_get_bp_params(struct bpf_if *, u_int *, u_int *);
 #endif