From owner-p4-projects@FreeBSD.ORG Wed Dec 6 17:42:18 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EE96316A416; Wed, 6 Dec 2006 17:42:17 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 80C2016A492 for ; Wed, 6 Dec 2006 17:42:17 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48BA343CA2 for ; Wed, 6 Dec 2006 17:41:29 +0000 (GMT) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kB6HgFsq053794 for ; Wed, 6 Dec 2006 17:42:15 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kB6HgFMD053788 for perforce@freebsd.org; Wed, 6 Dec 2006 17:42:15 GMT (envelope-from zec@FreeBSD.org) Date: Wed, 6 Dec 2006 17:42:15 GMT Message-Id: <200612061742.kB6HgFMD053788@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 111204 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Dec 2006 17:42:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=111204 Change 111204 by zec@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; };