Skip to content

Commit 39a3fe0

Browse files
vale: fix logic that allows destructions of persistent vale ports
1 parent 9364f59 commit 39a3fe0

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

sys/dev/netmap/netmap_vale.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ static int
553553
nm_vi_destroy(const char *name)
554554
{
555555
struct ifnet *ifp;
556+
struct netmap_vp_adapter *vpna;
556557
int error;
557558

558559
ifp = ifunit_ref(name);
@@ -565,11 +566,21 @@ nm_vi_destroy(const char *name)
565566
goto err;
566567
}
567568

568-
D("refcount %d", NA(ifp)->na_refcount);
569-
if (NA(ifp)->na_refcount > 1) {
569+
vpna = (struct netmap_vp_adapter *)NA(ifp);
570+
571+
/* we can only destroy ports that were created via NETMAP_BDG_NEWIF */
572+
if (vpna->autodelete) {
573+
error = EINVAL;
574+
goto err;
575+
}
576+
577+
/* also make sure that nobody is using the inferface */
578+
if (NETMAP_OWNED_BY_ANY(&vpna->up) ||
579+
vpna->up.na_refcount > 1 /* any ref besides the one in nm_vi_create()? */) {
570580
error = EBUSY;
571581
goto err;
572582
}
583+
573584
NMG_UNLOCK();
574585

575586
D("destroying a persistent vale interface %s", ifp->if_xname);

0 commit comments

Comments
 (0)