diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2022-01-25 05:07:16 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2022-01-25 05:07:16 +0000 |
commit | 6d1808f051a5f8e3b546442b9bcab3d03f04ef8a (patch) | |
tree | e6ee945dc5c94070d16a36700af500d3de27fbb7 /sys/net/if_clone.c | |
parent | 54712fc42350acb4991d8bd8604b08562660e962 (diff) | |
download | src-6d1808f051a5f8e3b546442b9bcab3d03f04ef8a.tar.gz src-6d1808f051a5f8e3b546442b9bcab3d03f04ef8a.zip |
if_clone: correctly destroy a clone from a different vnet
Try to live with cruel reality fact - if_vmove doesn't move an
interface from previous vnet cloning infrastructure to the new
one. Let's admit this as design feature and make it work better.
* Delete two blocks of code that would fallback to vnet0, if a
cloner isn't found. They didn't do any good job and also whole
idea of treating vnet0 as special one is wrong.
* When deleting a cloned interface, lookup its cloner using it's
home vnet.
With this change simple sequence works correctly:
ifconfig foo0 create
jail -c name=jj persist vnet vnet.interface=foo0
jexec jj ifconfig foo0 destroy
Differential revision: https://reviews.freebsd.org/D33942
Diffstat (limited to 'sys/net/if_clone.c')
-rw-r--r-- | sys/net/if_clone.c | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c index 7660c91bd2e1..272a98f285d5 100644 --- a/sys/net/if_clone.c +++ b/sys/net/if_clone.c @@ -189,20 +189,6 @@ if_clone_create(char *name, size_t len, caddr_t params) if (ifc->ifc_match(ifc, name)) break; } -#ifdef VIMAGE - if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) { - CURVNET_SET_QUIET(vnet0); - LIST_FOREACH(ifc, &V_if_cloners, ifc_list) - if (ifc->ifc_type == SIMPLE) { - if (ifc_simple_match(ifc, name)) - break; - } else { - if (ifc->ifc_match(ifc, name)) - break; - } - CURVNET_RESTORE(); - } -#endif IF_CLONERS_UNLOCK(); if (ifc == NULL) @@ -266,27 +252,15 @@ if_clone_destroy(const char *name) return (ENXIO); /* Find the cloner for this interface */ + CURVNET_SET_QUIET(ifp->if_home_vnet); IF_CLONERS_LOCK(); LIST_FOREACH(ifc, &V_if_cloners, ifc_list) { if (strcmp(ifc->ifc_name, ifp->if_dname) == 0) { break; } } -#ifdef VIMAGE - if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) { - CURVNET_SET_QUIET(vnet0); - LIST_FOREACH(ifc, &V_if_cloners, ifc_list) - if (ifc->ifc_type == SIMPLE) { - if (ifc_simple_match(ifc, name)) - break; - } else { - if (ifc->ifc_match(ifc, name)) - break; - } - CURVNET_RESTORE(); - } -#endif IF_CLONERS_UNLOCK(); + CURVNET_RESTORE(); if (ifc == NULL) { if_rele(ifp); return (EINVAL); |