Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if.c
Show First 20 Lines • Show All 1,084 Lines • ▼ Show 20 Lines | |||||
if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp) | if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp) | ||||
{ | { | ||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
int i; | int i; | ||||
struct domain *dp; | struct domain *dp; | ||||
struct ifnet *iter; | struct ifnet *iter; | ||||
int found = 0; | int found = 0; | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
int shutdown; | bool shutdown; | ||||
shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && | shutdown = !vnet_is_running(ifp->if_vnet); | ||||
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; | |||||
#endif | #endif | ||||
IFNET_WLOCK(); | IFNET_WLOCK(); | ||||
CK_STAILQ_FOREACH(iter, &V_ifnet, if_link) | CK_STAILQ_FOREACH(iter, &V_ifnet, if_link) | ||||
if (iter == ifp) { | if (iter == ifp) { | ||||
CK_STAILQ_REMOVE(&V_ifnet, ifp, ifnet, if_link); | CK_STAILQ_REMOVE(&V_ifnet, ifp, ifnet, if_link); | ||||
if (!vmove) | if (!vmove) | ||||
ifp->if_flags |= IFF_DYING; | ifp->if_flags |= IFF_DYING; | ||||
found = 1; | found = 1; | ||||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Move an ifnet to or from another child prison/vnet, specified by the jail id. | * Move an ifnet to or from another child prison/vnet, specified by the jail id. | ||||
*/ | */ | ||||
static int | static int | ||||
if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) | if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) | ||||
{ | { | ||||
struct prison *pr; | struct prison *pr; | ||||
struct ifnet *difp; | struct ifnet *difp; | ||||
int shutdown; | bool shutdown; | ||||
/* Try to find the prison within our visibility. */ | /* Try to find the prison within our visibility. */ | ||||
sx_slock(&allprison_lock); | sx_slock(&allprison_lock); | ||||
pr = prison_find_child(td->td_ucred->cr_prison, jid); | pr = prison_find_child(td->td_ucred->cr_prison, jid); | ||||
sx_sunlock(&allprison_lock); | sx_sunlock(&allprison_lock); | ||||
if (pr == NULL) | if (pr == NULL) | ||||
return (ENXIO); | return (ENXIO); | ||||
prison_hold_locked(pr); | prison_hold_locked(pr); | ||||
Show All 11 Lines | if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) | ||||
difp = ifunit(ifname); | difp = ifunit(ifname); | ||||
if (difp != NULL) { | if (difp != NULL) { | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
prison_free(pr); | prison_free(pr); | ||||
return (EEXIST); | return (EEXIST); | ||||
} | } | ||||
/* Make sure the VNET is stable. */ | /* Make sure the VNET is stable. */ | ||||
shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && | shutdown = !vnet_is_running(ifp->if_vnet); | ||||
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; | |||||
if (shutdown) { | if (shutdown) { | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
prison_free(pr); | prison_free(pr); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
/* Move the interface into the child jail/vnet. */ | /* Move the interface into the child jail/vnet. */ | ||||
if_vmove(ifp, pr->pr_vnet); | if_vmove(ifp, pr->pr_vnet); | ||||
/* Report the new if_xname back to the userland. */ | /* Report the new if_xname back to the userland. */ | ||||
sprintf(ifname, "%s", ifp->if_xname); | sprintf(ifname, "%s", ifp->if_xname); | ||||
prison_free(pr); | prison_free(pr); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
if_vmove_reclaim(struct thread *td, char *ifname, int jid) | if_vmove_reclaim(struct thread *td, char *ifname, int jid) | ||||
{ | { | ||||
struct prison *pr; | struct prison *pr; | ||||
struct vnet *vnet_dst; | struct vnet *vnet_dst; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
int shutdown; | bool shutdown; | ||||
/* Try to find the prison within our visibility. */ | /* Try to find the prison within our visibility. */ | ||||
sx_slock(&allprison_lock); | sx_slock(&allprison_lock); | ||||
pr = prison_find_child(td->td_ucred->cr_prison, jid); | pr = prison_find_child(td->td_ucred->cr_prison, jid); | ||||
sx_sunlock(&allprison_lock); | sx_sunlock(&allprison_lock); | ||||
if (pr == NULL) | if (pr == NULL) | ||||
return (ENXIO); | return (ENXIO); | ||||
prison_hold_locked(pr); | prison_hold_locked(pr); | ||||
Show All 12 Lines | if_vmove_reclaim(struct thread *td, char *ifname, int jid) | ||||
vnet_dst = TD_TO_VNET(td); | vnet_dst = TD_TO_VNET(td); | ||||
if (vnet_dst == ifp->if_vnet) { | if (vnet_dst == ifp->if_vnet) { | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
prison_free(pr); | prison_free(pr); | ||||
return (EEXIST); | return (EEXIST); | ||||
} | } | ||||
/* Make sure the VNET is stable. */ | /* Make sure the VNET is stable. */ | ||||
shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET && | shutdown = !vnet_is_running(ifp->if_vnet); | ||||
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; | |||||
if (shutdown) { | if (shutdown) { | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
prison_free(pr); | prison_free(pr); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
/* Get interface back from child jail/vnet. */ | /* Get interface back from child jail/vnet. */ | ||||
if_vmove(ifp, vnet_dst); | if_vmove(ifp, vnet_dst); | ||||
▲ Show 20 Lines • Show All 1,575 Lines • ▼ Show 20 Lines | #ifdef COMPAT_FREEBSD32 | ||||
struct ifmediareq ifmr; | struct ifmediareq ifmr; | ||||
struct ifmediareq *ifmrp; | struct ifmediareq *ifmrp; | ||||
#endif | #endif | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct ifreq *ifr; | struct ifreq *ifr; | ||||
int error; | int error; | ||||
int oif_flags; | int oif_flags; | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
int shutdown; | bool shutdown; | ||||
#endif | #endif | ||||
CURVNET_SET(so->so_vnet); | CURVNET_SET(so->so_vnet); | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
/* Make sure the VNET is stable. */ | /* Make sure the VNET is stable. */ | ||||
shutdown = (so->so_vnet->vnet_state > SI_SUB_VNET && | shutdown = !vnet_is_running(so->so_vnet); | ||||
so->so_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0; | |||||
if (shutdown) { | if (shutdown) { | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
#endif | #endif | ||||
switch (cmd) { | switch (cmd) { | ||||
▲ Show 20 Lines • Show All 1,595 Lines • Show Last 20 Lines |