Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jan 2021 18:03:03 GMT
From:      Lutz Donnerhacke <donner@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d7dd28bb09fa - main - netgraph/ng_source: If queue is full, don't enqueue
Message-ID:  <202101231803.10NI332d010594@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by donner:

URL: https://cgit.FreeBSD.org/src/commit/?id=d7dd28bb09fa51b9958a5dc288d2aeef56a67491

commit d7dd28bb09fa51b9958a5dc288d2aeef56a67491
Author:     Lutz Donnerhacke <donner@FreeBSD.org>
AuthorDate: 2021-01-23 17:54:47 +0000
Commit:     Lutz Donnerhacke <donner@FreeBSD.org>
CommitDate: 2021-01-23 17:54:47 +0000

    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
---
 sys/netgraph/ng_source.c | 9 ++++++---
 1 file 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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101231803.10NI332d010594>