Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net pktq_dequeue(): Prevent packets from getting stuck b...



details:   https://anonhg.NetBSD.org/src/rev/1b20e4fcb89a
branches:  trunk
changeset: 369783:1b20e4fcb89a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Sep 01 02:35:06 2022 +0000

description:
pktq_dequeue(): Prevent packets from getting stuck beind barrier markers.

pktq_barrier() ensures that all packets enqueued before the barrier have
been dequeued before the barrier returns.  However, previously, pktq_dequeue()
would return NULL when a barrier marker was encountered.  If there were
packets queued up behind the marker and no additional softint were scheduled
for the pktqueue, those packets would end up stranded.  pktq_dequeue() now
continues to the next slot after the marker, ensuring that processing can
continue after the barrier has been signaled.

diffstat:

 sys/net/pktqueue.c |  15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 4864fda28454 -r 1b20e4fcb89a sys/net/pktqueue.c
--- a/sys/net/pktqueue.c        Thu Sep 01 01:54:38 2022 +0000
+++ b/sys/net/pktqueue.c        Thu Sep 01 02:35:06 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pktqueue.c,v 1.16 2021/12/21 04:09:32 knakahara Exp $  */
+/*     $NetBSD: pktqueue.c,v 1.17 2022/09/01 02:35:06 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.16 2021/12/21 04:09:32 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.17 2022/09/01 02:35:06 thorpej Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -410,7 +410,16 @@
        if (__predict_false(m == PKTQ_MARKER)) {
                /* Note the marker entry. */
                atomic_inc_uint(&pq->pq_barrier);
-               return NULL;
+
+               /* Get the next queue entry. */
+               m = pcq_get(pktq_pcq(pq, ci));
+
+               /*
+                * There can only be one barrier operation pending
+                * on a pktqueue at any given time, so we can assert
+                * that the next item is not a marker.
+                */
+               KASSERT(m != PKTQ_MARKER);
        }
        if (__predict_true(m != NULL)) {
                pktq_inc_count(pq, PQCNT_DEQUEUE);



Home | Main Index | Thread Index | Old Index