From owner-svn-src-head@freebsd.org Thu May 28 07:31:54 2020 Return-Path: Delivered-To: svn-src-head@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 649C332901B; Thu, 28 May 2020 07:31:54 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49XfXV1rNRz44P9; Thu, 28 May 2020 07:31:54 +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 3A84722932; Thu, 28 May 2020 07:31:54 +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 04S7Vs7M045114; Thu, 28 May 2020 07:31:54 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04S7Vr28045112; Thu, 28 May 2020 07:31:53 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202005280731.04S7Vr28045112@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Thu, 28 May 2020 07:31:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361574 - head/sys/netinet X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: head/sys/netinet X-SVN-Commit-Revision: 361574 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 May 2020 07:31:54 -0000 Author: melifaro Date: Thu May 28 07:31:53 2020 New Revision: 361574 URL: https://svnweb.freebsd.org/changeset/base/361574 Log: Switch ip_output/icmp_reflect rt lookup calls with fib4_lookup. fib4_lookup_nh_ represents pre-epoch generation of fib api, providing less guarantees over pointer validness and requiring on-stack data copying. Conversion is straight-forwarded, as the only 2 differences are requirement of running in network epoch and the need to handle RTF_GATEWAY case in the caller code. Reviewed by: ae Differential Revision: https://reviews.freebsd.org/D24976 Modified: head/sys/netinet/ip_icmp.c head/sys/netinet/ip_output.c Modified: head/sys/netinet/ip_icmp.c ============================================================================== --- head/sys/netinet/ip_icmp.c Thu May 28 07:29:44 2020 (r361573) +++ head/sys/netinet/ip_icmp.c Thu May 28 07:31:53 2020 (r361574) @@ -764,7 +764,7 @@ icmp_reflect(struct mbuf *m) struct ifnet *ifp; struct in_ifaddr *ia; struct in_addr t; - struct nhop4_extended nh_ext; + struct nhop_object *nh; struct mbuf *opts = NULL; int optlen = (ip->ip_hl << 2) - sizeof(struct ip); @@ -851,12 +851,13 @@ icmp_reflect(struct mbuf *m) * When we don't have a route back to the packet source, stop here * and drop the packet. */ - if (fib4_lookup_nh_ext(M_GETFIB(m), ip->ip_dst, 0, 0, &nh_ext) != 0) { + nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_NONE, 0); + if (nh == NULL) { m_freem(m); ICMPSTAT_INC(icps_noroute); goto done; } - t = nh_ext.nh_src; + t = IA_SIN(ifatoia(nh->nh_ifa))->sin_addr; match: #ifdef MAC mac_netinet_icmp_replyinplace(m); Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Thu May 28 07:29:44 2020 (r361573) +++ head/sys/netinet/ip_output.c Thu May 28 07:31:53 2020 (r361574) @@ -512,11 +512,10 @@ again: mtu = ifp->if_mtu; src = IA_SIN(ia)->sin_addr; } else { - struct nhop4_extended nh; + struct nhop_object *nh; - bzero(&nh, sizeof(nh)); - if (fib4_lookup_nh_ext(M_GETFIB(m), ip->ip_dst, 0, 0, &nh) != - 0) { + nh = fib4_lookup(M_GETFIB(m), ip->ip_dst, 0, NHR_NONE, 0); + if (nh == NULL) { #if defined(IPSEC) || defined(IPSEC_SUPPORT) /* * There is no route for this packet, but it is @@ -530,8 +529,8 @@ again: error = EHOSTUNREACH; goto bad; } - ifp = nh.nh_ifp; - mtu = nh.nh_mtu; + ifp = nh->nh_ifp; + mtu = nh->nh_mtu; /* * We are rewriting here dst to be gw actually, contradicting * comment at the beginning of the function. However, in this @@ -540,10 +539,11 @@ again: * function, the dst would be rewritten by ip_output_pfil(). */ MPASS(dst == &sin); - dst->sin_addr = nh.nh_addr; - ia = nh.nh_ia; - src = nh.nh_src; - isbroadcast = (((nh.nh_flags & (NHF_HOST | NHF_BROADCAST)) == + if (nh->nh_flags & NHF_GATEWAY) + dst->sin_addr = nh->gw4_sa.sin_addr; + ia = ifatoia(nh->nh_ifa); + src = IA_SIN(ia)->sin_addr; + isbroadcast = (((nh->nh_flags & (NHF_HOST | NHF_BROADCAST)) == (NHF_HOST | NHF_BROADCAST)) || ((ifp->if_flags & IFF_BROADCAST) && in_ifaddr_broadcast(dst->sin_addr, ia)));