1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-14 10:09:48 +00:00

netmap: iflib: stop krings during interface reset

When different processes open separate subsets of the
available rings of a same netmap interface, a device
reset may be performed while one of the processes
is actively using some rings (e.g., caused by another
process executing a nmport_open()).
With this patch, such situation will cause the
active process to get a POLLERR, so that it can
have a chance to detect the situation.
We also guarantee that no process is running a txsync
or rxsync (ioctl or poll) while an iflib device reset
is in progress.

PR:	    252453
MFC after:  1 week
This commit is contained in:
Vincenzo Maffione 2021-01-09 20:54:11 +00:00
parent faaf43b2a7
commit 1d238b07d5
2 changed files with 10 additions and 1 deletions

View File

@ -4236,7 +4236,7 @@ nm_set_native_flags(struct netmap_adapter *na)
struct ifnet *ifp = na->ifp;
/* We do the setup for intercepting packets only if we are the
* first user of this adapapter. */
* first user of this adapter. */
if (na->active_fds > 0) {
return;
}

View File

@ -809,6 +809,13 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff)
if (!CTX_IS_VF(ctx))
IFDI_CRCSTRIP_SET(ctx, onoff, iflib_crcstrip);
/*
* Stop any pending txsync/rxsync and prevent new ones
* form starting. Processes blocked in poll() will get
* POLLERR.
*/
netmap_disable_all_rings(ifp);
iflib_stop(ctx);
/*
@ -828,6 +835,8 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff)
if (status)
nm_clear_native_flags(na);
CTX_UNLOCK(ctx);
/* Re-enable txsync/rxsync. */
netmap_enable_all_rings(ifp);
return (status);
}