Convert rtalloc_mpath_fib() users to the new KPI.

New fib[46]_lookup() functions support multipath transparently.
Given that, switch the last rtalloc_mpath_fib() calls to
 dib4_lookup() and eliminate the function itself.

Note: proper flowid generation (especially for the outbound traffic) is a
 bigger topic and will be handled in a separate review.
This change leaves flowid generation intact.

Differential Revision:	https://reviews.freebsd.org/D24595
This commit is contained in:
melifaro 2020-04-28 08:06:56 +00:00
parent 4a05b1819a
commit 192053a93a
4 changed files with 10 additions and 54 deletions

View File

@ -256,46 +256,6 @@ rt_mpath_select(struct rtentry *rte, uint32_t hash)
return (rt_mpath_selectrte(rte, hash));
}
void
rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum)
{
struct rtentry *rt, *rt_tmp;
/*
* XXX we don't attempt to lookup cached route again; what should
* be done for sendto(3) case?
*/
if (ro->ro_nh && RT_LINK_IS_UP(ro->ro_nh->nh_ifp))
return;
ro->ro_nh = NULL;
rt_tmp = rtalloc1_fib(&ro->ro_dst, 1, 0, fibnum);
/* if the route does not exist or it is not multipath, don't care */
if (rt_tmp == NULL)
return;
if (rn_mpath_next((struct radix_node *)rt_tmp) == NULL) {
ro->ro_nh = rt_tmp->rt_nhop;
nhop_ref_object(ro->ro_nh);
RT_UNLOCK(rt_tmp);
return;
}
rt = rt_mpath_selectrte(rt_tmp, hash);
/* XXX try filling rt_gwroute and avoid unreachable gw */
/* gw selection has failed - there must be only zero weight routes */
if (!rt) {
RT_UNLOCK(rt_tmp);
return;
}
if (rt_tmp != rt) {
RTFREE_LOCKED(rt_tmp);
ro->ro_nh = rt->rt_nhop;
nhop_ref_object(ro->ro_nh);
} else
RT_UNLOCK(rt_tmp);
}
void
rt_mpath_init_rnh(struct rib_head *rnh)
{

View File

@ -54,7 +54,6 @@ u_int32_t rn_mpath_count(struct radix_node *);
struct rtentry *rt_mpath_matchgate(struct rtentry *, struct sockaddr *);
int rt_mpath_conflict(struct rib_head *, struct rtentry *,
struct sockaddr *);
void rtalloc_mpath_fib(struct route *, u_int32_t, u_int);
struct rtentry *rt_mpath_select(struct rtentry *, uint32_t);
struct rtentry *rt_mpath_selectrte(struct rtentry *, uint32_t);
int rt_mpath_deldup(struct rtentry *, struct rtentry *);

View File

@ -954,6 +954,7 @@ ip_forward(struct mbuf *m, int srcrt)
struct sockaddr_in *sin;
struct in_addr dest;
struct route ro;
uint32_t flowid;
int error, type = 0, code = 0, mtu = 0;
NET_EPOCH_ASSERT();
@ -978,13 +979,11 @@ ip_forward(struct mbuf *m, int srcrt)
sin->sin_len = sizeof(*sin);
sin->sin_addr = ip->ip_dst;
#ifdef RADIX_MPATH
rtalloc_mpath_fib(&ro,
ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr),
M_GETFIB(m));
flowid = ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr);
#else
ro.ro_nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_REF,
m->m_pkthdr.flowid);
flowid = m->m_pkthdr.flowid;
#endif
ro.ro_nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_REF, flowid);
if (ro.ro_nh != NULL) {
ia = ifatoia(ro.ro_nh->nh_ifa);
} else

View File

@ -68,9 +68,6 @@ __FBSDID("$FreeBSD$");
#include <net/pfil.h>
#include <net/route.h>
#include <net/route/nhop.h>
#ifdef RADIX_MPATH
#include <net/radix_mpath.h>
#endif
#include <net/rss_config.h>
#include <net/vnet.h>
@ -470,14 +467,15 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
* layer, as this is probably required in all cases
* for correct operation (as it is for ARP).
*/
uint32_t flowid;
#ifdef RADIX_MPATH
rtalloc_mpath_fib(ro,
ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr),
fibnum);
flowid = ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr);
#else
ro->ro_nh = fib4_lookup(fibnum, dst->sin_addr, 0,
NHR_REF, m->m_pkthdr.flowid);
flowid = m->m_pkthdr.flowid;
#endif
ro->ro_nh = fib4_lookup(fibnum, dst->sin_addr, 0,
NHR_REF, flowid);
if (ro->ro_nh == NULL || (!NH_IS_VALID(ro->ro_nh)) ||
!RT_LINK_IS_UP(ro->ro_nh->nh_ifp)) {
#if defined(IPSEC) || defined(IPSEC_SUPPORT)