From owner-svn-src-head@freebsd.org Thu May 28 07:29:45 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 39C13328E13; Thu, 28 May 2020 07:29:45 +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 49XfV10qRLz43wW; Thu, 28 May 2020 07:29:45 +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 16AC92274F; Thu, 28 May 2020 07:29:45 +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 04S7TiaU043457; Thu, 28 May 2020 07:29:44 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04S7Ti0h043456; Thu, 28 May 2020 07:29:44 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202005280729.04S7Ti0h043456@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:29:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361573 - head/sys/netinet6 X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: head/sys/netinet6 X-SVN-Commit-Revision: 361573 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:29:45 -0000 Author: melifaro Date: Thu May 28 07:29:44 2020 New Revision: 361573 URL: https://svnweb.freebsd.org/changeset/base/361573 Log: Replace ip6_ouput fib6_lookup_nh_ calls with fib6_lookup(). fib6_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/D24973 Modified: head/sys/netinet6/ip6_output.c Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Thu May 28 07:26:18 2020 (r361572) +++ head/sys/netinet6/ip6_output.c Thu May 28 07:29:44 2020 (r361573) @@ -736,7 +736,7 @@ again: counter_u64_add(nh->nh_pksent, 1); } } else { - struct nhop6_extended nh6; + struct nhop_object *nh; struct in6_addr kdst; uint32_t scopeid; @@ -766,20 +766,19 @@ again: } } - error = fib6_lookup_nh_ext(fibnum, &kdst, scopeid, NHR_REF, 0, - &nh6); - if (error != 0) { + nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0); + if (nh == NULL) { IP6STAT_INC(ip6s_noroute); /* No ifp in6_ifstat_inc(ifp, ifs6_out_discard); */ error = EHOSTUNREACH;; goto bad; } - ifp = nh6.nh_ifp; - mtu = nh6.nh_mtu; - dst->sin6_addr = nh6.nh_addr; - ia = nh6.nh_ia; - fib6_free_nh_ext(fibnum, &nh6); + ifp = nh->nh_ifp; + mtu = nh->nh_mtu; + ia = ifatoia6(nh->nh_ifa); + if (nh->nh_flags & NHF_GATEWAY) + dst->sin6_addr = nh->gw6_sa.sin6_addr; nonh6lookup: ; } @@ -1449,23 +1448,22 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int static int ip6_getpmtu_ctl(u_int fibnum, const struct in6_addr *dst, u_long *mtup) { - struct nhop6_extended nh6; + struct epoch_tracker et; + struct nhop_object *nh; struct in6_addr kdst; uint32_t scopeid; - struct ifnet *ifp; - u_long mtu; int error; in6_splitscope(dst, &kdst, &scopeid); - if (fib6_lookup_nh_ext(fibnum, &kdst, scopeid, NHR_REF, 0, &nh6) != 0) - return (EHOSTUNREACH); - ifp = nh6.nh_ifp; - mtu = nh6.nh_mtu; + NET_EPOCH_ENTER(et); + nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0); + if (nh != NULL) + error = ip6_calcmtu(nh->nh_ifp, dst, nh->nh_mtu, mtup, NULL, 0); + else + error = EHOSTUNREACH; + NET_EPOCH_EXIT(et); - error = ip6_calcmtu(ifp, dst, mtu, mtup, NULL, 0); - fib6_free_nh_ext(fibnum, &nh6); - return (error); } @@ -1484,12 +1482,14 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, int do_lookup, struct ifnet *ifp, const struct in6_addr *dst, u_long *mtup, int *alwaysfragp, u_int fibnum, u_int proto) { - struct nhop6_basic nh6; + struct nhop_object *nh; struct in6_addr kdst; uint32_t scopeid; struct sockaddr_in6 *sa6_dst, sin6; u_long mtu; + NET_EPOCH_ASSERT(); + mtu = 0; if (ro_pmtu == NULL || do_lookup) { @@ -1512,9 +1512,9 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, int do_lookup, sa6_dst->sin6_addr = *dst; in6_splitscope(dst, &kdst, &scopeid); - if (fib6_lookup_nh_basic(fibnum, &kdst, scopeid, 0, 0, - &nh6) == 0) { - mtu = nh6.nh_mtu; + nh = fib6_lookup(fibnum, &kdst, scopeid, NHR_NONE, 0); + if (nh != NULL) { + mtu = nh->nh_mtu; if (ro_pmtu != NULL) ro_pmtu->ro_mtu = mtu; }