diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-10-07 10:50:36 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-10-07 10:50:36 +0000 |
commit | 94ece62a44e8baa8868e570371090ecd63084b6e (patch) | |
tree | bc5f3754e4a1460f0bda7034e456eee072b9372b /sys/net/art.c | |
parent | 68c2f66c0d155e4cfba0392dd4da5e4c3ae9db46 (diff) |
Initialize the routing table before domains.
The routing table is not an optional component of the network stack
and initializing it inside the "routing domain" requires some ugly
introspection in the domain interface.
This put the rtable* layer at the same level of the if* level. These
two subsystem are organized around the two global data structure used
in the network stack:
- the global &ifnet list, to be used in process context only, and
- the routing table which can be read in interrupt context.
This change makes the rtable_* layer domain-aware and extends the
"struct domain" such that INET, INET6 and MPLS can specify the length
of the binary key used in lookups. This allows us to keep, or move
towards, AF-free route and rtable layers.
While here stop the madness and pass the size of the maximum key length
in *byte* to rn_inithead0().
ok claudio@, mikeb@
Diffstat (limited to 'sys/net/art.c')
-rw-r--r-- | sys/net/art.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/net/art.c b/sys/net/art.c index 5efaf81312b..74f13a0b39e 100644 --- a/sys/net/art.c +++ b/sys/net/art.c @@ -1,4 +1,4 @@ -/* $OpenBSD: art.c,v 1.3 2015/08/20 12:51:10 mpi Exp $ */ +/* $OpenBSD: art.c,v 1.4 2015/10/07 10:50:35 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -78,21 +78,19 @@ int art_table_walk(struct art_table *, /* * Per routing table initialization API function. */ -int -art_attach(void **head, int off) +struct art_root * +art_attach(unsigned int rtableid, int off) { struct art_root *ar; int i; - if (*head) - return (1); ar = malloc(sizeof(*ar), M_RTABLE, M_NOWAIT|M_ZERO); if (ar == NULL) - return (0); + return (NULL); /* XXX using the offset is a hack. */ switch (off) { - case 32: /* AF_INET && AF_MPLS */ + case 4: /* AF_INET && AF_MPLS */ ar->ar_alen = 32; ar->ar_nlvl = 3; ar->ar_bits[0] = 16; @@ -100,7 +98,7 @@ art_attach(void **head, int off) ar->ar_bits[2] = 8; break; #ifdef INET6 - case 64: /* AF_INET6 */ + case 8: /* AF_INET6 */ ar->ar_alen = 128; ar->ar_nlvl = 16; for (i = 0; i < ar->ar_nlvl; i++) @@ -110,19 +108,19 @@ art_attach(void **head, int off) default: printf("%s: unknown offset %d\n", __func__, off); free(ar, M_RTABLE, sizeof(*ar)); - return (0); + return (NULL); } - ar->ar_off = off / 8; + ar->ar_off = off; ar->ar_root = art_table_get(ar, NULL, -1); if (ar->ar_root == NULL) { free(ar, M_RTABLE, sizeof(*ar)); - return (0); + return (NULL); } + ar->ar_rtableid = rtableid; - *head = ar; - return (1); + return (ar); } /* |