Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jun 2022 14:36:24 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 841433148101 - main - debugnet: Handle batches of packets from if_input
Message-ID:  <202206161436.25GEaO6N056664@gitrepo.freebsd.org>

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

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

commit 841433148101aafcec8c24ae02efb042c7dfb34b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-06-16 14:02:00 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-06-16 14:02:00 +0000

    debugnet: Handle batches of packets from if_input
    
    Some drivers will collect multiple mbuf chains, linked by m_nextpkt,
    before passing them to upper layers.  debugnet_pkt_in() didn't handle
    this and would process only the first packet, typically leading to
    retransmits.
    
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
---
 sys/net/debugnet.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/sys/net/debugnet.c b/sys/net/debugnet.c
index fa8d64ab86c8..a197017c1767 100644
--- a/sys/net/debugnet.c
+++ b/sys/net/debugnet.c
@@ -523,7 +523,7 @@ debugnet_handle_udp(struct debugnet_pcb *pcb, struct mbuf **mb)
  *	m	an mbuf containing the packet received
  */
 static void
-debugnet_pkt_in(struct ifnet *ifp, struct mbuf *m)
+debugnet_input_one(struct ifnet *ifp, struct mbuf *m)
 {
 	struct ifreq ifr;
 	struct ether_header *eh;
@@ -582,6 +582,19 @@ done:
 		m_freem(m);
 }
 
+static void
+debugnet_input(struct ifnet *ifp, struct mbuf *m)
+{
+	struct mbuf *n;
+
+	do {
+		n = m->m_nextpkt;
+		m->m_nextpkt = NULL;
+		debugnet_input_one(ifp, m);
+		m = n;
+	} while (m != NULL);
+}
+
 /*
  * Network polling primitive.
  *
@@ -736,13 +749,13 @@ debugnet_connect(const struct debugnet_conn_params *dcp,
 	/*
 	 * We maintain the invariant that g_debugnet_pcb_inuse is always true
 	 * while the debugnet ifp's if_input is overridden with
-	 * debugnet_pkt_in.
+	 * debugnet_input().
 	 */
 	g_debugnet_pcb_inuse = true;
 
 	/* Make the card use *our* receive callback. */
 	pcb->dp_drv_input = ifp->if_input;
-	ifp->if_input = debugnet_pkt_in;
+	ifp->if_input = debugnet_input;
 
 	printf("%s: searching for %s MAC...\n", __func__,
 	    (dcp->dc_gateway == INADDR_ANY) ? "server" : "gateway");



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