Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_tuntap.c
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | |||||
#define TUN_UNUSED2 0x0010 | #define TUN_UNUSED2 0x0010 | ||||
#define TUN_LMODE 0x0020 | #define TUN_LMODE 0x0020 | ||||
#define TUN_RWAIT 0x0040 | #define TUN_RWAIT 0x0040 | ||||
#define TUN_ASYNC 0x0080 | #define TUN_ASYNC 0x0080 | ||||
#define TUN_IFHEAD 0x0100 | #define TUN_IFHEAD 0x0100 | ||||
#define TUN_DYING 0x0200 | #define TUN_DYING 0x0200 | ||||
#define TUN_L2 0x0400 | #define TUN_L2 0x0400 | ||||
#define TUN_VMNET 0x0800 | #define TUN_VMNET 0x0800 | ||||
#define TUN_TRANSIENT 0x1000 | |||||
#define TUN_DRIVER_IDENT_MASK (TUN_L2 | TUN_VMNET) | #define TUN_DRIVER_IDENT_MASK (TUN_L2 | TUN_VMNET) | ||||
#define TUN_READY (TUN_OPEN | TUN_INITED) | #define TUN_READY (TUN_OPEN | TUN_INITED) | ||||
pid_t tun_pid; /* owning pid */ | pid_t tun_pid; /* owning pid */ | ||||
struct ifnet *tun_ifp; /* the interface */ | struct ifnet *tun_ifp; /* the interface */ | ||||
struct sigio *tun_sigio; /* async I/O info */ | struct sigio *tun_sigio; /* async I/O info */ | ||||
struct tuntap_driver *tun_drv; /* appropriate driver */ | struct tuntap_driver *tun_drv; /* appropriate driver */ | ||||
▲ Show 20 Lines • Show All 1,076 Lines • ▼ Show 20 Lines | out: | ||||
selwakeuppri(&tp->tun_rsel, PZERO + 1); | selwakeuppri(&tp->tun_rsel, PZERO + 1); | ||||
KNOTE_LOCKED(&tp->tun_rsel.si_note, 0); | KNOTE_LOCKED(&tp->tun_rsel.si_note, 0); | ||||
TUNDEBUG (ifp, "closed\n"); | TUNDEBUG (ifp, "closed\n"); | ||||
tp->tun_flags &= ~TUN_OPEN; | tp->tun_flags &= ~TUN_OPEN; | ||||
tp->tun_pid = 0; | tp->tun_pid = 0; | ||||
tun_vnethdr_set(ifp, 0); | tun_vnethdr_set(ifp, 0); | ||||
tun_unbusy_locked(tp); | tun_unbusy_locked(tp); | ||||
if ((tp->tun_flags & TUN_TRANSIENT) != 0) { | |||||
int error __diagused; | |||||
/* Mark it busy so that nothing can re-open it. */ | |||||
tp->tun_flags |= TUN_DYING; | |||||
TUN_UNLOCK(tp); | TUN_UNLOCK(tp); | ||||
error = if_clone_destroyif(NULL, ifp); | |||||
zlei: What about making `ifc_find_cloner_in_vnet()` public and using it here ?
So we do not need… | |||||
glebiusUnsubmitted Not Done Inline ActionsWe have the knowledge about the cloner inside the tuntap driver. You don't need to hack if_clone.c to achieve what you want. Let me come with a prototype quickly... glebius: We have the knowledge about the cloner inside the tuntap driver. You don't need to hack… | |||||
kevansAuthorUnsubmitted Done Inline ActionsRight, I had a version that looked up the cloner, but it was a little gross because you also need to switch back to the home vnet and grab the cloner from that particular vnet, effectively duplicating what's already done in if_clone.c. kevans: Right, I had a version that looked up the cloner, but it was a little gross because you also… | |||||
MPASS(error == 0); | |||||
return; | |||||
} | } | ||||
TUN_UNLOCK(tp); | |||||
} | |||||
static void | static void | ||||
tuninit(struct ifnet *ifp) | tuninit(struct ifnet *ifp) | ||||
{ | { | ||||
struct tuntap_softc *tp = ifp->if_softc; | struct tuntap_softc *tp = ifp->if_softc; | ||||
TUNDEBUG(ifp, "tuninit\n"); | TUNDEBUG(ifp, "tuninit\n"); | ||||
TUN_LOCK(tp); | TUN_LOCK(tp); | ||||
▲ Show 20 Lines • Show All 431 Lines • ▼ Show 20 Lines | case TUNGIFINFO: | ||||
tunp->baudrate = TUN2IFP(tp)->if_baudrate; | tunp->baudrate = TUN2IFP(tp)->if_baudrate; | ||||
TUN_UNLOCK(tp); | TUN_UNLOCK(tp); | ||||
break; | break; | ||||
case TUNSDEBUG: | case TUNSDEBUG: | ||||
tundebug = *(int *)data; | tundebug = *(int *)data; | ||||
break; | break; | ||||
case TUNGDEBUG: | case TUNGDEBUG: | ||||
*(int *)data = tundebug; | *(int *)data = tundebug; | ||||
break; | |||||
case TUNSTRANSIENT: | |||||
TUN_LOCK(tp); | |||||
if (*(int *)data) | |||||
tp->tun_flags |= TUN_TRANSIENT; | |||||
else | |||||
tp->tun_flags &= ~TUN_TRANSIENT; | |||||
TUN_UNLOCK(tp); | |||||
break; | |||||
case TUNGTRANSIENT: | |||||
TUN_LOCK(tp); | |||||
*(int *)data = (tp->tun_flags & TUN_TRANSIENT) != 0; | |||||
TUN_UNLOCK(tp); | |||||
break; | break; | ||||
case FIONBIO: | case FIONBIO: | ||||
break; | break; | ||||
case FIOASYNC: | case FIOASYNC: | ||||
TUN_LOCK(tp); | TUN_LOCK(tp); | ||||
if (*(int *)data) | if (*(int *)data) | ||||
tp->tun_flags |= TUN_ASYNC; | tp->tun_flags |= TUN_ASYNC; | ||||
else | else | ||||
▲ Show 20 Lines • Show All 411 Lines • Show Last 20 Lines |
What about making ifc_find_cloner_in_vnet() public and using it here ?
So we do not need complex logic in if_clone_destroyif_flags() .