PERFORCE change 118634 for review
Marko Zec
zec at FreeBSD.org
Mon Apr 23 05:15:02 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=118634
Change 118634 by zec at zec_tca51 on 2007/04/23 05:14:25
If lo0 is gone, don't queue any routing messages, since those
must have m_pkthdr.rcvif set to loif.
Affected files ...
.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#17 edit
.. //depot/projects/vimage/src/sys/net/rtsock.c#8 edit
.. //depot/projects/vimage/src/sys/netinet6/in6_rmx.c#6 edit
.. //depot/projects/vimage/src/sys/sys/protosw.h#2 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#17 (text+ko) ====
@@ -54,6 +54,7 @@
#include <net/bpf.h>
#include <net/if_types.h>
#include <net/if_dl.h>
+#include <net/if_clone.h>
#include <net/ethernet.h>
MALLOC_DEFINE(M_VIMAGE, "vimage", "virtual image resource container");
@@ -99,6 +100,8 @@
if (modinfo->i_attach) {
VNET_ITERLOOP_BEGIN_QUIET();
+printf("Calling i_attach() for %s vnet %s\n",
+ modinfo->name, vnet_name(curvnet));
modinfo->i_attach();
VNET_ITERLOOP_END();
}
@@ -394,6 +397,7 @@
struct vprocg *vprocg;
struct vcpu *vcpu;
struct domain *dp;
+ struct vnet_modlink *modlnk_i;
/*
* XXX don't forget the locking
@@ -435,19 +439,19 @@
CURVNET_SET_QUIET(vnet);
/*
- * Initialize modules with ORDER_1ST flag set
+ * Attach modules with ORDER_1ST flag set
*/
- struct vnet_modlink *modlnk_i;
TAILQ_FOREACH(modlnk_i, &vnet_modlink_head, mod_le)
if (modlnk_i->modinfo->i_attach != NULL &&
modlnk_i->modinfo->flags & VNET_MFLAG_ORDER_1ST) {
VNET_ASSERT(!(modlnk_i->modinfo->flags & \
VNET_MFLAG_ORDER_2ND));
+printf("Calling i_attach() for %s\n", modlnk_i->modinfo->name);
modlnk_i->modinfo->i_attach();
}
/*
- * Initialize domains.
+ * Attach protocol domains.
*/
for (dp = domains; dp; dp = dp->dom_next) {
struct protosw *pr;
@@ -463,13 +467,14 @@
}
/*
- * Initialize modules with ORDER_2ND flag set
+ * Attach modules with ORDER_2ND flag set
*/
TAILQ_FOREACH(modlnk_i, &vnet_modlink_head, mod_le)
if (modlnk_i->modinfo->i_attach != NULL &&
modlnk_i->modinfo->flags & VNET_MFLAG_ORDER_2ND) {
VNET_ASSERT(!(modlnk_i->modinfo->flags & \
VNET_MFLAG_ORDER_1ST));
+printf("Calling i_attach() for %s\n", modlnk_i->modinfo->name);
modlnk_i->modinfo->i_attach();
}
@@ -496,30 +501,69 @@
struct vnet *vnet = vip->v_vnet;
struct vprocg *vprocg = vip->v_procg;
struct vcpu *vcpu = vip->v_cpu;
- struct ifnet *ifp;
+ struct ifnet *ifp, *nifp;
+ struct vnet_modlink *modlnk_i;
+#if 0
+ struct domain *dp;
+#endif
CURVNET_SET_QUIET(vnet);
INIT_VNET_NET(vnet);
- /* return all interfaces to the parent vnet */
- while ((ifp = TAILQ_FIRST(&V_ifnet)) != NULL) {
- if (ifp->if_flags & IFF_LOOPBACK) {
- bpfdetach(ifp);
- if_detach(ifp);
- } else
+ /* Return all inherited interfaces to their parent vnets */
+ /*for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = next) {*/
+ TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp)
+ if (ifp->if_home_vnet != ifp->if_vnet)
vi_if_move(NULL, ifp, vip);
- }
+
+ /*
+ * XXX TODO: kill all cloning ifnets
+ * XXX TODO: kill all netgraph ifnets
+ * XXX TODO: at this point only lo0 should be attached!!!
+ */
+TAILQ_FOREACH(ifp, &V_ifnet, if_link)
+ printf("attached ifnet: %s\n", ifp->if_xname);
+
+ /*
+ * Detach modules with ORDER_2ND flag set
+ */
+ TAILQ_FOREACH_REVERSE(modlnk_i, &vnet_modlink_head, vnet_modlink_head, mod_le)
+ if (modlnk_i->modinfo->i_detach != NULL &&
+ modlnk_i->modinfo->flags & VNET_MFLAG_ORDER_2ND) {
+ VNET_ASSERT(!(modlnk_i->modinfo->flags & \
+ VNET_MFLAG_ORDER_1ST));
+printf("Calling i_detach() for %s\n", modlnk_i->modinfo->name);
+ modlnk_i->modinfo->i_detach();
+ }
+
+TAILQ_FOREACH(ifp, &V_ifnet, if_link)
+ printf("attached ifnet: %s\n", ifp->if_xname);
#if 0
/*
- * Call all domain destroy routines - those basically have to free
- * the allocated memory and stop all the pending timers.
+ * Detach protocol domains
*/
- for (dp = domains; dp; dp = dp->dom_next)
+ for (dp = domains; dp; dp = dp->dom_next) {
+ struct protosw *pr;
for (pr = dp->dom_protoswNPROTOSW; pr > dp->dom_protosw;)
if ((--pr)->pr_destroy)
- (*pr->pr_destroy)(vnet);
+ (*pr->pr_destroy)();
+ }
+#endif
+
+ /*
+ * Detach modules with ORDER_1ST flag set
+ */
+ TAILQ_FOREACH_REVERSE(modlnk_i, &vnet_modlink_head, vnet_modlink_head, mod_le)
+ if (modlnk_i->modinfo->i_detach != NULL &&
+ modlnk_i->modinfo->flags & VNET_MFLAG_ORDER_1ST) {
+ VNET_ASSERT(!(modlnk_i->modinfo->flags & \
+ VNET_MFLAG_ORDER_2ND));
+printf("Calling i_detach() for %s\n", modlnk_i->modinfo->name);
+ modlnk_i->modinfo->i_detach();
+ }
+#if 0
free((caddr_t)vnet->ifnet_addrs, M_IFADDR);
free((caddr_t)vnet->ifindex2ifnet, M_IFADDR);
#endif
==== //depot/projects/vimage/src/sys/net/rtsock.c#8 (text+ko) ====
@@ -1059,6 +1059,7 @@
static void
rt_dispatch(struct mbuf *m, const struct sockaddr *sa)
{
+ INIT_VNET_NET(curvnet);
struct m_tag *tag;
/*
@@ -1077,8 +1078,12 @@
m_tag_prepend(m, tag);
}
#ifdef VIMAGE
- INIT_VNET_NET(curvnet);
- m->m_pkthdr.rcvif = V_loif;
+ if (V_loif)
+ m->m_pkthdr.rcvif = V_loif;
+ else {
+ m_freem(m);
+ return;
+ }
#endif
netisr_queue(NETISR_ROUTE, m); /* mbuf is free'd on failure. */
}
==== //depot/projects/vimage/src/sys/netinet6/in6_rmx.c#6 (text+ko) ====
@@ -336,11 +336,7 @@
CURVNET_SET_QUIET((struct vnet *) rock);
INIT_VNET_NET((struct vnet *) rock);
INIT_VNET_INET6((struct vnet *) rock);
-#ifdef VIMAGE
struct radix_node_head *rnh = V_rt_tables[AF_INET6];
-#else
- struct radix_node_head *rnh = rock;
-#endif
struct rtqk_arg arg;
struct timeval atv;
static time_t last_adjusted_timeout = 0;
@@ -428,11 +424,7 @@
CURVNET_SET_QUIET((struct vnet *) rock);
INIT_VNET_NET((struct vnet *) rock);
INIT_VNET_INET6((struct vnet *) rock);
-#ifdef VIMAGE
struct radix_node_head *rnh = V_rt_tables[AF_INET6];
-#else
- struct radix_node_head *rnh = rock;
-#endif
struct mtuex_arg arg;
struct timeval atv;
@@ -495,12 +487,7 @@
rnh->rnh_close = in6_clsroute;
callout_init(&V_rtq_timer6, CALLOUT_MPSAFE);
callout_init(&V_rtq_mtutimer, CALLOUT_MPSAFE);
-#ifdef VIMAGE
in6_rtqtimo(curvnet); /* kick off timeout first time */
in6_mtutimo(curvnet); /* kick off timeout first time */
-#else
- in6_rtqtimo(rnh); /* kick off timeout first time */
- in6_mtutimo(rnh); /* kick off timeout first time */
-#endif
return 1;
}
==== //depot/projects/vimage/src/sys/sys/protosw.h#2 (text+ko) ====
@@ -72,6 +72,7 @@
typedef void pr_ctlinput_t (int, struct sockaddr *, void *);
typedef int pr_ctloutput_t (struct socket *, struct sockopt *);
typedef void pr_init_t (void);
+typedef void pr_destroy_t (void);
typedef void pr_fasttimo_t (void);
typedef void pr_slowtimo_t (void);
typedef void pr_drain_t (void);
More information about the p4-projects
mailing list