diff options
author | Vincenzo Maffione <vmaffione@FreeBSD.org> | 2020-06-14 21:07:12 +0000 |
---|---|---|
committer | Vincenzo Maffione <vmaffione@FreeBSD.org> | 2020-06-14 21:07:12 +0000 |
commit | 0a182b4c63297560804fe44d98f05806af7adf8d (patch) | |
tree | 15e8c678850583aabcd6647c9b6b5f0badbd1c0f /sys/net | |
parent | dfdeb45425cf025ce32c517ec3f85a8dd9fdff54 (diff) | |
download | src-0a182b4c63297560804fe44d98f05806af7adf8d.tar.gz src-0a182b4c63297560804fe44d98f05806af7adf8d.zip |
iflib: netmap: enter/exit netmap mode after device stops
Avoid possible race conditions by calling nm_set_native_flags()
and nm_clear_native_flags() only after the device has been
stopped.
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=362185
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/iflib.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 4f03ee6d4b87..94178ea14af3 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -788,13 +788,19 @@ iflib_netmap_register(struct netmap_adapter *na, int onoff) if (!CTX_IS_VF(ctx)) IFDI_CRCSTRIP_SET(ctx, onoff, iflib_crcstrip); - /* enable or disable flags and callbacks in na and ifp */ + iflib_stop(ctx); + + /* + * Enable (or disable) netmap flags, and intercept (or restore) + * ifp->if_transmit. This is done once the device has been stopped + * to prevent race conditions. + */ if (onoff) { nm_set_native_flags(na); } else { nm_clear_native_flags(na); } - iflib_stop(ctx); + iflib_init_locked(ctx); IFDI_CRCSTRIP_SET(ctx, onoff, iflib_crcstrip); // XXX why twice ? status = ifp->if_drv_flags & IFF_DRV_RUNNING ? 0 : 1; |