Index: sys/mbuf.h =================================================================== RCS file: /cvs/src/sys/sys/mbuf.h,v retrieving revision 1.185 diff -u -p -r1.185 mbuf.h --- sys/mbuf.h 7 Feb 2015 02:30:00 -0000 1.185 +++ sys/mbuf.h 9 Feb 2015 04:50:12 -0000 @@ -433,6 +433,7 @@ void m_extfree_pool(caddr_t, u_int, void void m_adj(struct mbuf *, int); int m_copyback(struct mbuf *, int, int, const void *, int); void m_freem(struct mbuf *); +void m_freec(struct mbuf *); void m_reclaim(void *, int); void m_copydata(struct mbuf *, int, int, caddr_t); void m_cat(struct mbuf *, struct mbuf *); @@ -501,7 +502,7 @@ void ml_enqueue(struct mbuf_list *, st struct mbuf * ml_dequeue(struct mbuf_list *); struct mbuf * ml_dechain(struct mbuf_list *); struct mbuf * ml_filter(struct mbuf_list *, - int (*)(void *, const struct mbuf *), void *); + int (*)(void *, struct mbuf *), void *); #define ml_len(_ml) ((_ml)->ml_len) #define ml_empty(_ml) ((_ml)->ml_len == 0) @@ -530,7 +531,7 @@ int mq_enlist(struct mbuf_queue *, str void mq_delist(struct mbuf_queue *, struct mbuf_list *); struct mbuf * mq_dechain(struct mbuf_queue *); struct mbuf * mq_filter(struct mbuf_queue *, - int (*)(void *, const struct mbuf *), void *); + int (*)(void *, struct mbuf *), void *); #define mq_len(_mq) ml_len(&(_mq)->mq_list) #define mq_empty(_mq) ml_empty(&(_mq)->mq_list) Index: kern/uipc_mbuf.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.201 diff -u -p -r1.201 uipc_mbuf.c --- kern/uipc_mbuf.c 7 Feb 2015 02:52:09 -0000 1.201 +++ kern/uipc_mbuf.c 9 Feb 2015 04:50:12 -0000 @@ -127,7 +127,7 @@ void m_zero(struct mbuf *); const char *mclpool_warnmsg = - "WARNING: mclpools limit reached; increase kern.maxclusters"; + "WARNING: mbuf limit reached; increase kern.maxclusters"; /* * Initialize the mbuf allocator. @@ -147,7 +147,6 @@ mbinit(void) pool_init(&mbpool, MSIZE, 0, 0, 0, "mbufpl", NULL); pool_setipl(&mbpool, IPL_NET); pool_set_constraints(&mbpool, &kp_dma_contig); - pool_setlowat(&mbpool, mblowat); pool_init(&mtagpool, PACKET_TAG_MAXSIZE + sizeof(struct m_tag), 0, 0, 0, "mtagpl", NULL); @@ -160,7 +159,6 @@ mbinit(void) mclnames[i], NULL); pool_setipl(&mclpools[i], IPL_NET); pool_set_constraints(&mclpools[i], &kp_dma_contig); - pool_setlowat(&mclpools[i], mcllowat); } nmbclust_update(); @@ -169,25 +167,7 @@ mbinit(void) void nmbclust_update(void) { - int i; - /* - * Set the hard limit on the mclpools to the number of - * mbuf clusters the kernel is to support. Log the limit - * reached message max once a minute. - */ - for (i = 0; i < nitems(mclsizes); i++) { - (void)pool_sethardlimit(&mclpools[i], nmbclust, - mclpool_warnmsg, 60); - /* - * XXX this needs to be reconsidered. - * Setting the high water mark to nmbclust is too high - * but we need to have enough spare buffers around so that - * allocations in interrupt context don't fail or mclgeti() - * drivers may end up with empty rings. - */ - pool_sethiwat(&mclpools[i], nmbclust); - } - pool_sethiwat(&mbpool, nmbclust); + (void)pool_sethardlimit(&mbpool, nmbclust, mclpool_warnmsg, 60); } /* @@ -399,6 +379,19 @@ m_freem(struct mbuf *m) m = m_free(m); } +void +m_freec(struct mbuf *m) +{ + struct mbuf *m0; + + while (m != NULL) { + m0 = m->m_nextpkt; + m->m_nextpkt = NULL; + m_freem(m); + m = m0; + } +} + /* * mbuf chain defragmenter. This function uses some evil tricks to defragment * an mbuf chain into a single buffer without changing the mbuf pointer. @@ -1311,7 +1304,7 @@ ml_dechain(struct mbuf_list *ml) struct mbuf * ml_filter(struct mbuf_list *ml, - int (*filter)(void *, const struct mbuf *), void *ctx) + int (*filter)(void *, struct mbuf *), void *ctx) { struct mbuf_list matches = MBUF_LIST_INITIALIZER(); struct mbuf *m, *n; @@ -1428,7 +1421,7 @@ mq_dechain(struct mbuf_queue *mq) struct mbuf * mq_filter(struct mbuf_queue *mq, - int (*filter)(void *, const struct mbuf *), void *ctx) + int (*filter)(void *, struct mbuf *), void *ctx) { struct mbuf *m0; Index: net/if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.319 diff -u -p -r1.319 if.c --- net/if.c 9 Feb 2015 03:09:57 -0000 1.319 +++ net/if.c 9 Feb 2015 04:50:12 -0000 @@ -109,6 +109,7 @@ #if NBPFILTER > 0 #include +int if_input_bpf(void *, struct mbuf *); #endif #if NBRIDGE > 0 @@ -432,6 +433,18 @@ if_start(struct ifnet *ifp) } } +#if NBPFILTER > 0 +int +if_input_bpf(void *xifp, struct mbuf *m) +{ + struct ifnet *ifp = xifp; + + bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); + + return (ISSET(m->m_flags, M_FILDROP)); +} +#endif + void if_input(struct ifnet *ifp, struct mbuf_list *ml) { @@ -440,14 +453,16 @@ if_input(struct ifnet *ifp, struct mbuf_ splassert(IPL_NET); +#if NBPFILTER > 0 + if (ifp->if_bpf) { + m = ml_filter(ml, if_input_bpf, ifp); + m_freec(m); + } +#endif + while ((m = ml_dequeue(ml)) != NULL) { m->m_pkthdr.rcvif = ifp; m->m_pkthdr.ph_rtableid = ifp->if_rdomain; - -#if NBPFILTER > 0 - if (ifp->if_bpf) - bpf_mtap_ether(ifp->if_bpf, m, BPF_DIRECTION_IN); -#endif SLIST_FOREACH(ifih, &ifp->if_inputs, ifih_next) { if ((*ifih->ifih_input)(ifp, NULL, m))