aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLutz Donnerhacke <donner@FreeBSD.org>2021-01-23 17:54:47 +0000
committerLutz Donnerhacke <donner@FreeBSD.org>2021-01-23 17:54:47 +0000
commitd7dd28bb09fa51b9958a5dc288d2aeef56a67491 (patch)
tree413460aa9445ef51127406ee3e307d4df99b6b6c
parent519b64e27fddf10c0b7f6a615edbad730b8c6c45 (diff)
netgraph/ng_source: If queue is full, don't enqueue
Submitted by: nc Reviewed by: donner, kp Approved by: kp (mentor) Differential Revision: https://reviews.freebsd.org/D23477
-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 401548da65d0..4bde62e5898a 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;