File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -553,6 +553,7 @@ static int
553553nm_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 );
You can’t perform that action at this time.
0 commit comments