PERFORCE change 118611 for review
Marko Zec
zec at FreeBSD.org
Sun Apr 22 21:40:15 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=118611
Change 118611 by zec at zec_tca51 on 2007/04/22 21:39:58
Introduce the notion of home_vnet for an ifnet, indicating
the vnet instance where the ifnet was attached for the
first time.
Implement an idetach() routine for cleaning up the container
holding virtualized state from sys/net stuff.
Affected files ...
.. //depot/projects/vimage/src/sys/net/if.c#11 edit
.. //depot/projects/vimage/src/sys/net/if_var.h#8 edit
Differences ...
==== //depot/projects/vimage/src/sys/net/if.c#11 (text+ko) ====
@@ -138,6 +138,9 @@
#endif
static int vnet_net_iattach(void);
+#ifdef VIMAGE
+static int vnet_net_idetach(void);
+#endif
int ifqmaxlen = IFQ_MAXLEN;
struct mtx ifnet_lock;
@@ -176,7 +179,7 @@
.name = "net",
.symmap = vnet_net_symmap,
.i_attach = vnet_net_iattach,
- .i_detach = NULL,
+ .i_detach = vnet_net_idetach
};
MALLOC_DEFINE(M_NET, "net", "NET instance");
@@ -370,6 +373,27 @@
return 0;
}
+#ifdef VIMAGE
+static int
+vnet_net_idetach()
+{
+ INIT_VNET_NET(curvnet);
+
+ VNET_ASSERT(TAILQ_EMPTY(&V_ifnet));
+#ifdef NOTYET
+ VNET_ASSERT(TAILQ_EMPTY(&V_ifg_head));
+#endif
+ VNET_ASSERT(SLIST_EMPTY(&V_ifklist.kl_list));
+
+ free((caddr_t)V_ifindex_table, M_IFNET);
+
+ curvnet->mod_data[vnet_net_modinfo.id] = NULL;
+ free((caddr_t)vnet_net, M_NET);
+
+ return 0;
+}
+#endif
+
void
if_grow(void)
{
@@ -517,8 +541,9 @@
ifp->if_xname);
#ifdef VIMAGE
- ifp->if_vnet = vnet_net->parent_vnet;
- ifp->if_vnet->ifccnt++; /* XXX locking? */
+ ifp->if_vnet = curvnet;
+ if (ifp->if_home_vnet == NULL)
+ ifp->if_home_vnet = curvnet;
#endif
TASK_INIT(&ifp->if_starttask, 0, if_start_deferred, ifp);
TASK_INIT(&ifp->if_linktask, 0, do_link_state_change, ifp);
@@ -606,6 +631,9 @@
IFNET_WLOCK();
TAILQ_INSERT_TAIL(&V_ifnet, ifp, if_link);
+#ifdef VIMAGE
+ curvnet->ifccnt++;
+#endif
IFNET_WUNLOCK();
if (domain_init_status >= 2)
@@ -752,16 +780,14 @@
found = 1;
break;
}
+#ifdef VIMAGE
+ if (found)
+ curvnet->ifccnt--;
+#endif
IFNET_WUNLOCK();
if (!found)
return;
-#ifdef VIMAGE
- IFNET_WLOCK();
- ifp->if_vnet->ifccnt--;
- IFNET_WUNLOCK();
-#endif
-
/*
* Remove/wait for pending events.
*/
==== //depot/projects/vimage/src/sys/net/if_var.h#8 (text+ko) ====
@@ -187,7 +187,9 @@
/* protected by if_addr_mtx */
void *if_pf_kif;
void *if_lagg; /* lagg glue */
+
struct vnet *if_vnet; /* network stack instance */
+ struct vnet *if_home_vnet; /* where this ifnet originates from */
};
typedef void if_init_f_t(void *);
More information about the p4-projects
mailing list