diff options
Diffstat (limited to 'sys/net/route.c')
-rw-r--r-- | sys/net/route.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 0feadb8..d6e6d93 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -142,6 +142,7 @@ static VNET_DEFINE(uma_zone_t, rtzone); /* Routing table UMA zone. */ 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 @@ -401,15 +402,6 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags, int needlock; KASSERT((fibnum < rt_numfibs), ("rtalloc1_fib: bad fibnum")); - switch (dst->sa_family) { - case AF_INET6: - case AF_INET: - /* We support multiple FIBs. */ - break; - default: - fibnum = RT_DEFAULT_FIB; - break; - } rnh = rt_tables_get_rnh(fibnum, dst->sa_family); newrt = NULL; if (rnh == NULL) @@ -897,7 +889,7 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum) * The route must be locked. */ int -rtexpunge(struct rtentry *rt) +rt_expunge(struct radix_node_head *rnh, struct rtentry *rt) { #if !defined(RADIX_MPATH) struct radix_node *rn; @@ -906,17 +898,10 @@ rtexpunge(struct rtentry *rt) int fib; struct rtentry *rt0; #endif - struct radix_node_head *rnh; struct ifaddr *ifa; int error = 0; - /* - * Find the correct routing tree to use for this Address Family - */ - rnh = rt_tables_get_rnh(rt->rt_fibnum, rt_key(rt)->sa_family); RT_LOCK_ASSERT(rt); - if (rnh == NULL) - return (EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK_ASSERT(rnh); #ifdef RADIX_MPATH @@ -1401,6 +1386,8 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt, 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. @@ -1431,7 +1418,6 @@ bad: #undef ifpaddr #undef flags -#define senderr(e) { error = e; goto bad; } static int rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info, struct rtentry **ret_nrt, u_int fibnum) @@ -1476,7 +1462,7 @@ rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info, free_ifa = 1; if (error != 0) - senderr(error); + goto bad; } /* Check if outgoing interface has changed */ @@ -1489,7 +1475,7 @@ rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info, if (info->rti_info[RTAX_GATEWAY] != NULL) { error = rt_setgate(rt, rt_key(rt), info->rti_info[RTAX_GATEWAY]); if (error != 0) - senderr(error); + goto bad; rt->rt_flags &= ~RTF_GATEWAY; rt->rt_flags |= (RTF_GATEWAY & info->rti_flags); @@ -1507,6 +1493,8 @@ rtrequest1_fib_change(struct radix_node_head *rnh, struct rt_addrinfo *info, 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,8 +1505,20 @@ bad: ifa_free(info->rti_ifa); return (error); } -#undef senderr +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) |