diff options
author | bz <bz@FreeBSD.org> | 2009-06-22 17:48:16 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2009-06-22 17:48:16 +0000 |
commit | 309ab541f2459967517418064abfdf4a506e8a6f (patch) | |
tree | c21bbe3b3caec3df904094416659b8661ea86397 /sys/net/route.c | |
parent | d05c6432a78b010e5a1cafd8330110c63350a8b4 (diff) | |
download | FreeBSD-src-309ab541f2459967517418064abfdf4a506e8a6f.zip FreeBSD-src-309ab541f2459967517418064abfdf4a506e8a6f.tar.gz |
Move virtualization of routing related variables into their own
Vimage module, which had been there already but now is stateful.
All variables are now file local; so this further limits the global
spreading of routing related things throughout the kernel.
Add a missing function local variable in case of MPATHing.
Reviewed by: zec
Diffstat (limited to 'sys/net/route.c')
-rw-r--r-- | sys/net/route.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 2a15a41..6efc176 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -60,7 +60,6 @@ #ifdef RADIX_MPATH #include <net/radix_mpath.h> #endif -#include <net/vnet.h> #include <netinet/in.h> #include <netinet/ip_mroute.h> @@ -96,6 +95,35 @@ int rttrash; /* routes not in table but not freed */ struct rtstat rtstat; #endif +#ifndef VIMAGE_GLOBALS +struct vnet_rtable { + struct radix_node_head *_rt_tables; + uma_zone_t _rtzone; + int _rttrash; + struct rtstat _rtstat; +}; + +/* Size guard. See sys/vimage.h. */ +VIMAGE_CTASSERT(SIZEOF_vnet_rtable, sizeof(struct vnet_rtable)); + +#ifndef VIMAGE +static struct vnet_rtable vnet_rtable_0; +#endif +#endif + +/* + * Symbol translation macros + */ +#define INIT_VNET_RTABLE(vnet) \ + INIT_FROM_VNET(vnet, VNET_MOD_RTABLE, struct vnet_rtable, vnet_rtable) + +#define VNET_RTABLE(sym) VSYM(vnet_rtable, sym) + +#define V_rt_tables VNET_RTABLE(rt_tables) +#define V_rtstat VNET_RTABLE(rtstat) +#define V_rttrash VNET_RTABLE(rttrash) +#define V_rtzone VNET_RTABLE(rtzone) + static void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); static int vnet_route_iattach(const void *); @@ -104,9 +132,18 @@ static int vnet_route_idetach(const void *); #endif #ifndef VIMAGE_GLOBALS +static struct vnet_symmap vnet_rtable_symmap[] = { + VNET_SYMMAP(rtable, rt_tables), + VNET_SYMMAP(rtable, rtstat), + VNET_SYMMAP(rtable, rttrash), + VNET_SYMMAP_END +}; + static const vnet_modinfo_t vnet_rtable_modinfo = { .vmi_id = VNET_MOD_RTABLE, .vmi_name = "rtable", + .vmi_size = sizeof(struct vnet_rtable), + .vmi_symmap = vnet_rtable_symmap, .vmi_iattach = vnet_route_iattach, #ifdef VIMAGE .vmi_idetach = vnet_route_idetach @@ -155,7 +192,7 @@ SYSCTL_PROC(_net, OID_AUTO, my_fibnum, CTLTYPE_INT|CTLFLAG_RD, static __inline struct radix_node_head ** rt_tables_get_rnh_ptr(int table, int fam) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); struct radix_node_head **rnh; KASSERT(table >= 0 && table < rt_numfibs, ("%s: table out of bounds.", @@ -199,7 +236,7 @@ route_init(void) static int vnet_route_iattach(const void *unused __unused) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); struct domain *dom; struct radix_node_head **rnh; int table; @@ -345,7 +382,7 @@ struct rtentry * rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags, u_int fibnum) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); struct radix_node_head *rnh; struct rtentry *rt; struct radix_node *rn; @@ -415,7 +452,7 @@ done: void rtfree(struct rtentry *rt) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); struct radix_node_head *rnh; KASSERT(rt != NULL,("%s: NULL rt", __func__)); @@ -514,7 +551,7 @@ rtredirect_fib(struct sockaddr *dst, struct sockaddr *src, u_int fibnum) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); struct rtentry *rt, *rt0 = NULL; int error = 0; short *stat = NULL; @@ -827,7 +864,7 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) int rtexpunge(struct rtentry *rt) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); struct radix_node *rn; struct radix_node_head *rnh; struct ifaddr *ifa; @@ -955,6 +992,8 @@ rn_mpath_update(int req, struct rt_addrinfo *info, RT_LOCK(rt); RT_ADDREF(rt); if (req == RTM_DELETE) { + INIT_VNET_RTABLE(curvnet); + rt->rt_flags &= ~RTF_UP; /* * One more rtentry floating around that is not @@ -989,7 +1028,7 @@ int rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, u_int fibnum) { - INIT_VNET_NET(curvnet); + INIT_VNET_RTABLE(curvnet); int error = 0, needlock = 0; register struct rtentry *rt; register struct radix_node *rn; |