From owner-svn-src-all@freebsd.org Tue Apr 28 08:06:58 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2F87A2B0C00; Tue, 28 Apr 2020 08:06:58 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49BDkp0RbFz4QD2; Tue, 28 Apr 2020 08:06:58 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A5BD21025; Tue, 28 Apr 2020 08:06:58 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03S86vx1087711; Tue, 28 Apr 2020 08:06:57 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03S86vQC087708; Tue, 28 Apr 2020 08:06:57 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202004280806.03S86vQC087708@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Tue, 28 Apr 2020 08:06:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360431 - in head/sys: net netinet X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: in head/sys: net netinet X-SVN-Commit-Revision: 360431 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2020 08:06:58 -0000 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 #include #include -#ifdef RADIX_MPATH -#include -#endif #include #include @@ -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)