summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c21
-rw-r--r--sys/net/if_gif.c37
-rw-r--r--sys/net/if_loop.c13
-rw-r--r--sys/net/route.c33
-rw-r--r--sys/net/vnet.h2
5 files changed, 74 insertions, 32 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index d9af711..20627d3 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -150,6 +150,8 @@ static int if_getgroupmembers(struct ifgroupreq *);
extern void nd6_setmtu(struct ifnet *);
#endif
+static int vnet_net_iattach(const void *);
+
#ifdef VIMAGE_GLOBALS
struct ifnethead ifnet; /* depend on static init XXX */
struct ifgrouphead ifg_head;
@@ -391,24 +393,33 @@ filt_netdev(struct knote *kn, long hint)
static void
if_init(void *dummy __unused)
{
- INIT_VNET_NET(curvnet);
#ifndef VIMAGE_GLOBALS
vnet_mod_register(&vnet_net_modinfo);
#endif
+ vnet_net_iattach(NULL);
+
+ IFNET_LOCK_INIT();
+ ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
+ 0600, "network"));
+ if_clone_init();
+}
+
+static int
+vnet_net_iattach(const void *unused __unused)
+{
+ INIT_VNET_NET(curvnet);
V_if_index = 0;
V_ifindex_table = NULL;
V_if_indexlim = 8;
- IFNET_LOCK_INIT();
TAILQ_INIT(&V_ifnet);
TAILQ_INIT(&V_ifg_head);
knlist_init(&V_ifklist, NULL, NULL, NULL, NULL);
if_grow(); /* create initial table */
- ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
- 0600, "network"));
- if_clone_init();
+
+ return (0);
}
static void
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index be7fa9f..4fbbb2d 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -121,6 +121,7 @@ void (*ng_gif_detach_p)(struct ifnet *ifp);
static void gif_start(struct ifnet *);
static int gif_clone_create(struct if_clone *, int, caddr_t);
static void gif_clone_destroy(struct ifnet *);
+static int vnet_gif_iattach(const void *);
IFC_SIMPLE_DECLARE(gif, 0);
@@ -251,6 +252,26 @@ gif_clone_destroy(ifp)
}
static int
+vnet_gif_iattach(const void *unused __unused)
+{
+ INIT_VNET_GIF(curvnet);
+
+ LIST_INIT(&V_gif_softc_list);
+ V_max_gif_nesting = MAX_GIF_NEST;
+#ifdef XBONEHACK
+ V_parallel_tunnels = 1;
+#else
+ V_parallel_tunnels = 0;
+#endif
+ V_ip_gif_ttl = GIF_TTL;
+#ifdef INET6
+ V_ip6_gif_hlim = GIF_HLIM;
+#endif
+
+ return (0);
+}
+
+static int
gifmodevent(mod, type, data)
module_t mod;
int type;
@@ -261,19 +282,7 @@ gifmodevent(mod, type, data)
case MOD_LOAD:
mtx_init(&gif_mtx, "gif_mtx", NULL, MTX_DEF);
- LIST_INIT(&V_gif_softc_list);
- V_max_gif_nesting = MAX_GIF_NEST;
-#ifdef XBONEHACK
- V_parallel_tunnels = 1;
-#else
- V_parallel_tunnels = 0;
-#endif
-#ifdef INET
- V_ip_gif_ttl = GIF_TTL;
-#endif
-#ifdef INET6
- V_ip6_gif_hlim = GIF_HLIM;
-#endif
+ vnet_gif_iattach(NULL);
if_clone_attach(&gif_cloner);
break;
@@ -281,7 +290,7 @@ gifmodevent(mod, type, data)
if_clone_detach(&gif_cloner);
mtx_destroy(&gif_mtx);
#ifdef INET6
- V_ip6_gif_hlim = 0;
+ V_ip6_gif_hlim = 0; /* XXX -> vnet_gif_idetach() */
#endif
break;
default:
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index f1a017b..5748311 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -105,6 +105,7 @@ int looutput(struct ifnet *ifp, struct mbuf *m,
struct sockaddr *dst, struct rtentry *rt);
static int lo_clone_create(struct if_clone *, int, caddr_t);
static void lo_clone_destroy(struct ifnet *);
+static int vnet_loif_iattach(const void *);
#ifdef VIMAGE_GLOBALS
struct ifnet *loif; /* Used externally */
@@ -153,6 +154,15 @@ lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)
return (0);
}
+static int vnet_loif_iattach(const void *unused __unused)
+{
+ INIT_VNET_NET(curvnet);
+
+ V_loif = NULL;
+ if_clone_attach(&lo_cloner);
+ return (0);
+}
+
static int
loop_modevent(module_t mod, int type, void *data)
{
@@ -160,8 +170,7 @@ loop_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
- V_loif = NULL;
- if_clone_attach(&lo_cloner);
+ vnet_loif_iattach(NULL);
break;
case MOD_UNLOAD:
diff --git a/sys/net/route.c b/sys/net/route.c
index e06c059..a1a3d8c 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -106,6 +106,7 @@ static int rttrash; /* routes not in table but not freed */
static void rt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
+static int vnet_route_iattach(const void *);
/* compare two sockaddr structures */
#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0)
@@ -122,7 +123,9 @@ static void rt_maskedcopy(struct sockaddr *,
*/
#define RNTORT(p) ((struct rtentry *)(p))
+#ifdef VIMAGE_GLOBALS
static uma_zone_t rtzone; /* Routing table UMA zone. */
+#endif
#if 0
/* default fib for tunnels to use */
@@ -150,20 +153,26 @@ SYSCTL_PROC(_net, OID_AUTO, my_fibnum, CTLTYPE_INT|CTLFLAG_RD,
static void
route_init(void)
{
- INIT_VNET_INET(curvnet);
- int table;
- struct domain *dom;
- int fam;
/* whack the tunable ints into line. */
if (rt_numfibs > RT_MAXFIBS)
rt_numfibs = RT_MAXFIBS;
if (rt_numfibs == 0)
rt_numfibs = 1;
- rtzone = uma_zcreate("rtentry", sizeof(struct rtentry), NULL, NULL,
- NULL, NULL, UMA_ALIGN_PTR, 0);
rn_init(); /* initialize all zeroes, all ones, mask table */
+ vnet_route_iattach(NULL);
+}
+
+static int vnet_route_iattach(const void *unused __unused)
+{
+ INIT_VNET_INET(curvnet);
+ int table;
+ struct domain *dom;
+ int fam;
+
+ V_rtzone = uma_zcreate("rtentry", sizeof(struct rtentry), NULL, NULL,
+ NULL, NULL, UMA_ALIGN_PTR, 0);
for (dom = domains; dom; dom = dom->dom_next) {
if (dom->dom_rtattach) {
for (table = 0; table < rt_numfibs; table++) {
@@ -186,6 +195,8 @@ route_init(void)
}
}
}
+
+ return (0);
}
#ifndef _SYS_SYSPROTO_H_
@@ -402,7 +413,7 @@ rtfree(struct rtentry *rt)
* and the rtentry itself of course
*/
RT_LOCK_DESTROY(rt);
- uma_zfree(rtzone, rt);
+ uma_zfree(V_rtzone, rt);
return;
}
done:
@@ -958,7 +969,7 @@ deldone:
if (info->rti_ifa == NULL && (error = rt_getifa_fib(info, fibnum)))
senderr(error);
ifa = info->rti_ifa;
- rt = uma_zalloc(rtzone, M_NOWAIT | M_ZERO);
+ rt = uma_zalloc(V_rtzone, M_NOWAIT | M_ZERO);
if (rt == NULL)
senderr(ENOBUFS);
RT_LOCK_INIT(rt);
@@ -971,7 +982,7 @@ deldone:
RT_LOCK(rt);
if ((error = rt_setgate(rt, dst, gateway)) != 0) {
RT_LOCK_DESTROY(rt);
- uma_zfree(rtzone, rt);
+ uma_zfree(V_rtzone, rt);
senderr(error);
}
@@ -1006,7 +1017,7 @@ deldone:
}
Free(rt_key(rt));
RT_LOCK_DESTROY(rt);
- uma_zfree(rtzone, rt);
+ uma_zfree(V_rtzone, rt);
senderr(EEXIST);
}
#endif
@@ -1022,7 +1033,7 @@ deldone:
IFAFREE(rt->rt_ifa);
Free(rt_key(rt));
RT_LOCK_DESTROY(rt);
- uma_zfree(rtzone, rt);
+ uma_zfree(V_rtzone, rt);
senderr(EEXIST);
}
diff --git a/sys/net/vnet.h b/sys/net/vnet.h
index 9354610..0b3ef8e 100644
--- a/sys/net/vnet.h
+++ b/sys/net/vnet.h
@@ -47,6 +47,7 @@ struct vnet_net {
struct rtstat _rtstat;
struct radix_node_head *_rt_tables[RT_MAXFIBS][AF_MAX+1];
int _rttrash;
+ uma_zone_t _rtzone;
struct ifnet *_loif;
LIST_HEAD(, lo_softc) _lo_list;
@@ -86,5 +87,6 @@ extern struct vnet_net vnet_net_0;
#define V_rt_tables VNET_NET(rt_tables)
#define V_rtstat VNET_NET(rtstat)
#define V_rttrash VNET_NET(rttrash)
+#define V_rtzone VNET_NET(rtzone)
#endif /* !_NET_VNET_H_ */
OpenPOWER on IntegriCloud