summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-07-18 15:51:16 +0000
committermpi <mpi@openbsd.org>2015-07-18 15:51:16 +0000
commit55df0a74ca63fd05c4c21e5aeadf5c4c957fdce8 (patch)
treef6159b4041233444f234906bca754b2df8f06c76 /sys/netinet6
parentEven if pf(4) is not compiled with SMALL_KERNEL add a define around (diff)
downloadwireguard-openbsd-55df0a74ca63fd05c4c21e5aeadf5c4c957fdce8.tar.xz
wireguard-openbsd-55df0a74ca63fd05c4c21e5aeadf5c4c957fdce8.zip
Abstract the routing table internals behind an rtable_* API.
Code abusing the radix internals for the routing table should now includes <net/rtable.h> and only deal with "struct rtentry". Code using a radix tree for another purpose can still include <net/radix.h>. Inputs from and ok claudio@, mikeb@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_proto.c13
-rw-r--r--sys/netinet6/nd6_rtr.c20
2 files changed, 12 insertions, 21 deletions
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index c16da207152..de32544d985 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_proto.c,v 1.77 2014/12/19 17:14:40 tedu Exp $ */
+/* $OpenBSD: in6_proto.c,v 1.78 2015/07/18 15:51:17 mpi Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -70,11 +70,8 @@
#include <net/if.h>
#include <net/if_var.h>
-#include <net/radix.h>
-#ifndef SMALL_KERNEL
-#include <net/radix_mpath.h>
-#endif
#include <net/route.h>
+#include <net/rtable.h>
#include <netinet/in.h>
#include <netinet/ip.h>
@@ -249,11 +246,7 @@ struct domain inet6domain =
{ AF_INET6, "internet6", 0, 0, 0,
(struct protosw *)inet6sw,
(struct protosw *)&inet6sw[nitems(inet6sw)], 0,
-#ifndef SMALL_KERNEL
- rn_mpath_inithead,
-#else
- rn_inithead,
-#endif
+ rtable_attach,
offsetof(struct sockaddr_in6, sin6_addr) << 3,
sizeof(struct sockaddr_in6),
in6_domifattach, in6_domifdetach, };
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 6a1255538d8..fa2ab04e923 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6_rtr.c,v 1.112 2015/07/18 15:05:32 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.113 2015/07/18 15:51:17 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
@@ -49,7 +49,7 @@
#include <net/if_var.h>
#include <net/if_types.h>
#include <net/route.h>
-#include <net/radix.h>
+#include <net/rtable.h>
#include <netinet/in.h>
#include <netinet6/in6_var.h>
@@ -72,7 +72,7 @@ void purge_detached(struct ifnet *);
void in6_init_address_ltimes(struct nd_prefix *, struct in6_addrlifetime *);
-int rt6_deleteroute(struct radix_node *, void *, u_int);
+int rt6_deleteroute(struct rtentry *, void *, unsigned int);
void nd6_addr_add(void *);
@@ -2184,26 +2184,24 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6)
void
rt6_flush(struct in6_addr *gateway, struct ifnet *ifp)
{
- struct radix_node_head *rnh = rtable_get(ifp->if_rdomain, AF_INET6);
- int s = splsoftnet();
+ int s;
/* We'll care only link-local addresses */
- if (!IN6_IS_ADDR_LINKLOCAL(gateway)) {
- splx(s);
+ if (!IN6_IS_ADDR_LINKLOCAL(gateway))
return;
- }
+
/* XXX: hack for KAME's link-local address kludge */
gateway->s6_addr16[1] = htons(ifp->if_index);
- rnh->rnh_walktree(rnh, rt6_deleteroute, (void *)gateway);
+ s = splsoftnet();
+ rtable_walk(ifp->if_rdomain, AF_INET6, rt6_deleteroute, gateway);
splx(s);
}
int
-rt6_deleteroute(struct radix_node *rn, void *arg, u_int id)
+rt6_deleteroute(struct rtentry *rt, void *arg, unsigned int id)
{
struct rt_addrinfo info;
- struct rtentry *rt = (struct rtentry *)rn;
struct in6_addr *gate = (struct in6_addr *)arg;
if (rt->rt_gateway == NULL || rt->rt_gateway->sa_family != AF_INET6)