diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-08-14 05:25:30 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-08-14 05:25:30 +0000 |
commit | fc5e6e905c0592dfb3e47078a194cb111c88b040 (patch) | |
tree | 0c2413c61cf523c5a1b55960eb7ab526404a6e3c /sys/kern | |
parent | 33c89536397ceb5dd2950df6e201816950484c60 (diff) |
provide ml_requeue and mq_requeue for prepending mbufs on lists/queues
ok mpi@ claudio@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 1a67eac45fd..a09bc982ea6 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.206 2015/07/15 22:29:32 deraadt Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.207 2015/08/14 05:25:29 dlg Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1299,6 +1299,19 @@ ml_dequeue(struct mbuf_list *ml) return (m); } +void +ml_requeue(struct mbuf_list *ml, struct mbuf *m) +{ + if (ml->ml_tail == NULL) + ml->ml_head = ml->ml_tail = m; + else { + m->m_nextpkt = ml->ml_head; + ml->ml_head = m; + } + + ml->ml_len++; +} + struct mbuf * ml_dechain(struct mbuf_list *ml) { @@ -1385,6 +1398,19 @@ mq_dequeue(struct mbuf_queue *mq) } int +mq_requeue(struct mbuf_queue *mq, struct mbuf *m) +{ + int full; + + mtx_enter(&mq->mq_mtx); + ml_requeue(&mq->mq_list, m); + full = mq_len(mq) > mq->mq_maxlen; + mtx_leave(&mq->mq_mtx); + + return (full); +} + +int mq_enlist(struct mbuf_queue *mq, struct mbuf_list *ml) { struct mbuf *m; |