Date: Tue, 29 Apr 2014 19:14:43 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265103 - head/sys/net Message-ID: <201404291914.s3TJEh38091834@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Tue Apr 29 19:14:42 2014 New Revision: 265103 URL: http://svnweb.freebsd.org/changeset/base/265103 Log: Move rt_setmetrics() from rtsock.c to route.c. All rtsock-initiated rte creation/modification are now performed in route.c holding radix tree write lock. This reduces the need for per-rte mutex. Sponsored by: Yandex LLC MFC after: 1 month Modified: head/sys/net/route.c head/sys/net/route.h head/sys/net/rtsock.c Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Tue Apr 29 19:02:34 2014 (r265102) +++ head/sys/net/route.c Tue Apr 29 19:14:42 2014 (r265103) @@ -142,6 +142,7 @@ static VNET_DEFINE(uma_zone_t, rtzone); static int rtrequest1_fib_change(struct radix_node_head *, struct rt_addrinfo *, struct rtentry **, u_int); +static void rt_setmetrics(const struct rt_addrinfo *, struct rtentry *); /* * handler for net.my_fibnum @@ -1401,6 +1402,8 @@ rtrequest1_fib(int req, struct rt_addrin if (ifa->ifa_rtrequest) ifa->ifa_rtrequest(req, rt, info); + rt_setmetrics(info, rt); + /* * actually return a resultant rtentry and * give the caller a single reference. @@ -1506,6 +1509,8 @@ rtrequest1_fib_change(struct radix_node_ if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest != NULL) rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, info); + rt_setmetrics(info, rt); + if (ret_nrt) { *ret_nrt = rt; RT_ADDREF(rt); @@ -1517,6 +1522,20 @@ bad: return (error); } +static void +rt_setmetrics(const struct rt_addrinfo *info, struct rtentry *rt) +{ + + if (info->rti_mflags & RTV_MTU) + rt->rt_mtu = info->rti_rmx->rmx_mtu; + if (info->rti_mflags & RTV_WEIGHT) + rt->rt_weight = info->rti_rmx->rmx_weight; + /* Kernel -> userland timebase conversion. */ + if (info->rti_mflags & RTV_EXPIRE) + rt->rt_expire = info->rti_rmx->rmx_expire ? + info->rti_rmx->rmx_expire - time_second + time_uptime : 0; +} + int rt_setgate(struct rtentry *rt, struct sockaddr *dst, struct sockaddr *gate) { Modified: head/sys/net/route.h ============================================================================== --- head/sys/net/route.h Tue Apr 29 19:02:34 2014 (r265102) +++ head/sys/net/route.h Tue Apr 29 19:14:42 2014 (r265103) @@ -261,6 +261,8 @@ struct rt_addrinfo { int rti_flags; struct ifaddr *rti_ifa; struct ifnet *rti_ifp; + u_long rti_mflags; + struct rt_metrics *rti_rmx; }; /* Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Tue Apr 29 19:02:34 2014 (r265102) +++ head/sys/net/rtsock.c Tue Apr 29 19:14:42 2014 (r265103) @@ -160,7 +160,6 @@ static int sysctl_dumpentry(struct radix static int sysctl_iflist(int af, struct walkarg *w); static int sysctl_ifmalist(int af, struct walkarg *w); static int route_output(struct mbuf *m, struct socket *so); -static void rt_setmetrics(const struct rt_msghdr *rtm, struct rtentry *rt); static void rt_getmetrics(const struct rtentry *rt, struct rt_metrics *out); static void rt_dispatch(struct mbuf *, sa_family_t); @@ -584,6 +583,10 @@ route_output(struct mbuf *m, struct sock rtm->rtm_pid = curproc->p_pid; info.rti_addrs = rtm->rtm_addrs; + + info.rti_mflags = rtm->rtm_inits; + info.rti_rmx = &rtm->rtm_rmx; + /* * rt_xaddrs() performs s6_addr[2] := sin6_scope_id for AF_INET6 * link-local address because rtrequest requires addresses with @@ -670,7 +673,6 @@ route_output(struct mbuf *m, struct sock rti_need_deembed = (V_deembed_scopeid) ? 1 : 0; #endif RT_LOCK(saved_nrt); - rt_setmetrics(rtm, saved_nrt); rtm->rtm_index = saved_nrt->rt_ifp->if_index; RT_REMREF(saved_nrt); RT_UNLOCK(saved_nrt); @@ -920,20 +922,6 @@ flush: } static void -rt_setmetrics(const struct rt_msghdr *rtm, struct rtentry *rt) -{ - - if (rtm->rtm_inits & RTV_MTU) - rt->rt_mtu = rtm->rtm_rmx.rmx_mtu; - if (rtm->rtm_inits & RTV_WEIGHT) - rt->rt_weight = rtm->rtm_rmx.rmx_weight; - /* Kernel -> userland timebase conversion. */ - if (rtm->rtm_inits & RTV_EXPIRE) - rt->rt_expire = rtm->rtm_rmx.rmx_expire ? - rtm->rtm_rmx.rmx_expire - time_second + time_uptime : 0; -} - -static void rt_getmetrics(const struct rtentry *rt, struct rt_metrics *out) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404291914.s3TJEh38091834>