diff options
author | 2017-05-03 20:55:29 +0000 | |
---|---|---|
committer | 2017-05-03 20:55:29 +0000 | |
commit | 45e6331d53e81841e39bf5fbed7e4126adaefe61 (patch) | |
tree | 412424d73e36e5a74b51a0fd0721a1b3715a70f1 | |
parent | Back out rev 1.185 (which made the code match the comment) and (diff) | |
download | wireguard-openbsd-45e6331d53e81841e39bf5fbed7e4126adaefe61.tar.xz wireguard-openbsd-45e6331d53e81841e39bf5fbed7e4126adaefe61.zip |
Provide a function to dispose of a list of mbufs on dequeue
ifq_mfreeml() is similar to the ifq_mfreem(), but takes an mbuf list
as an argument. This also lets these functions subtract the number
of packets to be disposed of from the ifq length.
OK dlg
-rw-r--r-- | sys/net/ifq.c | 13 | ||||
-rw-r--r-- | sys/net/ifq.h | 6 |
2 files changed, 16 insertions, 3 deletions
diff --git a/sys/net/ifq.c b/sys/net/ifq.c index 27dfa5cf2c7..d37be87f444 100644 --- a/sys/net/ifq.c +++ b/sys/net/ifq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.c,v 1.10 2017/05/03 03:14:32 dlg Exp $ */ +/* $OpenBSD: ifq.c,v 1.11 2017/05/03 20:55:29 mikeb Exp $ */ /* * Copyright (c) 2015 David Gwynne <dlg@openbsd.org> @@ -383,10 +383,21 @@ ifq_mfreem(struct ifqueue *ifq, struct mbuf *m) { IFQ_ASSERT_SERIALIZED(ifq); + ifq->ifq_len--; ifq->ifq_qdrops++; ml_enqueue(&ifq->ifq_free, m); } +void +ifq_mfreeml(struct ifqueue *ifq, struct mbuf_list *ml) +{ + IFQ_ASSERT_SERIALIZED(ifq); + + ifq->ifq_len -= ml_len(ml); + ifq->ifq_qdrops += ml_len(ml); + ml_enlist(&ifq->ifq_free, ml); +} + /* * priq implementation */ diff --git a/sys/net/ifq.h b/sys/net/ifq.h index 82e0e3bcbd8..29b89c38b23 100644 --- a/sys/net/ifq.h +++ b/sys/net/ifq.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ifq.h,v 1.12 2017/05/03 03:41:09 dlg Exp $ */ +/* $OpenBSD: ifq.h,v 1.13 2017/05/03 20:55:29 mikeb Exp $ */ /* * Copyright (c) 2015 David Gwynne <dlg@openbsd.org> @@ -171,7 +171,7 @@ struct ifqueue { * The queue lock acquired with ifq_q_enter() is released with * ifq_q_leave(). * - * === ifq_mfreem() + * === ifq_mfreem() and ifq_mfreeml() * * A goal of the API is to avoid freeing an mbuf while mutexs are * held. Because the ifq API manages the lock on behalf of the backend @@ -179,6 +179,7 @@ struct ifqueue { * backend needs to drop a packet during the handling of ifqop_deq_begin, * it may free it by calling ifq_mfreem(). This accounts for the drop, * and schedules the free of the mbuf outside the hold of ifq_mtx. + * ifq_mfreeml() takes an mbuf list as an argument instead. * * * == Network Driver API @@ -382,6 +383,7 @@ void ifq_deq_commit(struct ifqueue *, struct mbuf *); void ifq_deq_rollback(struct ifqueue *, struct mbuf *); struct mbuf *ifq_dequeue(struct ifqueue *); void ifq_mfreem(struct ifqueue *, struct mbuf *); +void ifq_mfreeml(struct ifqueue *, struct mbuf_list *); unsigned int ifq_purge(struct ifqueue *); void *ifq_q_enter(struct ifqueue *, const struct ifq_ops *); void ifq_q_leave(struct ifqueue *, void *); |