I've realised that something like this would be nice for convenience, but not crucial. I'd prefer not to pass the mbuf pointer, but there's no decent way around it.
--- sys/net/ifq.c | 12 +++++++++--- sys/net/ifq.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git sys/net/ifq.c sys/net/ifq.c index f678c2b01fd..ee302e99c3b 100644 --- sys/net/ifq.c +++ sys/net/ifq.c @@ -330,10 +330,18 @@ ifq_dequeue(struct ifqueue *ifq) ifq_deq_commit(ifq, m); return (m); } +void +ifq_drop(struct ifqueue *ifq, struct mbuf *m) +{ + m_freem(m); + ifq->ifq_len--; + ifq->ifq_qdrops++; +} + unsigned int ifq_purge(struct ifqueue *ifq) { struct mbuf_list ml = MBUF_LIST_INITIALIZER(); unsigned int rv; @@ -418,13 +426,11 @@ priq_enq(struct ifqueue *ifq, struct mbuf *m) /* Find a lower priority queue to drop from */ if (ifq_len(ifq) >= ifq->ifq_maxlen) { for (prio = 0; prio < m->m_pkthdr.pf.prio; prio++) { pl = &pq->pq_lists[prio]; if (ml_len(pl) > 0) { - m_freem(ml_dequeue(pl)); - ifq->ifq_len--; - ifq->ifq_qdrops++; + ifq_drop(ifq, ml_dequeue(pl)); break; } } /* * There's no lower priority queue that we can diff --git sys/net/ifq.h sys/net/ifq.h index 3a6891da6f6..df0193214c5 100644 --- sys/net/ifq.h +++ sys/net/ifq.h @@ -345,10 +345,11 @@ int ifq_enqueue_try(struct ifqueue *, struct mbuf *); int ifq_enqueue(struct ifqueue *, struct mbuf *); struct mbuf *ifq_deq_begin(struct ifqueue *); void ifq_deq_commit(struct ifqueue *, struct mbuf *); void ifq_deq_rollback(struct ifqueue *, struct mbuf *); struct mbuf *ifq_dequeue(struct ifqueue *); +void ifq_drop(struct ifqueue *, struct mbuf *); unsigned int ifq_purge(struct ifqueue *); void *ifq_q_enter(struct ifqueue *, const struct ifq_ops *); void ifq_q_leave(struct ifqueue *, void *); void ifq_serialize(struct ifqueue *, struct task *); int ifq_is_serialized(struct ifqueue *); -- 2.12.0