aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Donnerhacke <donner@FreeBSD.org>2021-01-23 17:54:47 +0000
committerLutz Donnerhacke <donner@FreeBSD.org>2021-05-09 13:45:07 +0000
commit3da0d11afe0807ccbbb9f447e6c814dce654d71d (patch)
treecd5690f082e0ee0bf9526fdef87ee269dd565553
parent0d8ba15a0e9dbb5928d0fd89011417b707f7a366 (diff)
downloadsrc-3da0d11afe0807ccbbb9f447e6c814dce654d71d.tar.gz
src-3da0d11afe0807ccbbb9f447e6c814dce654d71d.zip
netgraph/ng_source: If queue is full, don't enqueue
Submitted by: nc Reviewed by: donner, kp Differential Revision: https://reviews.freebsd.org/D23477 (cherry picked from commit d7dd28bb09fa51b9958a5dc288d2aeef56a67491)
-rw-r--r--sys/netgraph/ng_source.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/netgraph/ng_source.c b/sys/netgraph/ng_source.c
index da8f42381ac3..8d1d05b5673f 100644
--- a/sys/netgraph/ng_source.c
+++ b/sys/netgraph/ng_source.c
@@ -284,7 +284,7 @@ ng_source_constructor(node_p node)
NG_NODE_SET_PRIVATE(node, sc);
sc->node = node;
- sc->snd_queue.ifq_maxlen = 2048; /* XXX not checked */
+ sc->snd_queue.ifq_maxlen = 2048;
ng_callout_init(&sc->intr_ch);
return (0);
@@ -567,8 +567,11 @@ ng_source_rcvdata(hook_p hook, item_p item)
}
KASSERT(hook == sc->input, ("%s: no hook!", __func__));
- /* Enqueue packet. */
- /* XXX should we check IF_QFULL() ? */
+ /* Enqueue packet if the queue isn't full. */
+ if (_IF_QFULL(&sc->snd_queue)) {
+ NG_FREE_M(m);
+ return (ENOBUFS);
+ }
_IF_ENQUEUE(&sc->snd_queue, m);
sc->queueOctets += m->m_pkthdr.len;
sc->last_packet = m;