diff options
author | Seth Hoffert <seth.hoffert@gmail.com> | 2023-10-22 14:12:45 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2024-05-08 13:06:15 +0000 |
commit | 3f6515c20f381d6e136c8c322eadc69fd0e6c4aa (patch) | |
tree | db631112cd73c3f58f02eb00e25b56675d5c2392 | |
parent | ebc5b3b08560d900f5013038d0fd1bb484a4f187 (diff) | |
download | src-3f6515c20f381d6e136c8c322eadc69fd0e6c4aa.tar.gz src-3f6515c20f381d6e136c8c322eadc69fd0e6c4aa.zip |
bpf: Make BPF interop consistent with if_loop
The pseudo_AF_HDRCMPLT check is already being done in if_loop and
just needed to be ported over to if_ic, if_wg, if_disc, if_gif,
if_gre, if_me, if_tuntap and ng_iface. This is needed in order to
allow these interfaces to work properly with e.g., tcpreplay.
PR: 256587
Reviewed by: markj
MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/876
(cherry picked from commit 2cb0fce24d64039090dc9243cdf0715ee80c91b1)
-rw-r--r-- | sys/dev/iicbus/if_ic.c | 4 | ||||
-rw-r--r-- | sys/dev/wg/if_wg.c | 3 | ||||
-rw-r--r-- | sys/net/if_disc.c | 2 | ||||
-rw-r--r-- | sys/net/if_gif.c | 3 | ||||
-rw-r--r-- | sys/net/if_gre.c | 3 | ||||
-rw-r--r-- | sys/net/if_me.c | 3 | ||||
-rw-r--r-- | sys/net/if_tuntap.c | 2 | ||||
-rw-r--r-- | sys/netgraph/ng_iface.c | 2 |
8 files changed, 13 insertions, 9 deletions
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index 4ca8f3960298..52ab5afb9c4e 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -363,8 +363,8 @@ icoutput(if_t ifp, struct mbuf *m, const struct sockaddr *dst, u_char *cp; u_int32_t hdr; - /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) + /* BPF writes need to be handled specially. */ + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &hdr, sizeof(hdr)); else hdr = RO_GET_FAMILY(ro, dst); diff --git a/sys/dev/wg/if_wg.c b/sys/dev/wg/if_wg.c index 2c867956912a..30429c3725cd 100644 --- a/sys/dev/wg/if_wg.c +++ b/sys/dev/wg/if_wg.c @@ -2194,7 +2194,8 @@ wg_output(if_t ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro int ret; struct mbuf *defragged; - if (dst->sa_family == AF_UNSPEC) + /* BPF writes need to be handled specially. */ + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) memcpy(&af, dst->sa_data, sizeof(af)); else af = dst->sa_family; diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index 02f3bbbfdaf1..193bb31d138f 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -182,7 +182,7 @@ discoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, M_ASSERTPKTHDR(m); /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &af, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index e5065889d732..ef64c15074ed 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -408,7 +408,8 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, KASSERT(ifp->if_bridge == NULL, ("%s: unexpectedly called with bridge attached", __func__)); - if (dst->sa_family == AF_UNSPEC) + /* BPF writes need to be handled specially. */ + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) memcpy(&af, dst->sa_data, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 55163416f807..ca9c4835daf6 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -609,7 +609,8 @@ gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, { uint32_t af; - if (dst->sa_family == AF_UNSPEC) + /* BPF writes need to be handled specially. */ + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &af, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); diff --git a/sys/net/if_me.c b/sys/net/if_me.c index e9bcd345b5c5..80c2816b808a 100644 --- a/sys/net/if_me.c +++ b/sys/net/if_me.c @@ -539,7 +539,8 @@ me_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, { uint32_t af; - if (dst->sa_family == AF_UNSPEC) + /* BPF writes need to be handled specially. */ + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &af, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); diff --git a/sys/net/if_tuntap.c b/sys/net/if_tuntap.c index 4cb219dc92b6..5d37879e87b9 100644 --- a/sys/net/if_tuntap.c +++ b/sys/net/if_tuntap.c @@ -1442,7 +1442,7 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, } /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &af, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 8ae4707b7abd..e9f97ff0fdec 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -367,7 +367,7 @@ ng_iface_output(struct ifnet *ifp, struct mbuf *m, } /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) + if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT) bcopy(dst->sa_data, &af, sizeof(af)); else af = RO_GET_FAMILY(ro, dst); |