From owner-p4-projects@FreeBSD.ORG Fri Jun 22 16:40:08 2007 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 191D916A469; Fri, 22 Jun 2007 16:40:08 +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 A903516A41F for ; Fri, 22 Jun 2007 16:40:07 +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 9B2B013C448 for ; Fri, 22 Jun 2007 16:40:07 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l5MGe7Dp032263 for ; Fri, 22 Jun 2007 16:40:07 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l5MGe7R0032260 for perforce@freebsd.org; Fri, 22 Jun 2007 16:40:07 GMT (envelope-from zec@FreeBSD.org) Date: Fri, 22 Jun 2007 16:40:07 GMT Message-Id: <200706221640.l5MGe7R0032260@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 122160 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: Fri, 22 Jun 2007 16:40:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=122160 Change 122160 by zec@zec_tca51 on 2007/06/22 16:39:47 Fix a few bugs introduced by recent integrations from HEAD, i.e. remove a few variables from global namespace that have already been virtualized. Affected files ... .. //depot/projects/vimage/src/sys/netinet/in.c#9 edit .. //depot/projects/vimage/src/sys/netinet/in_mcast.c#2 edit .. //depot/projects/vimage/src/sys/netinet/tcp_hostcache.c#12 edit .. //depot/projects/vimage/src/sys/netinet/tcp_subr.c#18 edit .. //depot/projects/vimage/src/sys/netinet/vinet.h#16 edit Differences ... ==== //depot/projects/vimage/src/sys/netinet/in.c#9 (text+ko) ==== @@ -67,19 +67,20 @@ struct in_ifaddr *, struct sockaddr_in *, int); static void in_purgemaddrs(struct ifnet *); -static int subnetsarelocal = 0; -SYSCTL_INT(_net_inet_ip, OID_AUTO, subnets_are_local, CTLFLAG_RW, - &subnetsarelocal, 0, "Treat all subnets as directly connected"); -static int sameprefixcarponly = 0; -SYSCTL_INT(_net_inet_ip, OID_AUTO, same_prefix_carp_only, CTLFLAG_RW, - &sameprefixcarponly, 0, - "Refuse to create same prefixes on different interfaces"); - #ifndef VIMAGE +static int subnetsarelocal; +static int sameprefixcarponly; extern struct inpcbinfo ripcbinfo; extern struct inpcbinfo udbinfo; #endif +SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, subnets_are_local, + CTLFLAG_RW, subnetsarelocal, 0, + "Treat all subnets as directly connected"); +SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, same_prefix_carp_only, + CTLFLAG_RW, sameprefixcarponly, 0, + "Refuse to create same prefixes on different interfaces"); + /* * Return 1 if an internet address is for a ``local'' host * (one to which we have a connection). If subnetsarelocal @@ -93,7 +94,7 @@ register u_long i = ntohl(in.s_addr); register struct in_ifaddr *ia; - if (subnetsarelocal) { + if (V_subnetsarelocal) { TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) if ((i & ia->ia_netmask) == ia->ia_net) return (1); @@ -843,7 +844,7 @@ * interface address, we are done here. */ if (ia->ia_flags & IFA_ROUTE) { - if (sameprefixcarponly && + if (V_sameprefixcarponly && target->ia_ifp->if_type != IFT_CARP && ia->ia_ifp->if_type != IFT_CARP) return (EEXIST); ==== //depot/projects/vimage/src/sys/netinet/in_mcast.c#2 (text+ko) ==== @@ -89,7 +89,9 @@ * ip_output() to send IGMP packets while holding the lock; this probably is * not quite desirable. */ +#ifndef VIMAGE struct in_multihead in_multihead; /* XXX BSS initialization */ +#endif struct mtx in_multi_mtx; MTX_SYSINIT(in_multi_mtx, &in_multi_mtx, "in_multi_mtx", MTX_DEF | MTX_RECURSE); @@ -314,6 +316,7 @@ struct in_multi * in_addmulti(struct in_addr *ap, struct ifnet *ifp) { + INIT_VNET_INET(ifp->if_vnet); struct in_multi *inm; inm = NULL; @@ -375,7 +378,7 @@ ninm->inm_ifma = ifma; ninm->inm_refcount = 1; ifma->ifma_protospec = ninm; - LIST_INSERT_HEAD(&in_multihead, ninm, inm_link); + LIST_INSERT_HEAD(&V_in_multihead, ninm, inm_link); igmp_joingroup(ninm); ==== //depot/projects/vimage/src/sys/netinet/tcp_hostcache.c#12 (text+ko) ==== @@ -103,7 +103,9 @@ #define TCP_HOSTCACHE_EXPIRE 60*60 /* one hour */ #define TCP_HOSTCACHE_PRUNE 5*60 /* every 5 minutes */ +#ifndef VIMAGE static struct tcp_hostcache tcp_hostcache; +#endif static struct callout tcp_hc_callout; @@ -135,8 +137,8 @@ CTLFLAG_RW, tcp_hostcache.expire, 0, "Expire time of TCP hostcache entries"); -SYSCTL_INT(_net_inet_tcp_hostcache, OID_AUTO, prune, CTLFLAG_RW, - &tcp_hostcache.prune, 0, "Time between purge runs"); +SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, prune, + CTLFLAG_RW, tcp_hostcache.prune, 0, "Time between purge runs"); SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, purge, CTLFLAG_RW, tcp_hostcache.purgeall, 0, @@ -179,7 +181,7 @@ V_tcp_hostcache.cache_limit = V_tcp_hostcache.hashsize * V_tcp_hostcache.bucket_limit; V_tcp_hostcache.expire = TCP_HOSTCACHE_EXPIRE; - tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE; + V_tcp_hostcache.prune = TCP_HOSTCACHE_PRUNE; TUNABLE_INT_FETCH("net.inet.tcp.hostcache.hashsize", &V_tcp_hostcache.hashsize); @@ -227,7 +229,7 @@ if (curvnet == &vnet_0) { #endif callout_init(&tcp_hc_callout, CALLOUT_MPSAFE); - callout_reset(&tcp_hc_callout, tcp_hostcache.prune * hz, tcp_hc_purge, 0); + callout_reset(&tcp_hc_callout, V_tcp_hostcache.prune * hz, tcp_hc_purge, 0); #ifdef VIMAGE } #endif @@ -660,10 +662,15 @@ V_tcp_hostcache.hashbase[i].hch_length--; V_tcp_hostcache.cache_count--; } else - hc_entry->rmx_expire -= tcp_hostcache.prune; + hc_entry->rmx_expire -= V_tcp_hostcache.prune; } THC_UNLOCK(&V_tcp_hostcache.hashbase[i].hch_mtx); } VNET_ITERLOOP_END(); - callout_reset(&tcp_hc_callout, tcp_hostcache.prune * hz, tcp_hc_purge, 0); + + /* XXX Marko - FIXME! */ + CURVNET_SET(&vnet_0); + INIT_VNET_INET(&vnet_0); + callout_reset(&tcp_hc_callout, V_tcp_hostcache.prune * hz, tcp_hc_purge, 0); + CURVNET_RESTORE(); } ==== //depot/projects/vimage/src/sys/netinet/tcp_subr.c#18 (text+ko) ==== @@ -875,10 +875,9 @@ void tcp_drain(void) { - VNET_ITERLOOP_BEGIN(); - INIT_VNET_INET(vnet_iter); - if (do_tcpdrain) { + VNET_ITERLOOP_BEGIN(); + INIT_VNET_INET(vnet_iter); struct inpcb *inpb; struct tcpcb *tcpb; struct tseg_qent *te; @@ -910,9 +909,8 @@ INP_UNLOCK(inpb); } INP_INFO_RUNLOCK(&V_tcbinfo); + VNET_ITERLOOP_END(); } - - VNET_ITERLOOP_END(); } /* @@ -1453,10 +1451,12 @@ #define ISN_STATIC_INCREMENT 4096 #define ISN_RANDOM_INCREMENT (4096 - 1) +#ifndef VIMAGE static u_char isn_secret[32]; static int isn_last_reseed; static u_int32_t isn_offset, isn_offset_old; static MD5_CTX isn_ctx; +#endif tcp_seq tcp_new_isn(struct tcpcb *tp) @@ -1469,37 +1469,37 @@ ISN_LOCK(); /* Seed if this is the first use, reseed if requested. */ - if ((isn_last_reseed == 0) || ((V_tcp_isn_reseed_interval > 0) && - (((u_int)isn_last_reseed + (u_int)V_tcp_isn_reseed_interval*hz) + if ((V_isn_last_reseed == 0) || ((V_tcp_isn_reseed_interval > 0) && + (((u_int)V_isn_last_reseed + (u_int)V_tcp_isn_reseed_interval*hz) < (u_int)ticks))) { - read_random(&isn_secret, sizeof(isn_secret)); - isn_last_reseed = ticks; + read_random(&V_isn_secret, sizeof(V_isn_secret)); + V_isn_last_reseed = ticks; } /* Compute the md5 hash and return the ISN. */ - MD5Init(&isn_ctx); - MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_fport, sizeof(u_short)); - MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_lport, sizeof(u_short)); + MD5Init(&V_isn_ctx); + MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_fport, sizeof(u_short)); + MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_lport, sizeof(u_short)); #ifdef INET6 if ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) { - MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->in6p_faddr, + MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->in6p_faddr, sizeof(struct in6_addr)); - MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->in6p_laddr, + MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->in6p_laddr, sizeof(struct in6_addr)); } else #endif { - MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_faddr, + MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_faddr, sizeof(struct in_addr)); - MD5Update(&isn_ctx, (u_char *) &tp->t_inpcb->inp_laddr, + MD5Update(&V_isn_ctx, (u_char *) &tp->t_inpcb->inp_laddr, sizeof(struct in_addr)); } - MD5Update(&isn_ctx, (u_char *) &isn_secret, sizeof(isn_secret)); - MD5Final((u_char *) &md5_buffer, &isn_ctx); + MD5Update(&V_isn_ctx, (u_char *) &V_isn_secret, sizeof(V_isn_secret)); + MD5Final((u_char *) &md5_buffer, &V_isn_ctx); new_isn = (tcp_seq) md5_buffer[0]; - isn_offset += ISN_STATIC_INCREMENT + + V_isn_offset += ISN_STATIC_INCREMENT + (arc4random() & ISN_RANDOM_INCREMENT); - new_isn += isn_offset; + new_isn += V_isn_offset; ISN_UNLOCK(); return (new_isn); } @@ -1515,12 +1515,15 @@ u_int32_t projected_offset; ISN_LOCK(); - projected_offset = isn_offset_old + ISN_BYTES_PER_SECOND / 100; + VNET_ITERLOOP_BEGIN(); + INIT_VNET_INET(curvnet); + projected_offset = V_isn_offset_old + ISN_BYTES_PER_SECOND / 100; - if (projected_offset > isn_offset) - isn_offset = projected_offset; + if (projected_offset > V_isn_offset) + V_isn_offset = projected_offset; - isn_offset_old = isn_offset; + V_isn_offset_old = V_isn_offset; + VNET_ITERLOOP_END(); callout_reset(&isn_callout, hz/100, tcp_isn_tick, NULL); ISN_UNLOCK(); } ==== //depot/projects/vimage/src/sys/netinet/vinet.h#16 (text+ko) ==== @@ -36,6 +36,7 @@ #ifdef VIMAGE #include #include +#include #include #include @@ -65,6 +66,8 @@ int _arp_maxtries; int _useloopback; int _arp_proxyall; + int _subnetsarelocal; + int _sameprefixcarponly; int _ipforwarding; int _ipfastforward_active; @@ -128,6 +131,12 @@ int _tcp_reass_maxqlen; int _tcp_reass_overflows; + u_char _isn_secret[32]; + int _isn_last_reseed; + u_int32_t _isn_offset; + u_int32_t _isn_offset_old; + MD5_CTX _isn_ctx; + struct inpcbhead _udb; struct inpcbinfo _udbinfo; struct udpstat _udpstat; @@ -191,6 +200,8 @@ #define V_arp_maxtries VNET_INET(arp_maxtries) #define V_useloopback VNET_INET(useloopback) #define V_arp_proxyall VNET_INET(arp_proxyall) +#define V_subnetsarelocal VNET_INET(subnetsarelocal) +#define V_sameprefixcarponly VNET_INET(sameprefixcarponly) #define V_ipforwarding VNET_INET(ipforwarding) #define V_ipfastforward_active VNET_INET(ipfastforward_active) @@ -254,6 +265,12 @@ #define V_tcp_reass_maxqlen VNET_INET(tcp_reass_maxqlen) #define V_tcp_reass_overflows VNET_INET(tcp_reass_overflows) +#define V_isn_secret VNET_INET(isn_secret) +#define V_isn_last_reseed VNET_INET(isn_last_reseed) +#define V_isn_offset VNET_INET(isn_offset) +#define V_isn_offset_old VNET_INET(isn_offset_old) +#define V_isn_ctx VNET_INET(isn_ctx) + #define V_udb VNET_INET(udb) #define V_udbinfo VNET_INET(udbinfo) #define V_udpstat VNET_INET(udpstat)