aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>2000-11-01 00:01:39 +0000
committerBrian Somers <brian@FreeBSD.org>2000-11-01 00:01:39 +0000
commit5968c93c81f338d9aacd8380b4d07e427d10bbda (patch)
tree7c5aff4a99fff2cf0cbc1c08a24d4e50e4e549b5 /sys/net
parent301b91dbdcb75029d2717c8a7f39858ccda7e563 (diff)
downloadsrc-5968c93c81f338d9aacd8380b4d07e427d10bbda.tar.gz
src-5968c93c81f338d9aacd8380b4d07e427d10bbda.zip
MFC: Correct the byte-order of the address family passed to bpf
Notes
Notes: svn path=/stable/4/; revision=68131
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_tun.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index b544f7574fcb..86c1ff2b37b5 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -339,7 +339,7 @@ tunoutput(ifp, m0, dst, rt)
* try to free it or keep a pointer to it).
*/
struct mbuf m;
- u_int af = dst->sa_family;
+ uint32_t af = dst->sa_family;
m.m_next = m0;
m.m_len = 4;
@@ -596,7 +596,7 @@ tunwrite(dev, uio, flag)
struct ifnet *ifp = &tp->tun_if;
struct mbuf *top, **mp, *m;
int error=0, tlen, mlen;
- u_int32_t family;
+ uint32_t family;
TUNDEBUG("%s%d: tunwrite\n", ifp->if_name, ifp->if_unit);
@@ -643,13 +643,20 @@ tunwrite(dev, uio, flag)
top->m_pkthdr.rcvif = ifp;
if (ifp->if_bpf) {
- if (tp->tun_flags & TUN_IFHEAD)
+ if (tp->tun_flags & TUN_IFHEAD) {
/*
* Conveniently, we already have a 4-byte address
* family prepended to our packet !
+ * Inconveniently, it's in the wrong byte order !
*/
+ if ((top = m_pullup(top, sizeof(family))) == NULL)
+ return ENOBUFS;
+ *mtod(top, u_int32_t *) =
+ ntohl(*mtod(top, u_int32_t *));
bpf_mtap(ifp, top);
- else {
+ *mtod(top, u_int32_t *) =
+ htonl(*mtod(top, u_int32_t *));
+ } else {
/*
* We need to prepend the address family as
* a four byte field. Cons up a dummy header
@@ -658,7 +665,7 @@ tunwrite(dev, uio, flag)
* try to free it or keep a pointer to it).
*/
struct mbuf m;
- u_int af = AF_INET;
+ uint32_t af = AF_INET;
m.m_next = top;
m.m_len = 4;