Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Jan 2021 21:43:01 GMT
From:      Vincenzo Maffione <vmaffione@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3189ba61673a - main - netmap: iflib: fix asserts in netmap_fl_refill()
Message-ID:  <202101092143.109Lh1XJ069436@gitrepo.freebsd.org>

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

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

commit 3189ba61673af5bd3ed2ee9e33be92bc0b9995ba
Author:     Vincenzo Maffione <vmaffione@FreeBSD.org>
AuthorDate: 2021-01-09 21:35:07 +0000
Commit:     Vincenzo Maffione <vmaffione@FreeBSD.org>
CommitDate: 2021-01-09 21:35:07 +0000

    netmap: iflib: fix asserts in netmap_fl_refill()
    
    When netmap_fl_refill() is called at initialization time (e.g.,
    during netmap_iflib_register()), nic_i must be 0, since the
    free list is reinitialized. At the end of the refill cycle, nic_i
    must still be zero, because exactly N descriptors (N is the ring size)
    are refilled.
    This patch therefore fixes the assertions to check on nic_i rather
    than on nm_i. The current netmap_reset() may in fact cause nm_i
    to be != 0 while the device is resetting: this may happen when
    multiple non-cooperating processes open different subsets of the
    available netmap rings.
    
    PR:         252518
    MFC after:  1 week
---
 sys/net/iflib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 1b86fd670ac4..cf02b1574c10 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -883,6 +883,7 @@ netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring *kring, bool init)
 	iru_init(&iru, rxq, 0 /* flid */);
 	map = fl->ifl_sds.ifsd_map;
 	nic_i = fl->ifl_pidx;
+	MPASS(!init || nic_i == 0); /* on init/reset, nic_i must be 0 */
 	MPASS(nic_i == netmap_idx_k2n(kring, nm_i));
 	DBG_COUNTER_INC(fl_refills);
 	while (n > 0) {
@@ -923,7 +924,7 @@ netmap_fl_refill(iflib_rxq_t rxq, struct netmap_kring *kring, bool init)
 		ctx->isc_rxd_refill(ctx->ifc_softc, &iru);
 	}
 	fl->ifl_pidx = nic_i;
-	MPASS(!init || nm_i == 0);
+	MPASS(!init || nic_i == 0); /* on init/reset nic_i wraps around to 0 */
 	MPASS(nm_i == kring->rhead);
 	kring->nr_hwcur = nm_i;
 



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