Index: if.c =================================================================== --- if.c (revision 223821) +++ if.c (working copy) @@ -2533,18 +2534,21 @@ return (ENXIO); } + IF_ADDR_LOCK(ifp); + if (ifp->if_flags & IFF_INIOCTL) + msleep(ifp, &ifp->if_addr_mtx, 0, "ifioctl", 0); + else + ifp->if_flags |= IFF_INIOCTL; + IF_ADDR_UNLOCK(ifp); + error = ifhwioctl(cmd, ifp, data, td); - if (error != ENOIOCTL) { - if_rele(ifp); - CURVNET_RESTORE(); - return (error); - } + if (error != ENOIOCTL) + goto wakeup_out; oif_flags = ifp->if_flags; if (so->so_proto == NULL) { - if_rele(ifp); - CURVNET_RESTORE(); - return (EOPNOTSUPP); + error = EOPNOTSUPP; + goto wakeup_out; } #ifndef COMPAT_43 error = ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, @@ -2617,6 +2621,13 @@ } #endif } + +wakeup_out: + IF_ADDR_LOCK(ifp); + ifp->if_flags &= ~IFF_INIOCTL; + wakeup(ifp); + IF_ADDR_UNLOCK(ifp); + if_rele(ifp); CURVNET_RESTORE(); return (error);