mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add locks before each ena_up and ena_down
Lock only ena_up and ena_down calls in ioctl handler, instead of whole ioctl. Locking ioctl with sx lock that is sleepable, is not allowed in some cases, e.g. when multicast options are being changed. Additional locking was added in deatch function to prevent race condition with ioctl function. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon.com Inc. Differential revision: https://reviews.freebsd.org/D10924
This commit is contained in:
parent
1e9fb89962
commit
e67c655431
1 changed files with 12 additions and 5 deletions
|
|
@ -2285,16 +2285,16 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
|||
/*
|
||||
* Acquiring lock to prevent from running up and down routines parallel.
|
||||
*/
|
||||
sx_xlock(&adapter->ioctl_sx);
|
||||
|
||||
rc = 0;
|
||||
switch (command) {
|
||||
case SIOCSIFMTU:
|
||||
sx_xlock(&adapter->ioctl_sx);
|
||||
ena_down(adapter);
|
||||
|
||||
ena_change_mtu(ifp, ifr->ifr_mtu);
|
||||
|
||||
rc = ena_up(adapter);
|
||||
sx_unlock(&adapter->ioctl_sx);
|
||||
break;
|
||||
|
||||
case SIOCSIFFLAGS:
|
||||
|
|
@ -2306,11 +2306,16 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
|||
"ioctl promisc/allmulti\n");
|
||||
}
|
||||
} else {
|
||||
sx_xlock(&adapter->ioctl_sx);
|
||||
rc = ena_up(adapter);
|
||||
sx_unlock(&adapter->ioctl_sx);
|
||||
}
|
||||
} else {
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING)
|
||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
||||
sx_xlock(&adapter->ioctl_sx);
|
||||
ena_down(adapter);
|
||||
sx_unlock(&adapter->ioctl_sx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -2333,8 +2338,10 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
|||
}
|
||||
|
||||
if (reinit && (ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
||||
sx_xlock(&adapter->ioctl_sx);
|
||||
ena_down(adapter);
|
||||
rc = ena_up(adapter);
|
||||
sx_unlock(&adapter->ioctl_sx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2344,8 +2351,6 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data)
|
|||
break;
|
||||
}
|
||||
|
||||
sx_unlock(&adapter->ioctl_sx);
|
||||
|
||||
return (rc);
|
||||
}
|
||||
|
||||
|
|
@ -3666,7 +3671,9 @@ ena_detach(device_t pdev)
|
|||
taskqueue_drain(adapter->reset_tq, &adapter->reset_task);
|
||||
taskqueue_free(adapter->reset_tq);
|
||||
|
||||
sx_xlock(&adapter->ioctl_sx);
|
||||
ena_down(adapter);
|
||||
sx_unlock(&adapter->ioctl_sx);
|
||||
|
||||
if (adapter->ifp != NULL) {
|
||||
ether_ifdetach(adapter->ifp);
|
||||
|
|
|
|||
Loading…
Reference in a new issue