summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2016-01-25 06:33:15 +0000
committermelifaro <melifaro@FreeBSD.org>2016-01-25 06:33:15 +0000
commit23582454c7061201dc41b9ab4083ccbefd5dd88c (patch)
treee3d1ff0a530bc18a45f34e089f84583c63d778c7 /sys/netinet6
parent23ee6b6bf28dd68ee75ec7a21424cd765fb32fb4 (diff)
downloadFreeBSD-src-23582454c7061201dc41b9ab4083ccbefd5dd88c.zip
FreeBSD-src-23582454c7061201dc41b9ab4083ccbefd5dd88c.tar.gz
MFP r287070,r287073: split radix implementation and route table structure.
There are number of radix consumers in kernel land (pf,ipfw,nfs,route) with different requirements. In fact, first 3 don't have _any_ requirements and first 2 does not use radix locking. On the other hand, routing structure do have these requirements (rnh_gen, multipath, custom to-be-added control plane functions, different locking). Additionally, radix should not known anything about its consumers internals. So, radix code now uses tiny 'struct radix_head' structure along with internal 'struct radix_mask_head' instead of 'struct radix_node_head'. Existing consumers still uses the same 'struct radix_node_head' with slight modifications: they need to pass pointer to (embedded) 'struct radix_head' to all radix callbacks. Routing code now uses new 'struct rib_head' with different locking macro: RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing information base). New net/route_var.h header was added to hold routing subsystem internal data. 'struct rib_head' was placed there. 'struct rtentry' will also be moved there soon.
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_fib.c23
-rw-r--r--sys/netinet6/in6_rmx.c19
-rw-r--r--sys/netinet6/nd6_rtr.c7
3 files changed, 25 insertions, 24 deletions
diff --git a/sys/netinet6/in6_fib.c b/sys/netinet6/in6_fib.c
index 96acfbb..b01e633 100644
--- a/sys/netinet6/in6_fib.c
+++ b/sys/netinet6/in6_fib.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_var.h>
#include <net/if_dl.h>
#include <net/route.h>
+#include <net/route_var.h>
#include <net/vnet.h>
#ifdef RADIX_MPATH
@@ -170,7 +171,7 @@ int
fib6_lookup_nh_basic(uint32_t fibnum, const struct in6_addr *dst, uint32_t scopeid,
uint32_t flags, uint32_t flowid, struct nhop6_basic *pnh6)
{
- struct radix_node_head *rh;
+ struct rib_head *rh;
struct radix_node *rn;
struct sockaddr_in6 sin6;
struct rtentry *rte;
@@ -188,18 +189,18 @@ fib6_lookup_nh_basic(uint32_t fibnum, const struct in6_addr *dst, uint32_t scope
if (IN6_IS_SCOPE_LINKLOCAL(dst))
sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff);
- RADIX_NODE_HEAD_RLOCK(rh);
- rn = rh->rnh_matchaddr((void *)&sin6, rh);
+ RIB_RLOCK(rh);
+ rn = rh->rnh_matchaddr((void *)&sin6, &rh->head);
if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
rte = RNTORT(rn);
/* Ensure route & ifp is UP */
if (RT_LINK_IS_UP(rte->rt_ifp)) {
fib6_rte_to_nh_basic(rte, &sin6.sin6_addr, flags, pnh6);
- RADIX_NODE_HEAD_RUNLOCK(rh);
+ RIB_RUNLOCK(rh);
return (0);
}
}
- RADIX_NODE_HEAD_RUNLOCK(rh);
+ RIB_RUNLOCK(rh);
return (ENOENT);
}
@@ -219,7 +220,7 @@ int
fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst,uint32_t scopeid,
uint32_t flags, uint32_t flowid, struct nhop6_extended *pnh6)
{
- struct radix_node_head *rh;
+ struct rib_head *rh;
struct radix_node *rn;
struct sockaddr_in6 sin6;
struct rtentry *rte;
@@ -237,14 +238,14 @@ fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst,uint32_t scopeid,
if (IN6_IS_SCOPE_LINKLOCAL(dst))
sin6.sin6_addr.s6_addr16[1] = htons(scopeid & 0xffff);
- RADIX_NODE_HEAD_RLOCK(rh);
- rn = rh->rnh_matchaddr((void *)&sin6, rh);
+ RIB_RLOCK(rh);
+ rn = rh->rnh_matchaddr((void *)&sin6, &rh->head);
if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) {
rte = RNTORT(rn);
#ifdef RADIX_MPATH
rte = rt_mpath_select(rte, flowid);
if (rte == NULL) {
- RADIX_NODE_HEAD_RUNLOCK(rh);
+ RIB_RUNLOCK(rh);
return (ENOENT);
}
#endif
@@ -255,12 +256,12 @@ fib6_lookup_nh_ext(uint32_t fibnum, const struct in6_addr *dst,uint32_t scopeid,
if ((flags & NHR_REF) != 0) {
/* TODO: Do lwref on egress ifp's */
}
- RADIX_NODE_HEAD_RUNLOCK(rh);
+ RIB_RUNLOCK(rh);
return (0);
}
}
- RADIX_NODE_HEAD_RUNLOCK(rh);
+ RIB_RUNLOCK(rh);
return (ENOENT);
}
diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c
index 93c786c..38b4bf2 100644
--- a/sys/netinet6/in6_rmx.c
+++ b/sys/netinet6/in6_rmx.c
@@ -77,6 +77,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
+#include <net/route_var.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
@@ -102,13 +103,12 @@ extern int in6_detachhead(void **head, int off);
* Do what we need to do when inserting a route.
*/
static struct radix_node *
-in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
+in6_addroute(void *v_arg, void *n_arg, struct radix_head *head,
struct radix_node *treenodes)
{
struct rtentry *rt = (struct rtentry *)treenodes;
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rt_key(rt);
- RADIX_NODE_HEAD_WLOCK_ASSERT(head);
if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
rt->rt_flags |= RTF_MULTICAST;
@@ -154,7 +154,7 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
* Age old PMTUs.
*/
struct mtuex_arg {
- struct radix_node_head *rnh;
+ struct rib_head *rnh;
time_t nextstop;
};
static VNET_DEFINE(struct callout, rtq_mtutimer);
@@ -179,7 +179,7 @@ in6_mtuexpire(struct rtentry *rt, void *rock)
#define MTUTIMO_DEFAULT (60*1)
static void
-in6_mtutimo_setwa(struct radix_node_head *rnh, uint32_t fibum, int af,
+in6_mtutimo_setwa(struct rib_head *rnh, uint32_t fibum, int af,
void *_arg)
{
struct mtuex_arg *arg;
@@ -213,15 +213,14 @@ static VNET_DEFINE(int, _in6_rt_was_here);
int
in6_inithead(void **head, int off)
{
- struct radix_node_head *rnh;
+ struct rib_head *rh;
- if (!rn_inithead(head, offsetof(struct sockaddr_in6, sin6_addr) << 3))
+ rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3);
+ if (rh == NULL)
return (0);
- rnh = *head;
- RADIX_NODE_HEAD_LOCK_INIT(rnh);
-
- rnh->rnh_addaddr = in6_addroute;
+ rh->rnh_addaddr = in6_addroute;
+ *head = (void *)rh;
if (V__in6_rt_was_here == 0) {
callout_init(&V_rtq_mtutimer, 1);
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index b57cf15..ca64908 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_types.h>
#include <net/if_dl.h>
#include <net/route.h>
+#include <net/route_var.h>
#include <net/radix.h>
#include <net/vnet.h>
@@ -1525,7 +1526,7 @@ static int
nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, struct ifaddr *ifa)
{
static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
- struct radix_node_head *rnh;
+ struct rib_head *rnh;
struct rtentry *rt;
struct sockaddr_in6 mask6;
u_long rtflags;
@@ -1554,7 +1555,7 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, struct ifaddr *ifa)
rnh = rt_tables_get_rnh(rt->rt_fibnum, AF_INET6);
/* XXX what if rhn == NULL? */
- RADIX_NODE_HEAD_LOCK(rnh);
+ RIB_WLOCK(rnh);
RT_LOCK(rt);
if (rt_setgate(rt, rt_key(rt),
(struct sockaddr *)&null_sdl) == 0) {
@@ -1564,7 +1565,7 @@ nd6_prefix_onlink_rtrequest(struct nd_prefix *pr, struct ifaddr *ifa)
dl->sdl_type = rt->rt_ifp->if_type;
dl->sdl_index = rt->rt_ifp->if_index;
}
- RADIX_NODE_HEAD_UNLOCK(rnh);
+ RIB_WUNLOCK(rnh);
nd6_rtmsg(RTM_ADD, rt);
RT_UNLOCK(rt);
pr->ndpr_stateflags |= NDPRF_ONLINK;
OpenPOWER on IntegriCloud