diff options
author | bz <bz@FreeBSD.org> | 2009-07-26 11:29:26 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2009-07-26 11:29:26 +0000 |
commit | 3aec900b26d9617b51a15ddcb14a13ff18cd1c00 (patch) | |
tree | afa1c5ff605911c48845fd9724bbb425cee977aa /sys/kern | |
parent | 0de8238d45da1b7b3bf6f6206fbba3b8534c683a (diff) | |
download | FreeBSD-src-3aec900b26d9617b51a15ddcb14a13ff18cd1c00.zip FreeBSD-src-3aec900b26d9617b51a15ddcb14a13ff18cd1c00.tar.gz |
Make the in-kernel logic for the SIOCSIFVNET, SIOCSIFRVNET ioctls
(ifconfig ifN (-)vnet <jname|jid>) work correctly.
Move vi_if_move to if.c and split it up into two functions(*),
one for each ioctl.
In the reclaim case, correctly set the vnet before calling if_vmove.
Instead of silently allowing a move of an interface from the current
vnet to the current vnet, return an error. (*)
There is some duplicate interface name checking before actually moving
the interface between network stacks without locking and thus race
prone. Ideally if_vmove will correctly and automagically handle these
in the future.
Suggested by: rwatson (*)
Approved by: re (kib)
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_vimage.c | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/sys/kern/kern_vimage.c b/sys/kern/kern_vimage.c index fa2d1f4..9c86b75 100644 --- a/sys/kern/kern_vimage.c +++ b/sys/kern/kern_vimage.c @@ -68,61 +68,6 @@ struct sx vnet_sxlock; struct vnet_list_head vnet_head; struct vnet *vnet0; -/* - * Move an ifnet to or from another vnet, specified by the jail id. - */ -int -vi_if_move(struct thread *td, struct ifnet *ifp, char *ifname, int jid) -{ - struct ifnet *t_ifp; - struct prison *pr; - struct vnet *new_vnet; - int error; - - sx_slock(&allprison_lock); - pr = prison_find_child(td->td_ucred->cr_prison, jid); - sx_sunlock(&allprison_lock); - if (pr == NULL) - return (ENXIO); - prison_hold_locked(pr); - mtx_unlock(&pr->pr_mtx); - if (ifp != NULL) { - /* SIOCSIFVNET */ - new_vnet = pr->pr_vnet; - } else { - /* SIOCSIFRVNET */ - new_vnet = TD_TO_VNET(td); - CURVNET_SET(pr->pr_vnet); - ifp = ifunit(ifname); - CURVNET_RESTORE(); - if (ifp == NULL) { - prison_free(pr); - return (ENXIO); - } - } - - error = 0; - if (new_vnet != ifp->if_vnet) { - /* - * Check for naming clashes in target vnet. Not locked so races - * are possible. - */ - CURVNET_SET_QUIET(new_vnet); - t_ifp = ifunit(ifname); - CURVNET_RESTORE(); - if (t_ifp != NULL) - error = EEXIST; - else { - /* Detach from curvnet and attach to new_vnet. */ - if_vmove(ifp, new_vnet); - - /* Report the new if_xname back to the userland */ - sprintf(ifname, "%s", ifp->if_xname); - } - } - prison_free(pr); - return (error); -} struct vnet * vnet_alloc(void) |