Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if.c
Show First 20 Lines • Show All 1,074 Lines • ▼ Show 20 Lines | 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 | ||||
bool shutdown; | bool shutdown; | ||||
shutdown = ifp->if_vnet->vnet_shutdown; | shutdown = (ifp->if_vnet->vnet_shutdown && | ||||
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? true : false; | |||||
hselasky: I think ? true : false is not needed. | |||||
bzAuthorUnsubmitted Done Inline ActionsYes, it is not necessary but it also doesn't hurt. The result of a && operation is an int. It's just explicit boolean rather than implicit cast. bz: Yes, it is not necessary but it also doesn't hurt. The result of a && operation is an int. | |||||
Done Inline ActionsAs this check is used 3? times: can it be a vnet macro like VNET_IS_SHUTDOWN(_vnet)? melifaro: As this check is used 3? times: can it be a vnet macro like `VNET_IS_SHUTDOWN(_vnet)`? | |||||
#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 240 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; | ||||
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. */ | ||||
if (ifp->if_vnet->vnet_shutdown) { | shutdown = (ifp->if_vnet->vnet_shutdown && | ||||
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? true : false; | |||||
if (shutdown) { | |||||
hselaskyUnsubmitted Done Inline ActionsDitto. hselasky: Ditto. | |||||
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; | ||||
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. */ | ||||
if (ifp->if_vnet->vnet_shutdown) { | shutdown = (ifp->if_vnet->vnet_shutdown && | ||||
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? true : false; | |||||
if (shutdown) { | |||||
hselaskyUnsubmitted Done Inline ActionsDitto. hselasky: Ditto. | |||||
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); | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
▲ Show 20 Lines • Show All 1,510 Lines • ▼ Show 20 Lines | #ifdef COMPAT_FREEBSD32 | ||||
caddr_t saved_data = NULL; | caddr_t saved_data = NULL; | ||||
struct ifmediareq ifmr; | struct ifmediareq ifmr; | ||||
struct ifmediareq *ifmrp = NULL; | struct ifmediareq *ifmrp = NULL; | ||||
#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 | |||||
bool shutdown; | |||||
#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. */ | ||||
if (so->so_vnet->vnet_shutdown) { | shutdown = (so->so_vnet->vnet_shutdown && | ||||
so->so_vnet->vnet_state < SI_SUB_VNET_DONE) ? true : false; | |||||
if (shutdown) { | |||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
return (EBUSY); | return (EBUSY); | ||||
} | } | ||||
#endif | #endif | ||||
switch (cmd) { | switch (cmd) { | ||||
case SIOCGIFCONF: | case SIOCGIFCONF: | ||||
error = ifconf(cmd, data); | error = ifconf(cmd, data); | ||||
▲ Show 20 Lines • Show All 1,596 Lines • Show Last 20 Lines |
I think ? true : false is not needed.