svn commit: r360431 - in head/sys: net netinet

Alexander V. Chernikov melifaro at FreeBSD.org
Tue Apr 28 08:06:58 UTC 2020


Author: melifaro
Date: Tue Apr 28 08:06:56 2020
New Revision: 360431
URL: https://svnweb.freebsd.org/changeset/base/360431

Log:
  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

Modified:
  head/sys/net/radix_mpath.c
  head/sys/net/radix_mpath.h
  head/sys/netinet/ip_input.c
  head/sys/netinet/ip_output.c

Modified: head/sys/net/radix_mpath.c
==============================================================================
--- head/sys/net/radix_mpath.c	Tue Apr 28 07:25:34 2020	(r360430)
+++ head/sys/net/radix_mpath.c	Tue Apr 28 08:06:56 2020	(r360431)
@@ -257,46 +257,6 @@ rt_mpath_select(struct rtentry *rte, uint32_t 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)
 {
 

Modified: head/sys/net/radix_mpath.h
==============================================================================
--- head/sys/net/radix_mpath.h	Tue Apr 28 07:25:34 2020	(r360430)
+++ head/sys/net/radix_mpath.h	Tue Apr 28 08:06:56 2020	(r360431)
@@ -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 *);

Modified: head/sys/netinet/ip_input.c
==============================================================================
--- head/sys/netinet/ip_input.c	Tue Apr 28 07:25:34 2020	(r360430)
+++ head/sys/netinet/ip_input.c	Tue Apr 28 08:06:56 2020	(r360431)
@@ -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

Modified: head/sys/netinet/ip_output.c
==============================================================================
--- head/sys/netinet/ip_output.c	Tue Apr 28 07:25:34 2020	(r360430)
+++ head/sys/netinet/ip_output.c	Tue Apr 28 08:06:56 2020	(r360431)
@@ -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 @@ again:
 			 * 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)


More information about the svn-src-all mailing list