From 23582454c7061201dc41b9ab4083ccbefd5dd88c Mon Sep 17 00:00:00 2001 From: melifaro Date: Mon, 25 Jan 2016 06:33:15 +0000 Subject: 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. --- sys/netinet/in_fib.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'sys/netinet/in_fib.c') diff --git a/sys/netinet/in_fib.c b/sys/netinet/in_fib.c index 352c6d0..afd5418 100644 --- a/sys/netinet/in_fib.c +++ b/sys/netinet/in_fib.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #ifdef RADIX_MPATH @@ -133,7 +134,7 @@ int fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flags, uint32_t flowid, struct nhop4_basic *pnh4) { - struct radix_node_head *rh; + struct rib_head *rh; struct radix_node *rn; struct sockaddr_in sin; struct rtentry *rte; @@ -148,19 +149,19 @@ fib4_lookup_nh_basic(uint32_t fibnum, struct in_addr dst, uint32_t flags, sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = dst; - RADIX_NODE_HEAD_RLOCK(rh); - rn = rh->rnh_matchaddr((void *)&sin, rh); + RIB_RLOCK(rh); + rn = rh->rnh_matchaddr((void *)&sin, &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)) { fib4_rte_to_nh_basic(rte, dst, flags, pnh4); - RADIX_NODE_HEAD_RUNLOCK(rh); + RIB_RUNLOCK(rh); return (0); } } - RADIX_NODE_HEAD_RUNLOCK(rh); + RIB_RUNLOCK(rh); return (ENOENT); } @@ -181,7 +182,7 @@ int fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flags, uint32_t flowid, struct nhop4_extended *pnh4) { - struct radix_node_head *rh; + struct rib_head *rh; struct radix_node *rn; struct sockaddr_in sin; struct rtentry *rte; @@ -196,14 +197,14 @@ fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flags, sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = dst; - RADIX_NODE_HEAD_RLOCK(rh); - rn = rh->rnh_matchaddr((void *)&sin, rh); + RIB_RLOCK(rh); + rn = rh->rnh_matchaddr((void *)&sin, &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 @@ -213,12 +214,12 @@ fib4_lookup_nh_ext(uint32_t fibnum, struct in_addr dst, uint32_t flags, if ((flags & NHR_REF) != 0) { /* TODO: 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); } -- cgit v1.1