git: adf62e836315 - main - infiniband: Convert BPF handling for IfAPI

From: Justin Hibbits <jhibbits_at_FreeBSD.org>
Date: Tue, 14 Mar 2023 20:01:38 UTC
The branch main has been updated by jhibbits:

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

commit adf62e83631571e74caf3d78ddb091870b9d6ecf
Author:     Justin Hibbits <jhibbits@FreeBSD.org>
AuthorDate: 2023-02-09 02:32:47 +0000
Commit:     Justin Hibbits <jhibbits@FreeBSD.org>
CommitDate: 2023-03-14 19:51:32 +0000

    infiniband: Convert BPF handling for IfAPI
    
    Summary:
    All callers of infiniband_bpf_mtap() call it through the wrapper macro,
    which checks the if_bpf member explicitly.  Since this is getting
    hidden, move this check into the internal function and remove the
    wrapper macro.
    
    Reviewed by:    hselasky
    Sponsored by:   Juniper Networks, Inc.
    Differential Revision: https://reviews.freebsd.org/D39024
---
 sys/net/if_infiniband.c                            | 5 ++++-
 sys/net/if_lagg.c                                  | 4 ++--
 sys/net/infiniband.h                               | 8 --------
 sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 +-
 4 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/sys/net/if_infiniband.c b/sys/net/if_infiniband.c
index e5830d977e80..6764373b3d1a 100644
--- a/sys/net/if_infiniband.c
+++ b/sys/net/if_infiniband.c
@@ -128,6 +128,9 @@ infiniband_bpf_mtap(struct ifnet *ifp, struct mbuf *mb)
 	struct infiniband_header *ibh;
 	struct ether_header eh;
 
+	if (!bpf_peers_present(ifp->if_bpf))
+		return;
+
 	if (mb->m_len < sizeof(*ibh))
 		return;
 
@@ -439,7 +442,7 @@ infiniband_input(struct ifnet *ifp, struct mbuf *m)
 	}
 
 	/* Let BPF have it before we strip the header. */
-	INFINIBAND_BPF_MTAP(ifp, m);
+	infiniband_bpf_mtap(ifp, m);
 
 	/* Allow monitor mode to claim this frame, after stats are updated. */
 	if (ifp->if_flags & IFF_MONITOR) {
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index 1ac8492834fc..a50cd995c6eb 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -2154,7 +2154,7 @@ lagg_transmit_infiniband(struct ifnet *ifp, struct mbuf *m)
 		return (ENXIO);
 	}
 
-	INFINIBAND_BPF_MTAP(ifp, m);
+	infiniband_bpf_mtap(ifp, m);
 
 	error = lagg_proto_start(sc, m);
 	NET_EPOCH_EXIT(et);
@@ -2222,7 +2222,7 @@ lagg_input_infiniband(struct ifnet *ifp, struct mbuf *m)
 		return (NULL);
 	}
 
-	INFINIBAND_BPF_MTAP(scifp, m);
+	infiniband_bpf_mtap(scifp, m);
 
 	m = lagg_proto_input(sc, lp, m);
 	if (m != NULL && (scifp->if_flags & IFF_MONITOR) != 0) {
diff --git a/sys/net/infiniband.h b/sys/net/infiniband.h
index b9fead61c220..6d41f0fe8816 100644
--- a/sys/net/infiniband.h
+++ b/sys/net/infiniband.h
@@ -41,14 +41,6 @@
 #define	INFINIBAND_IS_MULTICAST(addr) \
     ((addr)[4] == 0xff)
 
-#define	INFINIBAND_BPF_MTAP(_ifp, _m)			\
-do {							\
-	if (bpf_peers_present((_ifp)->if_bpf)) {	\
-		M_ASSERTVALID(_m);			\
-		infiniband_bpf_mtap(_ifp, _m);		\
-	}						\
-} while (0)
-
 struct infiniband_header {
 	uint8_t	ib_hwaddr[INFINIBAND_ADDR_LEN];
 	uint16_t ib_protocol;		/* big endian */
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
index f7b257c92784..3f01d8b0218e 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -747,7 +747,7 @@ ipoib_start_locked(struct ifnet *dev, struct ipoib_dev_priv *priv)
 		IFQ_DRV_DEQUEUE(&dev->if_snd, mb);
 		if (mb == NULL)
 			break;
-		INFINIBAND_BPF_MTAP(dev, mb);
+		infiniband_bpf_mtap(dev, mb);
 		ipoib_send_one(priv, mb);
 	}
 }