Module Name: src Committed By: thorpej Date: Thu Sep 1 02:35:06 UTC 2022
Modified Files: src/sys/net: pktqueue.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/net/pktqueue.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/pktqueue.c diff -u src/sys/net/pktqueue.c:1.16 src/sys/net/pktqueue.c:1.17 --- src/sys/net/pktqueue.c:1.16 Tue Dec 21 04:09:32 2021 +++ src/sys/net/pktqueue.c Thu Sep 1 02:35:06 2022 @@ -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 @@ pktq_dequeue(pktqueue_t *pq) 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);