git: 5f6d37787f1e - main - netmap: Handle packet batches in generic mode

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 05 Apr 2023 21:08:38 UTC
The branch main has been updated by markj:

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

commit 5f6d37787f1e6aaf9b18392e8cff65ed4e094f2c
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-04-05 20:52:41 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-04-05 21:07:48 +0000

    netmap: Handle packet batches in generic mode
    
    ifnets are allowed to pass batches of multiple packets to if_input,
    linked by the m_nextpkt pointer.  iflib_rxeof() sometimes does this, for
    example.  Netmap's generic mode did not handle this and would only
    deliver the first packet in the batch, leaking the rest.
    
    PR:             270636
    Reviewed by:    vmaffione
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D39426
---
 sys/dev/netmap/netmap_freebsd.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
index e67d26d6788f..5a540b6c98b3 100644
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -325,10 +325,17 @@ freebsd_generic_rx_handler(if_t ifp, struct mbuf *m)
 		return;
 	}
 
-	stolen = generic_rx_handler(ifp, m);
-	if (!stolen) {
-		NA(ifp)->if_input(ifp, m);
-	}
+	do {
+		struct mbuf *n;
+
+		n = m->m_nextpkt;
+		m->m_nextpkt = NULL;
+		stolen = generic_rx_handler(ifp, m);
+		if (!stolen) {
+			NA(ifp)->if_input(ifp, m);
+		}
+		m = n;
+	} while (m != NULL);
 }
 
 /*