PERFORCE change 111141 for review
Marko Zec
zec at FreeBSD.org
Tue Dec 5 04:54:31 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=111141
Change 111141 by zec at zec_tca51 on 2006/12/05 12:51:52
When destroying a vnet instance, first set the per-thread
vnet affinity to that instance.
Do not iterate through the entire list of vnets when setting /
restoring the per-thread vnet affinity. Instead, as an
alternative consistency checking measure, check that the target
vnet has its magic number field correctly set.
Affected files ...
.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/if_ether.c#3 edit
.. //depot/projects/vimage/src/sys/netinet6/nd6.c#3 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#3 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#4 (text+ko) ====
@@ -420,6 +420,7 @@
panic("vi_alloc: malloc failed for vnetb \"%s\"\n", name);
bzero(vnetb, sizeof(struct vnet_base));
vip->v_vnetb = vnetb;
+ vnetb->vnet_magic_n = VNET_MAGIC_N;
vprocg = malloc(sizeof(struct vprocg), M_VPROCG, M_NOWAIT);
if (vprocg == NULL)
@@ -491,6 +492,8 @@
struct vprocg *vprocg = vip->v_procg;
struct vcpu *vcpu = vip->v_cpu;
struct ifnet *ifp;
+
+ CURVNETB_SET(vnetb);
INIT_VNET_NET(vnetb);
/* return all interfaces to the parent vnetb */
@@ -516,8 +519,11 @@
free((caddr_t)vnetb->ifindex2ifnet, M_IFADDR);
#endif
+ CURVNETB_RESTORE();
+
/* hopefully, we are finally OK to free the vnetb container itself! */
LIST_REMOVE(vnetb, vnetb_le);
+ vnetb->vnet_magic_n = -1;
free(vnetb, M_VNET);
LIST_REMOVE(vprocg, vprocg_le);
@@ -550,6 +556,7 @@
vimage_0.v_cpu = &vcpu_0;
vnetb_tbl[0] = &vnetb_0; /* XXX */
+ vnetb_0.vnet_magic_n = VNET_MAGIC_N;
TAILQ_INIT(&vnet_modlink_head);
==== //depot/projects/vimage/src/sys/netinet/if_ether.c#3 (text+ko) ====
@@ -139,7 +139,7 @@
static void
arptimer(void *arg)
{
- CURVNETB_SET(arg);
+ CURVNETB_SET((struct vnet_base *) arg);
INIT_VNET_NET((struct vnet_base *) arg);
INIT_VNET_INET((struct vnet_base *) arg);
struct llinfo_arp *la, *ola;
==== //depot/projects/vimage/src/sys/netinet6/nd6.c#3 (text+ko) ====
@@ -1919,8 +1919,8 @@
nd6_slowtimo(arg)
void *arg;
{
- CURVNETB_SET(arg);
- INIT_VNET_NET(curvnetb);
+ CURVNETB_SET((struct vnet_base *) arg);
+ INIT_VNET_NET((struct vnet_base *) arg);
struct nd_ifinfo *nd6if;
struct ifnet *ifp;
==== //depot/projects/vimage/src/sys/sys/vimage.h#3 (text+ko) ====
@@ -82,6 +82,8 @@
int ifccnt;
int sockcnt;
+
+ int vnet_magic_n;
};
struct vnet_symmap {
@@ -116,26 +118,22 @@
#define VNET_SYMMAP_END \
{ NULL, 0 }
+#define VNET_MAGIC_N 0x3e0d8f29
+
#define CURVNETB_SET(arg) \
- struct vnet_base *vnetb_iter_XXX; \
+ VNET_ASSERT((arg)->vnet_magic_n == VNET_MAGIC_N); \
struct vnet_base *saved_vnetb = curvnetb; \
const char *saved_vnet_lpush = curthread->td_vnet_lpush; \
curvnetb = arg; \
curthread->td_vnet_lpush = __FUNCTION__ ; \
- LIST_FOREACH(vnetb_iter_XXX, &vnetb_head, vnetb_le) \
- if (arg == vnetb_iter_XXX) \
- break; \
- VNET_ASSERT(arg == vnetb_iter_XXX && arg != NULL ); \
if (saved_vnetb) \
printf("curvnetb_set() in %s cpu %d: %p (%s) -> %p\n", \
curthread->td_vnet_lpush, curcpu, saved_vnetb, \
saved_vnet_lpush, curvnetb);
#define CURVNETB_RESTORE() \
- LIST_FOREACH(vnetb_iter_XXX, &vnetb_head, vnetb_le) \
- if (saved_vnetb == vnetb_iter_XXX) \
- break; \
- VNET_ASSERT(saved_vnetb == vnetb_iter_XXX); \
+ VNET_ASSERT(saved_vnetb == NULL || \
+ saved_vnetb->vnet_magic_n == VNET_MAGIC_N); \
curvnetb = saved_vnetb; \
curthread->td_vnet_lpush = saved_vnet_lpush;
More information about the p4-projects
mailing list