diff options
author | melifaro <melifaro@FreeBSD.org> | 2016-01-25 06:33:15 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2016-01-25 06:33:15 +0000 |
commit | 23582454c7061201dc41b9ab4083ccbefd5dd88c (patch) | |
tree | e3d1ff0a530bc18a45f34e089f84583c63d778c7 /sys/net/rtsock.c | |
parent | 23ee6b6bf28dd68ee75ec7a21424cd765fb32fb4 (diff) | |
download | FreeBSD-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/net/rtsock.c')
-rw-r--r-- | sys/net/rtsock.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index a5ca9fa..d59ef70 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -59,6 +59,7 @@ #include <net/netisr.h> #include <net/raw_cb.h> #include <net/route.h> +#include <net/route_var.h> #include <net/vnet.h> #include <netinet/in.h> @@ -520,7 +521,7 @@ route_output(struct mbuf *m, struct socket *so, ...) { struct rt_msghdr *rtm = NULL; struct rtentry *rt = NULL; - struct radix_node_head *rnh; + struct rib_head *rnh; struct rt_addrinfo info; struct sockaddr_storage ss; #ifdef INET6 @@ -706,7 +707,7 @@ route_output(struct mbuf *m, struct socket *so, ...) if (rnh == NULL) senderr(EAFNOSUPPORT); - RADIX_NODE_HEAD_RLOCK(rnh); + RIB_RLOCK(rnh); if (info.rti_info[RTAX_NETMASK] == NULL && rtm->rtm_type == RTM_GET) { @@ -716,14 +717,14 @@ route_output(struct mbuf *m, struct socket *so, ...) * 'route -n get addr' */ rt = (struct rtentry *) rnh->rnh_matchaddr( - info.rti_info[RTAX_DST], rnh); + info.rti_info[RTAX_DST], &rnh->head); } else rt = (struct rtentry *) rnh->rnh_lookup( info.rti_info[RTAX_DST], - info.rti_info[RTAX_NETMASK], rnh); + info.rti_info[RTAX_NETMASK], &rnh->head); if (rt == NULL) { - RADIX_NODE_HEAD_RUNLOCK(rnh); + RIB_RUNLOCK(rnh); senderr(ESRCH); } #ifdef RADIX_MPATH @@ -735,11 +736,11 @@ route_output(struct mbuf *m, struct socket *so, ...) * if gate == NULL the first match is returned. * (no need to call rt_mpath_matchgate if gate == NULL) */ - if (rn_mpath_capable(rnh) && + if (rt_mpath_capable(rnh) && (rtm->rtm_type != RTM_GET || info.rti_info[RTAX_GATEWAY])) { rt = rt_mpath_matchgate(rt, info.rti_info[RTAX_GATEWAY]); if (!rt) { - RADIX_NODE_HEAD_RUNLOCK(rnh); + RIB_RUNLOCK(rnh); senderr(ESRCH); } } @@ -770,15 +771,16 @@ route_output(struct mbuf *m, struct socket *so, ...) /* * refactor rt and no lock operation necessary */ - rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, rnh); + rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, + &rnh->head); if (rt == NULL) { - RADIX_NODE_HEAD_RUNLOCK(rnh); + RIB_RUNLOCK(rnh); senderr(ESRCH); } } RT_LOCK(rt); RT_ADDREF(rt); - RADIX_NODE_HEAD_RUNLOCK(rnh); + RIB_RUNLOCK(rnh); report: RT_LOCK_ASSERT(rt); @@ -1803,7 +1805,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) { int *name = (int *)arg1; u_int namelen = arg2; - struct radix_node_head *rnh = NULL; /* silence compiler. */ + struct rib_head *rnh = NULL; /* silence compiler. */ int i, lim, error = EINVAL; int fib = 0; u_char af; @@ -1872,10 +1874,10 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS) for (error = 0; error == 0 && i <= lim; i++) { rnh = rt_tables_get_rnh(fib, i); if (rnh != NULL) { - RADIX_NODE_HEAD_RLOCK(rnh); - error = rnh->rnh_walktree(rnh, + RIB_RLOCK(rnh); + error = rnh->rnh_walktree(&rnh->head, sysctl_dumpentry, &w); - RADIX_NODE_HEAD_RUNLOCK(rnh); + RIB_RUNLOCK(rnh); } else if (af != 0) error = EAFNOSUPPORT; } |