diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-08-30 10:39:17 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-08-30 10:39:17 +0000 |
commit | c5ed706420c17da185f0a1a7e72edff6c520216f (patch) | |
tree | 9483bb4766af0434a5541f6f21a9cbf02f75c4ad /sys/net/route.c | |
parent | 1a2bdead7e7f29549e2927b099891f0827544aac (diff) |
Use a global table for domains instead of building a list at run time.
As a side effect there's no need to run if_attachdomain() after the
list of domains has been built.
ok claudio@, reyk@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r-- | sys/net/route.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 69d128d1608..051497eb2c0 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.225 2015/08/24 22:11:33 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.226 2015/08/30 10:39:16 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -173,17 +173,18 @@ rtable_alloc(void ***table, u_int id) { void **p; struct domain *dom; - u_int8_t i; + int i; if ((p = mallocarray(rtafidx_max + 1, sizeof(void *), M_RTABLE, M_NOWAIT|M_ZERO)) == NULL) return (ENOMEM); /* 2nd pass: attach */ - for (dom = domains; dom != NULL; dom = dom->dom_next) + for (i = 0; (dom = domains[i]) != NULL; i++) { if (dom->dom_rtattach) dom->dom_rtattach(&p[af2rtafidx[dom->dom_family]], dom->dom_rtoffset); + } for (i = 0; i < rtafidx_max; i++) rtable_setid(p, id, i); @@ -196,7 +197,8 @@ rtable_alloc(void ***table, u_int id) void route_init(void) { - struct domain *dom; + struct domain *dom; + int i; pool_init(&rtentry_pool, sizeof(struct rtentry), 0, 0, 0, "rtentry", NULL); @@ -206,9 +208,10 @@ route_init(void) rtafidx_max = 1; /* must have NULL at index 0, so start at 1 */ /* find out how many tables to allocate */ - for (dom = domains; dom != NULL; dom = dom->dom_next) + for (i = 0; (dom = domains[i]) != NULL; i++) { if (dom->dom_rtattach) af2rtafidx[dom->dom_family] = rtafidx_max++; + } if (rtable_add(0) != 0) panic("route_init rtable_add"); |