aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2009-06-22 17:48:16 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2009-06-22 17:48:16 +0000
commitb58ea5f3106d1c43ea9fdd106749917f78379372 (patch)
treec21bbe3b3caec3df904094416659b8661ea86397 /sys/net
parent435f8ce5b88a52accbfb2ac32b29e80586447ad3 (diff)
downloadsrc-b58ea5f3106d1c43ea9fdd106749917f78379372.tar.gz
src-b58ea5f3106d1c43ea9fdd106749917f78379372.zip
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
Notes
Notes: svn path=/head/; revision=194640
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c3
-rw-r--r--sys/net/route.c55
-rw-r--r--sys/net/vnet.h5
3 files changed, 47 insertions, 16 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index eb5e519b2b2b..3990e3f1e296 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -182,9 +182,6 @@ static struct filterops netdev_filtops =
#ifndef VIMAGE_GLOBALS
static struct vnet_symmap vnet_net_symmap[] = {
VNET_SYMMAP(net, ifnet),
- VNET_SYMMAP(net, rt_tables),
- VNET_SYMMAP(net, rtstat),
- VNET_SYMMAP(net, rttrash),
VNET_SYMMAP_END
};
diff --git a/sys/net/route.c b/sys/net/route.c
index 2a15a419b6ab..6efc1762db65 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;
diff --git a/sys/net/vnet.h b/sys/net/vnet.h
index 696e47203a86..74e5b599074c 100644
--- a/sys/net/vnet.h
+++ b/sys/net/vnet.h
@@ -44,11 +44,6 @@ struct vnet_net {
int _if_indexlim;
struct knlist _ifklist;
- struct rtstat _rtstat;
- struct radix_node_head *_rt_tables;
- int _rttrash;
- uma_zone_t _rtzone;
-
struct ifnet * _loif;
struct if_clone * _lo_cloner;
struct ifc_simple_data *_lo_cloner_data;