Author: bz
Date: Wed May 18 20:06:45 2016
New Revision: 300164
URL: https://svnweb.freebsd.org/changeset/base/300164

Log:
  Rather than having the if_vmove() code intermixed in the vnet_destroy()
  function in vnet.c move it to if.c where it logically belongs and put
  it under a VNET_SYSUNINIT() call.
  To not change the current behaviour make sure it runs first thing
  during teardown. In the future this will allow us more flexibility
  on changing the order on when we want to get rid of interfaces.
  
  Stop exporting if_vmove() and make it file static.
  
  Reviewed by:          gnn
  Sponsored by:         The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D6438

Modified:
  head/sys/net/if.c
  head/sys/net/if_var.h
  head/sys/net/vnet.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c   Wed May 18 19:59:05 2016        (r300163)
+++ head/sys/net/if.c   Wed May 18 20:06:45 2016        (r300164)
@@ -182,6 +182,9 @@ static int  if_getgroupmembers(struct ifg
 static void    if_delgroups(struct ifnet *);
 static void    if_attach_internal(struct ifnet *, int, struct if_clone *);
 static int     if_detach_internal(struct ifnet *, int, struct if_clone **);
+#ifdef VIMAGE
+static void    if_vmove(struct ifnet *, struct vnet *);
+#endif
 
 #ifdef INET6
 /*
@@ -392,6 +395,20 @@ vnet_if_uninit(const void *unused __unus
 }
 VNET_SYSUNINIT(vnet_if_uninit, SI_SUB_INIT_IF, SI_ORDER_FIRST,
     vnet_if_uninit, NULL);
+
+static void
+vnet_if_return(const void *unused __unused)
+{
+       struct ifnet *ifp, *nifp;
+
+       /* Return all inherited interfaces to their parent vnets. */
+       TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
+               if (ifp->if_home_vnet != ifp->if_vnet)
+                       if_vmove(ifp, ifp->if_home_vnet);
+       }
+}
+VNET_SYSUNINIT(vnet_if_return, SI_SUB_VNET_DONE, SI_ORDER_ANY,
+    vnet_if_return, NULL);
 #endif
 
 static void

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h       Wed May 18 19:59:05 2016        (r300163)
+++ head/sys/net/if_var.h       Wed May 18 20:06:45 2016        (r300164)
@@ -535,7 +535,6 @@ void        if_dead(struct ifnet *);
 int    if_delmulti(struct ifnet *, struct sockaddr *);
 void   if_delmulti_ifma(struct ifmultiaddr *);
 void   if_detach(struct ifnet *);
-void   if_vmove(struct ifnet *, struct vnet *);
 void   if_purgeaddrs(struct ifnet *);
 void   if_delallmulti(struct ifnet *);
 void   if_down(struct ifnet *);

Modified: head/sys/net/vnet.c
==============================================================================
--- head/sys/net/vnet.c Wed May 18 19:59:05 2016        (r300163)
+++ head/sys/net/vnet.c Wed May 18 20:06:45 2016        (r300164)
@@ -269,7 +269,6 @@ vnet_alloc(void)
 void
 vnet_destroy(struct vnet *vnet)
 {
-       struct ifnet *ifp, *nifp;
 
        SDT_PROBE2(vnet, functions, vnet_destroy, entry, __LINE__, vnet);
        KASSERT(vnet->vnet_sockcnt == 0,
@@ -280,13 +279,6 @@ vnet_destroy(struct vnet *vnet)
        VNET_LIST_WUNLOCK();
 
        CURVNET_SET_QUIET(vnet);
-
-       /* Return all inherited interfaces to their parent vnets. */
-       TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
-               if (ifp->if_home_vnet != ifp->if_vnet)
-                       if_vmove(ifp, ifp->if_home_vnet);
-       }
-
        vnet_sysuninit();
        CURVNET_RESTORE();
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to