Hi,
This reserves max_linkhdr bytes for a link layer header in the newly
allocated cluster in the bpf injection path like it's done for the
packets originating on the host itself (cf. tcp_output). Saves us
time doing costly pool allocations later on.
I believe this has been tested by Yasuoka-san.
OK?
diff --git sys/net/bpf.c sys/net/bpf.c
index 86f5f6d..6cdf789 100644
--- sys/net/bpf.c
+++ sys/net/bpf.c
@@ -200,17 +200,18 @@ bpf_movein(struct uio *uio, u_int linktype, struct mbuf
**mp,
MGETHDR(m, M_WAIT, MT_DATA);
m->m_pkthdr.ph_ifidx = 0;
m->m_pkthdr.len = len - hlen;
- if (len > MHLEN) {
- MCLGETI(m, M_WAIT, NULL, len);
+ if (len + max_linkhdr > MHLEN) {
+ MCLGETI(m, M_WAIT, NULL, len + max_linkhdr);
if ((m->m_flags & M_EXT) == 0) {
error = ENOBUFS;
goto bad;
}
}
+ m->m_data += max_linkhdr;
m->m_len = len;
*mp = m;
error = uiomovei(mtod(m, caddr_t), len, uio);
if (error)