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
This commit is contained in:
Justin Hibbits 2023-02-08 21:32:47 -05:00
parent 19aba210e1
commit adf62e8363
4 changed files with 7 additions and 12 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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 */

View File

@ -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);
}
}