Date: Wed, 24 Jan 2007 21:04:52 GMT From: Marko Zec <zec@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 113483 for review Message-ID: <200701242104.l0OL4qYZ000586@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=113483 Change 113483 by zec@zec_tca51 on 2007/01/24 21:04:11 Rearrange the location of the "snd_limited" field in struct tcpcb so that enough room can be create to accomodate a pointer to struct vnet without introducing any churn to other field's position nor the size of struct tcpcb. This allows vnet_tbl[] to be nuked... Don't link a newly created vnet to a list of all vnets before it has been completely initialized. Affected files ... .. //depot/projects/vimage/src/sys/kern/kern_vimage.c#13 edit .. //depot/projects/vimage/src/sys/netinet/tcp_subr.c#8 edit .. //depot/projects/vimage/src/sys/netinet/tcp_timer.c#6 edit .. //depot/projects/vimage/src/sys/netinet/tcp_var.h#3 edit .. //depot/projects/vimage/src/sys/sys/vimage.h#12 edit Differences ... ==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#13 (text+ko) ==== @@ -68,8 +68,6 @@ struct vcpu vcpu_0; struct vnet_base vnetb_0; -struct vnet_base *vnetb_tbl[100]; /* XXX used in struct tcb */ - struct vimage_list_head vimage_head; struct vnetb_list_head vnetb_head; struct vprocg_list_head vprocg_head; @@ -394,13 +392,16 @@ struct vprocg *vprocg; struct vcpu *vcpu; struct domain *dp; - int i; + + /* + * XXX don't forget the locking + */ printf("vi_alloc: %s\n", name); /* A brute force check whether there's enough mem for a new vimage */ vip = malloc(127*1024, M_VIMAGE, M_NOWAIT); /* XXX aaaargh... */ if (vip == NULL) - return NULL; + goto vi_alloc_done; vip = realloc(vip, sizeof(struct vimage), M_VIMAGE, M_NOWAIT); if (vip == NULL) @@ -414,12 +415,6 @@ 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) @@ -436,14 +431,6 @@ /* Some initialization stuff... */ sprintf(vip->vi_name, "%s", name); - /* - * XXX don't forget locking -> - * is it really needed given that the timers are giant-protected? - */ - LIST_INSERT_HEAD(&vimage_head, vip, vi_le); - LIST_INSERT_HEAD(&vnetb_head, vnetb, vnetb_le); - LIST_INSERT_HEAD(&vprocg_head, vprocg, vprocg_le); - LIST_INSERT_HEAD(&vcpu_head, vcpu, vcpu_le); CURVNETB_SET_QUIET(vnetb); /* @@ -487,8 +474,14 @@ } CURVNETB_RESTORE(); + + LIST_INSERT_HEAD(&vimage_head, vip, vi_le); + LIST_INSERT_HEAD(&vnetb_head, vnetb, vnetb_le); + LIST_INSERT_HEAD(&vprocg_head, vprocg, vprocg_le); + LIST_INSERT_HEAD(&vcpu_head, vcpu, vcpu_le); printf("done.\n"); +vi_alloc_done: return (vip); } @@ -568,9 +561,6 @@ vimage_0.v_procg = &vprocg_0; vimage_0.v_cpu = &vcpu_0; - 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#8 (text+ko) ==== @@ -189,16 +189,17 @@ static int tcptw_auto_size(void) { + INIT_VNET_INET(curvnetb); int halfrange; /* * Max out at half the ephemeral port range so that TIME_WAIT * sockets don't tie up too many ephemeral ports. */ - if (ipport_lastauto > ipport_firstauto) - halfrange = (ipport_lastauto - ipport_firstauto) / 2; + if (V_ipport_lastauto > V_ipport_firstauto) + halfrange = (V_ipport_lastauto - V_ipport_firstauto) / 2; else - halfrange = (ipport_firstauto - ipport_lastauto) / 2; + halfrange = (V_ipport_firstauto - V_ipport_lastauto) / 2; /* Protect against goofy port ranges smaller than 32. */ return (imin(imax(halfrange, 32), maxsockets / 5)); } @@ -686,7 +687,7 @@ return (NULL); tp = &tm->tcb; #ifdef VIMAGE - tp->vnet_id = inp->inp_vnetb->vnet_id; + tp->t_vnetb = inp->inp_vnetb; #endif /* LIST_INIT(&tp->t_segq); */ /* XXX covered by M_ZERO */ tp->t_maxseg = tp->t_maxopd = ==== //depot/projects/vimage/src/sys/netinet/tcp_timer.c#6 (text+ko) ==== @@ -145,8 +145,8 @@ { struct tcpcb *tp = xtp; struct inpcb *inp; - CURVNETB_SET(vnetb_tbl[tp->vnet_id]); - INIT_VNET_INET(vnetb_tbl[tp->vnet_id]); + CURVNETB_SET(tp->t_vnetb); + INIT_VNET_INET(tp->t_vnetb); INP_INFO_RLOCK(&V_tcbinfo); inp = tp->t_inpcb; @@ -187,8 +187,8 @@ { struct tcpcb *tp = xtp; struct inpcb *inp; - CURVNETB_SET(vnetb_tbl[tp->vnet_id]); - INIT_VNET_INET(vnetb_tbl[tp->vnet_id]); + CURVNETB_SET(tp->t_vnetb); + INIT_VNET_INET(tp->t_vnetb); #ifdef TCPDEBUG int ostate; @@ -313,8 +313,8 @@ struct tcpcb *tp = xtp; struct tcptemp *t_template; struct inpcb *inp; - CURVNETB_SET(vnetb_tbl[tp->vnet_id]); - INIT_VNET_INET(vnetb_tbl[tp->vnet_id]); + CURVNETB_SET(tp->t_vnetb); + INIT_VNET_INET(tp->t_vnetb); #ifdef TCPDEBUG int ostate; @@ -411,8 +411,8 @@ { struct tcpcb *tp = xtp; struct inpcb *inp; - CURVNETB_SET(vnetb_tbl[tp->vnet_id]); - INIT_VNET_INET(vnetb_tbl[tp->vnet_id]); + CURVNETB_SET(tp->t_vnetb); + INIT_VNET_INET(tp->t_vnetb); #ifdef TCPDEBUG int ostate; @@ -486,8 +486,8 @@ int rexmt; int headlocked; struct inpcb *inp; - CURVNETB_SET(vnetb_tbl[tp->vnet_id]); - INIT_VNET_INET(vnetb_tbl[tp->vnet_id]); + CURVNETB_SET(tp->t_vnetb); + INIT_VNET_INET(tp->t_vnetb); #ifdef TCPDEBUG int ostate; ==== //depot/projects/vimage/src/sys/netinet/tcp_var.h#3 (text+ko) ==== @@ -177,6 +177,7 @@ u_char rcv_scale; /* window scaling for recv window */ u_char request_r_scale; /* pending window scaling */ u_char requested_s_scale; /* unused, to be reused later */ + u_char snd_limited; /* segments limited transmitted */ u_int32_t ts_recent; /* timestamp echo data */ u_long ts_recent_age; /* when last updated */ u_int32_t ts_offset; /* our timestamp offset */ @@ -187,8 +188,7 @@ u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */ tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */ u_long t_badrxtwin; /* window for retransmit recovery */ - u_char snd_limited; /* segments limited transmitted */ - u_short vnet_id; /* index to vnetb_table */ + struct vnet_base *t_vnetb; /* back pointer to parent vnet */ /* anti DoS counters */ u_long rcv_second; /* start of interval second */ u_long rcv_pps; /* received packets per second */ ==== //depot/projects/vimage/src/sys/sys/vimage.h#12 (text+ko) ==== @@ -88,8 +88,6 @@ int ifccnt; int sockcnt; - int vnet_id; /* index to vnetb_tbl */ - int vnet_magic_n; }; @@ -226,8 +224,6 @@ LIST_HEAD(vnetb_list_head, vnet_base); extern struct vnetb_list_head vnetb_head; -extern struct vnet_base *vnetb_tbl[]; /* XXX hack used in tcb */ - /* * XXX The stuff bellow needs a major cleanup / rewrite from scratch.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701242104.l0OL4qYZ000586>