aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincenzo Maffione <vmaffione@FreeBSD.org>2021-01-09 21:35:07 +0000
committerVincenzo Maffione <vmaffione@FreeBSD.org>2021-01-09 21:35:07 +0000
commit3189ba61673af5bd3ed2ee9e33be92bc0b9995ba (patch)
tree132ae92dccfca3199315c3088c626142a076e282
parent1d238b07d5d4d9660ae0e08daede6da7e91c7853 (diff)
downloadsrc-3189ba61673af5bd3ed2ee9e33be92bc0b9995ba.tar.gz
src-3189ba61673af5bd3ed2ee9e33be92bc0b9995ba.zip
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
-rw-r--r--sys/net/iflib.c3
1 files changed, 2 insertions, 1 deletions
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;