From f02493cbbd6e5e5f9094dc7ef872f773fa8b1a11 Mon Sep 17 00:00:00 2001 From: Marko Zec Date: Fri, 28 Nov 2008 23:30:51 +0000 Subject: [PATCH] Unhide declarations of network stack virtualization structs from underneath #ifdef VIMAGE blocks. This change introduces some churn in #include ordering and nesting throughout the network stack and drivers but is not expected to cause any additional issues. In the next step this will allow us to instantiate the virtualization container structures and switch from using global variables to their "containerized" counterparts. Reviewed by: bz, julian Approved by: julian (mentor) Obtained from: //depot/projects/vimage-commit2/... X-MFC after: never Sponsored by: NLnet Foundation, The FreeBSD Foundation --- sys/contrib/ipfilter/netinet/ip_fil_freebsd.c | 2 +- sys/contrib/ipfilter/netinet/mlfk_ipl.c | 2 + sys/net/vnet.h | 5 +-- sys/netgraph/netgraph.h | 11 +++++ sys/netgraph/ng_base.c | 1 - sys/netgraph/ng_eiface.c | 3 -- sys/netinet/in.c | 1 - sys/netinet/ip_id.c | 1 - sys/netinet/ip_input.c | 2 +- sys/netinet/ip_var.h | 12 ------ sys/netinet/tcp_hostcache.c | 43 ------------------- sys/netinet/vinet.h | 17 ++++++-- sys/netinet6/in6_ifattach.c | 1 - sys/netinet6/vinet6.h | 4 -- sys/netipsec/keysock.c | 5 --- sys/netipsec/keysock.h | 5 +++ sys/netipsec/vipsec.h | 2 - sys/sys/param.h | 4 ++ 18 files changed, 40 insertions(+), 81 deletions(-) diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c index 7bfd1de3e79f..f0604b090a3b 100644 --- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c +++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c @@ -121,7 +121,7 @@ static const char rcsid[] = "@(#)$Id: ip_fil_freebsd.c,v 2.53.2.50 2007/09/20 12 #endif extern int ip_optcopy __P((struct ip *, struct ip *)); -#if (__FreeBSD_version > 460000) +#if (__FreeBSD_version > 460000) && (__FreeBSD_version < 800055) extern int path_mtu_discovery; #endif diff --git a/sys/contrib/ipfilter/netinet/mlfk_ipl.c b/sys/contrib/ipfilter/netinet/mlfk_ipl.c index 36048e4bb067..0b462d9436c8 100644 --- a/sys/contrib/ipfilter/netinet/mlfk_ipl.c +++ b/sys/contrib/ipfilter/netinet/mlfk_ipl.c @@ -43,7 +43,9 @@ static int sysctl_ipf_int ( SYSCTL_HANDLER_ARGS ); static int ipf_modload(void); static int ipf_modunload(void); +#if __FreeBSD_version < 800055 SYSCTL_DECL(_net_inet); +#endif #define SYSCTL_IPF(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|access, \ ptr, val, sysctl_ipf_int, "I", descr); diff --git a/sys/net/vnet.h b/sys/net/vnet.h index f287bf94d90e..531d7149a4eb 100644 --- a/sys/net/vnet.h +++ b/sys/net/vnet.h @@ -33,9 +33,10 @@ #ifndef _NET_VNET_H_ #define _NET_VNET_H_ -#ifdef VIMAGE #include "opt_route.h" +#include +#include #include #include #include @@ -66,8 +67,6 @@ struct vnet_net { int _ether_ipfw; }; -#endif - /* * Symbol translation macros */ diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index 78af963eaaf5..0def6414c5b6 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -1186,6 +1186,7 @@ typedef void *meta_p; /* Hash related definitions */ #define NG_ID_HASH_SIZE 128 /* most systems wont need even this many */ +#define NG_NAME_HASH_SIZE 128 /* most systems wont need even this many */ /* Virtualization macros */ #define INIT_VNET_NETGRAPH(vnet) \ @@ -1194,6 +1195,16 @@ typedef void *meta_p; #define VNET_NETGRAPH(sym) VSYM(vnet_netgraph, sym) +struct vnet_netgraph { + LIST_HEAD(, ng_node) _ng_ID_hash[NG_ID_HASH_SIZE]; + LIST_HEAD(, ng_node) _ng_name_hash[NG_NAME_HASH_SIZE]; + LIST_HEAD(, ng_node) _ng_nodelist; + ng_ID_t _nextID; + struct unrhdr *_ng_iface_unit; + struct unrhdr *_ng_eiface_unit; + struct unrhdr *_ng_wormhole_unit; +}; + /* Symbol translation macros */ #define V_nextID VNET_NETGRAPH(nextID) #define V_ng_ID_hash VNET_NETGRAPH(ng_ID_hash) diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 263469aa4753..24ed885fe080 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -183,7 +183,6 @@ static struct mtx ng_idhash_mtx; } \ } while (0) -#define NG_NAME_HASH_SIZE 128 /* most systems wont need even this many */ static LIST_HEAD(, ng_node) ng_name_hash[NG_NAME_HASH_SIZE]; static struct mtx ng_namehash_mtx; #define NG_NAMEHASH(NAME, HASH) \ diff --git a/sys/netgraph/ng_eiface.c b/sys/netgraph/ng_eiface.c index 09011d2d6d55..1c952cd96d28 100644 --- a/sys/netgraph/ng_eiface.c +++ b/sys/netgraph/ng_eiface.c @@ -447,8 +447,6 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook) caddr_t ptr; int buflen; -#define SA_SIZE(s) ((s)->sa_lensa_len) - /* Determine size of response and allocate it */ buflen = 0; TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) @@ -474,7 +472,6 @@ ng_eiface_rcvmsg(node_p node, item_p item, hook_p lasthook) buflen -= len; } break; -#undef SA_SIZE } default: diff --git a/sys/netinet/in.c b/sys/netinet/in.c index f2d7ccbe04e5..b57049f155d6 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -70,7 +70,6 @@ static void in_purgemaddrs(struct ifnet *); 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, diff --git a/sys/netinet/ip_id.c b/sys/netinet/ip_id.c index ce8c6b42ec78..ed0a3e49b044 100644 --- a/sys/netinet/ip_id.c +++ b/sys/netinet/ip_id.c @@ -104,7 +104,6 @@ static int sysctl_ip_id_change(SYSCTL_HANDLER_ARGS); MTX_SYSINIT(ip_id_mtx, &ip_id_mtx, "ip_id_mtx", MTX_DEF); -SYSCTL_DECL(_net_inet_ip); SYSCTL_PROC(_net_inet_ip, OID_AUTO, random_id_period, CTLTYPE_INT|CTLFLAG_RW, &array_size, 0, sysctl_ip_id_change, "IU", "IP ID Array size"); SYSCTL_INT(_net_inet_ip, OID_AUTO, random_id_collisions, CTLFLAG_RD, diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 8e40d8455eb1..7f12098fac20 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -104,7 +104,7 @@ struct ipstat ipstat; static int ip_rsvp_on; struct socket *ip_rsvpd; int rsvp_on; -static TAILQ_HEAD(ipqhead, ipq) ipq[IPREASS_NHASH]; +static struct ipqhead ipq[IPREASS_NHASH]; static int maxnipq; /* Administrative limit on # reass queues. */ static int maxfragsperpacket; int ipstealth; diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 3b052547661a..e23fe93379c0 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -234,18 +234,6 @@ extern struct pfil_head inet_pfil_hook; /* packet filter hooks */ void in_delayed_cksum(struct mbuf *m); -static __inline uint16_t ip_newid(void); -extern int ip_do_randomid; - -static __inline uint16_t -ip_newid(void) -{ - if (V_ip_do_randomid) - return ip_randomid(); - - return htons(V_ip_id++); -} - #endif /* _KERNEL */ #endif /* !_NETINET_IP_VAR_H_ */ diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index 25dc44a72799..ae89d59d6547 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -98,55 +98,12 @@ __FBSDID("$FreeBSD$"); #include - -TAILQ_HEAD(hc_qhead, hc_metrics); - -struct hc_head { - struct hc_qhead hch_bucket; - u_int hch_length; - struct mtx hch_mtx; -}; - -struct hc_metrics { - /* housekeeping */ - TAILQ_ENTRY(hc_metrics) rmx_q; - struct hc_head *rmx_head; /* head of bucket tail queue */ - struct in_addr ip4; /* IP address */ - struct in6_addr ip6; /* IP6 address */ - /* endpoint specific values for TCP */ - u_long rmx_mtu; /* MTU for this path */ - u_long rmx_ssthresh; /* outbound gateway buffer limit */ - u_long rmx_rtt; /* estimated round trip time */ - u_long rmx_rttvar; /* estimated rtt variance */ - u_long rmx_bandwidth; /* estimated bandwidth */ - u_long rmx_cwnd; /* congestion window */ - u_long rmx_sendpipe; /* outbound delay-bandwidth product */ - u_long rmx_recvpipe; /* inbound delay-bandwidth product */ - /* TCP hostcache internal data */ - int rmx_expire; /* lifetime for object */ - u_long rmx_hits; /* number of hits */ - u_long rmx_updates; /* number of updates */ -}; - /* Arbitrary values */ #define TCP_HOSTCACHE_HASHSIZE 512 #define TCP_HOSTCACHE_BUCKETLIMIT 30 #define TCP_HOSTCACHE_EXPIRE 60*60 /* one hour */ #define TCP_HOSTCACHE_PRUNE 5*60 /* every 5 minutes */ -struct tcp_hostcache { - struct hc_head *hashbase; - uma_zone_t zone; - u_int hashsize; - u_int hashmask; - u_int bucket_limit; - u_int cache_count; - u_int cache_limit; - int expire; - int prune; - int purgeall; -}; - #ifdef VIMAGE_GLOBALS static struct tcp_hostcache tcp_hostcache; static struct callout tcp_hc_callout; diff --git a/sys/netinet/vinet.h b/sys/netinet/vinet.h index 005a46b27fe5..5fdb1c0c28b0 100644 --- a/sys/netinet/vinet.h +++ b/sys/netinet/vinet.h @@ -33,11 +33,12 @@ #ifndef _NETINET_VINET_H_ #define _NETINET_VINET_H_ -#ifdef VIMAGE #include #include #include +#include + #include #include #include @@ -196,8 +197,6 @@ struct vnet_inet { int _icmp_quotelen; int _icmpbmcastecho; }; -#endif - /* * Symbol translation macros @@ -333,4 +332,16 @@ struct vnet_inet { #define V_udpstat VNET_INET(udpstat) #define V_useloopback VNET_INET(useloopback) +static __inline uint16_t ip_newid(void); +extern int ip_do_randomid; + +static __inline uint16_t +ip_newid(void) +{ + if (V_ip_do_randomid) + return ip_randomid(); + + return htons(V_ip_id++); +} + #endif /* !_NETINET_VINET_H_ */ diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 534eb755ea56..48579bc404c5 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); unsigned long in6_maxmtu; int ip6_auto_linklocal; struct callout in6_tmpaddrtimer_ch; -extern struct inpcbinfo udbinfo; extern struct inpcbinfo ripcbinfo; #endif diff --git a/sys/netinet6/vinet6.h b/sys/netinet6/vinet6.h index 5c5455c8bdc6..cc8269c13dc1 100644 --- a/sys/netinet6/vinet6.h +++ b/sys/netinet6/vinet6.h @@ -33,7 +33,6 @@ #ifndef _NETINET6_VINET6_H_ #define _NETINET6_VINET6_H_ -#ifdef VIMAGE #include #include #include @@ -154,15 +153,12 @@ struct vnet_inet6 { struct ip6_pktopts _ip6_opts; }; -#endif - #define INIT_VNET_INET6(vnet) \ INIT_FROM_VNET(vnet, VNET_MOD_INET6, struct vnet_inet6, vnet_inet6) #define VNET_INET6(sym) VSYM(vnet_inet6, sym) - /* * Symbol translation macros */ diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index ace6993951b7..6842b5f61233 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -66,11 +66,6 @@ #include -struct key_cb { - int key_count; - int any_count; -}; - #ifdef VIMAGE_GLOBALS static struct key_cb key_cb; struct pfkeystat pfkeystat; diff --git a/sys/netipsec/keysock.h b/sys/netipsec/keysock.h index a331b5e3694c..1097206eb25b 100644 --- a/sys/netipsec/keysock.h +++ b/sys/netipsec/keysock.h @@ -58,6 +58,11 @@ struct pfkeystat { u_quad_t sockerr; /* # of socket related errors */ }; +struct key_cb { + int key_count; + int any_count; +}; + #define KEY_SENDUP_ONE 0 #define KEY_SENDUP_ALL 1 #define KEY_SENDUP_REGISTERED 2 diff --git a/sys/netipsec/vipsec.h b/sys/netipsec/vipsec.h index 2f5acf7a25d0..32818b90c17d 100644 --- a/sys/netipsec/vipsec.h +++ b/sys/netipsec/vipsec.h @@ -33,7 +33,6 @@ #ifndef _NETIPSEC_VIPSEC_H_ #define _NETIPSEC_VIPSEC_H_ -#ifdef VIMAGE #include #include #include @@ -112,7 +111,6 @@ struct vnet_ipsec { LIST_HEAD(, secacq) _acqtree; LIST_HEAD(, secspacq) _spacqtree; }; -#endif /* * Symbol translation macros diff --git a/sys/sys/param.h b/sys/sys/param.h index 0894051c99e6..e8dd9b3e3eaa 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -92,9 +92,13 @@ #include #endif +#ifndef FALSE #define FALSE 0 +#endif +#ifndef TRUE #define TRUE 1 #endif +#endif #ifndef _KERNEL /* Signals. */