diff options
author | sam <sam@FreeBSD.org> | 2003-12-28 03:56:00 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-12-28 03:56:00 +0000 |
commit | c165a87f8dfc070bceb68d9c3ff183ec2135e060 (patch) | |
tree | f663da0db11fcecb5ff2d3e93732492fb4d7bd29 /sys/dev/iicbus | |
parent | 853a4ae85d691a2f3500efc16c2eab14e3c117b0 (diff) | |
download | FreeBSD-src-c165a87f8dfc070bceb68d9c3ff183ec2135e060.zip FreeBSD-src-c165a87f8dfc070bceb68d9c3ff183ec2135e060.tar.gz |
o eliminate widespread on-stack mbuf use for bpf by introducing
a new bpf_mtap2 routine that does the right thing for an mbuf
and a variable-length chunk of data that should be prepended.
o while we're sweeping the drivers, use u_int32_t uniformly when
when prepending the address family (several places were assuming
sizeof(int) was 4)
o return M_ASSERTVALID to BPF_MTAP* now that all stack-allocated
mbufs have been eliminated; this may better be moved to the bpf
routines
Reviewed by: arch@ and several others
Diffstat (limited to 'sys/dev/iicbus')
-rw-r--r-- | sys/dev/iicbus/if_ic.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/sys/dev/iicbus/if_ic.c b/sys/dev/iicbus/if_ic.c index a98720f..e712b9b 100644 --- a/sys/dev/iicbus/if_ic.c +++ b/sys/dev/iicbus/if_ic.c @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #define PCF_MASTER_ADDRESS 0xaa -#define ICHDRLEN sizeof(u_int) +#define ICHDRLEN sizeof(u_int32_t) #define ICMTU 1500 /* default mtu */ struct ic_softc { @@ -369,7 +369,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m, int s, len, sent; struct mbuf *mm; u_char *cp; - u_int hdr = dst->sa_family; + u_int32_t hdr = dst->sa_family; ifp->if_flags |= IFF_RUNNING; @@ -400,23 +400,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m, } while ((mm = mm->m_next)); - if (ifp->if_bpf) { - struct mbuf m0, *n = m; - - /* - * We need to prepend the address family as - * a four byte field. Cons up a dummy header - * to pacify bpf. This is safe because bpf - * will only read from the mbuf (i.e., it won't - * try to free it or keep a pointer a to it). - */ - m0.m_next = m; - m0.m_len = sizeof(u_int); - m0.m_data = (char *)&hdr; - n = &m0; - - BPF_MTAP(ifp, n); - } + BPF_MTAP2(ifp, &hdr, sizeof(hdr), m); sc->ic_sending = 1; |