summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-11-02 09:21:49 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-11-02 09:21:49 +0000
commit0a52a71ed2b0cc46e043d928eec873aebc947244 (patch)
tree364b1cd1094492187b43506049abbc190f6b35c5 /sys/kern
parentd38f5eb49596b360f93ccf67fe305780aaf44c3e (diff)
provide ml_purge and mq_purge.
these are modelled on IF_PURGE or IFQ_PURGE. they m_freem all the mbufs on an mbuf list or queue. ok jmatthew@ mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_mbuf.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 06fe2bc3d0f..78b70935be3 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.210 2015/10/30 19:47:40 bluhm Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.211 2015/11/02 09:21:48 dlg Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -1368,6 +1368,23 @@ ml_filter(struct mbuf_list *ml,
return (matches.ml_head); /* ml_dechain */
}
+unsigned int
+ml_purge(struct mbuf_list *ml)
+{
+ struct mbuf *m, *n;
+ unsigned int len;
+
+ for (m = ml->ml_head; m != NULL; m = n) {
+ n = m->m_nextpkt;
+ m_freem(m);
+ }
+
+ len = ml->ml_len;
+ ml_init(ml);
+
+ return (len);
+}
+
/*
* mbuf queues
*/
@@ -1481,3 +1498,13 @@ mq_filter(struct mbuf_queue *mq,
return (m0);
}
+
+unsigned int
+mq_purge(struct mbuf_queue *mq)
+{
+ struct mbuf_list ml;
+
+ mq_delist(mq, &ml);
+
+ return (ml_purge(&ml));
+}