summaryrefslogtreecommitdiffstats
path: root/sys/i4b
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2005-06-26 18:11:11 +0000
committerdwmalone <dwmalone@FreeBSD.org>2005-06-26 18:11:11 +0000
commitf1f0123e88adadd09a074577a66eedcdcfa047bc (patch)
tree5510fdb16b02fe3d6d31530943a20683c2479916 /sys/i4b
parent573c1a10201fed9f95880691f90de7ade6ee0d48 (diff)
downloadFreeBSD-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/i4b')
-rw-r--r--sys/i4b/driver/i4b_ipr.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index 60d8a46..1309d73 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -272,7 +272,7 @@ i4biprattach(void *dummy)
if_attach(sc->sc_ifp);
- bpfattach(sc->sc_ifp, DLT_NULL, sizeof(u_int));
+ bpfattach(sc->sc_ifp, DLT_NULL, sizeof(u_int32_t));
}
}
@@ -288,12 +288,20 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
int s;
struct ifqueue *ifq;
struct ip *ip;
+ u_int32_t af;
s = SPLI4B();
sc = ifp->if_softc;
unit = ifp->if_dunit;
+ /* BPF writes need to be handled specially. */
+ if(dst->sa_family == AF_UNSPEC)
+ {
+ bcopy(dst->sa_data, &af, sizeof(af));
+ dst->sa_family = af;
+ }
+
/* check for IP */
if(dst->sa_family != AF_INET)
OpenPOWER on IntegriCloud