PERFORCE change 111204 for review
Marko Zec
zec at FreeBSD.org
Wed Dec 6 09:42:18 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=111204
Change 111204 by zec at zec_tca51 on 2006/12/06 17:41:53
At creation time assign each vnet a unique positive integer id.
The only use for this id so far is to serve as an index into
vnetb_tbl[], which stores ptrs to all corresponding vnets.
The table indexing method of fetching the appropriate vnet * is
used only in tcp timer-triggered functions as an interim hack.
In those function it is possible for (struct tcpcb *tp)->t_inpcb
to be NULL due to some race conditions that I do not comprehend,
but which are documented and handled in the existing code. Given
that in timer-triggered functions curvnetb is always NULL, and
that we cannot reliably fetch vnet * from tp->t_inpcb->inp_vnet,
as an alternative method we fetch vnet * from
vnetb_tbl[tp->vnet_id].
NB this whole hassle of going through a table to fetch a ptr
to a vnet could be easily avoided if we stored the ptr directly
in the struct tcpcb. However, doing so would alter the size
of tcpcb and I would have to rebuild my userland as a consequence.
OTOH struct tcpcb has enough spare room for a 16-bit index...
Hope nobody is actually reading this...
Affected files ...
.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#7 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_subr.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_timer.c#4 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#6 edit
Differences ...
==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#7 (text+ko) ====
@@ -402,6 +402,7 @@
struct vprocg *vprocg;
struct vcpu *vcpu;
struct domain *dp;
+ int i;
printf("vi_alloc: %s\n", name);
/* A brute force check whether there's enough mem for a new vimage */
@@ -421,6 +422,12 @@
bzero(vnetb, sizeof(struct vnet_base));
vip->v_vnetb = vnetb;
vnetb->vnet_magic_n = VNET_MAGIC_N;
+ for (i = 0; i < 100; i++) /* XXX !!! */
+ if (vnetb_tbl[i] == NULL) {
+ vnetb->vnet_id = i;
+ vnetb_tbl[i] = vnetb;
+ break;
+ }
vprocg = malloc(sizeof(struct vprocg), M_VPROCG, M_NOWAIT);
if (vprocg == NULL)
@@ -555,7 +562,9 @@
vimage_0.v_procg = &vprocg_0;
vimage_0.v_cpu = &vcpu_0;
- vnetb_tbl[0] = &vnetb_0; /* XXX */
+ vnetb_0.vnet_id = 1; /* XXX */
+ vnetb_tbl[0] = (void *) 0xc0dedead; /* XXX */
+ vnetb_tbl[1] = &vnetb_0; /* XXX */
vnetb_0.vnet_magic_n = VNET_MAGIC_N;
TAILQ_INIT(&vnet_modlink_head);
==== //depot/projects/vimage/src/sys/netinet/tcp_subr.c#4 (text+ko) ====
@@ -684,6 +684,9 @@
if (tm == NULL)
return (NULL);
tp = &tm->tcb;
+#ifdef VIMAGE
+ tp->vnet_id = inp->inp_vnetb->vnet_id;
+#endif
/* LIST_INIT(&tp->t_segq); */ /* XXX covered by M_ZERO */
tp->t_maxseg = tp->t_maxopd =
#ifdef INET6
==== //depot/projects/vimage/src/sys/netinet/tcp_timer.c#4 (text+ko) ====
==== //depot/projects/vimage/src/sys/sys/vimage.h#6 (text+ko) ====
@@ -83,6 +83,8 @@
int ifccnt;
int sockcnt;
+ int vnet_id; /* index to vnetb_tbl */
+
int vnet_magic_n;
};
More information about the p4-projects
mailing list