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
This commit is contained in:
Gleb Smirnoff 2022-01-24 21:07:16 -08:00
parent 54712fc423
commit 6d1808f051

View File

@ -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);