diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2005-06-26 18:11:11 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2005-06-26 18:11:11 +0000 |
commit | f1f0123e88adadd09a074577a66eedcdcfa047bc (patch) | |
tree | 5510fdb16b02fe3d6d31530943a20683c2479916 /sys/net/if_stf.c | |
parent | 573c1a10201fed9f95880691f90de7ade6ee0d48 (diff) | |
download | FreeBSD-src-f1f0123e88adadd09a074577a66eedcdcfa047bc.zip FreeBSD-src-f1f0123e88adadd09a074577a66eedcdcfa047bc.tar.gz |
Fix some long standing bugs in writing to the BPF device attached to
a DLT_NULL interface. In particular:
1) Consistently use type u_int32_t for the header of a
DLT_NULL device - it continues to represent the address
family as always.
2) In the DLT_NULL case get bpf_movein to store the u_int32_t
in a sockaddr rather than in the mbuf, to be consistent
with all the DLT types.
3) Consequently fix a bug in bpf_movein/bpfwrite which
only permitted packets up to 4 bytes less than the MTU
to be written.
4) Fix all DLT_NULL devices to have the code required to
allow writing to their bpf devices.
5) Move the code to allow writing to if_lo from if_simloop
to looutput, because it only applies to DLT_NULL devices
but was being applied to other devices that use if_simloop
possibly incorrectly.
PR: 82157
Submitted by: Matthew Luckie <mjl@luckie.org.nz>
Approved by: re (scottl)
Diffstat (limited to 'sys/net/if_stf.c')
-rw-r--r-- | sys/net/if_stf.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index c848e2a..3ba3343 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -245,7 +245,7 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len) ifp->if_output = stf_output; ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; if_attach(ifp); - bpfattach(ifp, DLT_NULL, sizeof(u_int)); + bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); mtx_lock(&stf_mtx); LIST_INSERT_HEAD(&stf_softc_list, sc, sc_list); mtx_unlock(&stf_mtx); @@ -438,6 +438,7 @@ stf_output(ifp, m, dst, rt) struct ip *ip; struct ip6_hdr *ip6; struct in6_ifaddr *ia6; + u_int32_t af; #ifdef MAC int error; @@ -481,6 +482,15 @@ stf_output(ifp, m, dst, rt) tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; /* + * BPF writes need to be handled specially. + * This is a null operation, nothing here checks dst->sa_family. + */ + if (dst->sa_family == AF_UNSPEC) { + bcopy(dst->sa_data, &af, sizeof(af)); + dst->sa_family = af; + } + + /* * Pickup the right outer dst addr from the list of candidates. * ip6_dst has priority as it may be able to give us shorter IPv4 hops. */ @@ -504,7 +514,7 @@ stf_output(ifp, m, dst, rt) * will only read from the mbuf (i.e., it won't * try to free it or keep a pointer a to it). */ - u_int32_t af = AF_INET6; + af = AF_INET6; bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); } |