From owner-svn-src-all@freebsd.org Wed Apr 29 21:54:11 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 38B512C3F37; Wed, 29 Apr 2020 21:54:11 +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 49CC2q0kcmz3N9k; Wed, 29 Apr 2020 21:54:11 +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 139A5C6F8; Wed, 29 Apr 2020 21:54:11 +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 03TLsAZL028311; Wed, 29 Apr 2020 21:54:10 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03TLsAp5028307; Wed, 29 Apr 2020 21:54:10 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202004292154.03TLsAp5028307@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Wed, 29 Apr 2020 21:54:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360478 - in head/sys/net: . route X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: in head/sys/net: . route X-SVN-Commit-Revision: 360478 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: Wed, 29 Apr 2020 21:54:11 -0000 Author: melifaro Date: Wed Apr 29 21:54:09 2020 New Revision: 360478 URL: https://svnweb.freebsd.org/changeset/base/360478 Log: Convert more rtentry field accesses into nhop fields accesses. Continue routing subsystem conversion to nhop objects defined in r359823. Use fields from nhop structure instead of "struct rtentry" fields. This is one of the last changes prior to removing rt_ifp, rt_ifa, rt_gateway and rt_mtu from struct rtentry. Differential Revision: https://reviews.freebsd.org/D24609 Modified: head/sys/net/radix_mpath.c head/sys/net/route.c head/sys/net/route/route_ddb.c head/sys/net/rtsock.c Modified: head/sys/net/radix_mpath.c ============================================================================== --- head/sys/net/radix_mpath.c Wed Apr 29 21:48:52 2020 (r360477) +++ head/sys/net/radix_mpath.c Wed Apr 29 21:54:09 2020 (r360478) @@ -183,6 +183,7 @@ rt_mpath_conflict(struct rib_head *rnh, struct rtentry struct sockaddr *netmask) { struct radix_node *rn, *rn1; + struct nhop_object *nh, *nh1; struct rtentry *rt1; rn = (struct radix_node *)rt; @@ -198,15 +199,17 @@ rt_mpath_conflict(struct rib_head *rnh, struct rtentry if (rn1 == rn) continue; - if (rt1->rt_gateway->sa_family == AF_LINK) { - if (rt1->rt_ifa->ifa_addr->sa_len != rt->rt_ifa->ifa_addr->sa_len || - bcmp(rt1->rt_ifa->ifa_addr, rt->rt_ifa->ifa_addr, - rt1->rt_ifa->ifa_addr->sa_len)) + nh = rt->rt_nhop; + nh1 = rt1->rt_nhop; + + if (nh1->gw_sa.sa_family == AF_LINK) { + if (nh1->nh_ifa->ifa_addr->sa_len != nh->nh_ifa->ifa_addr->sa_len || + bcmp(nh1->nh_ifa->ifa_addr, nh->nh_ifa->ifa_addr, + nh1->nh_ifa->ifa_addr->sa_len)) continue; } else { - if (rt1->rt_gateway->sa_len != rt->rt_gateway->sa_len || - bcmp(rt1->rt_gateway, rt->rt_gateway, - rt1->rt_gateway->sa_len)) + if (nh1->gw_sa.sa_len != nh->gw_sa.sa_len || + bcmp(&nh1->gw_sa, &nh->gw_sa, nh1->gw_sa.sa_len)) continue; } Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Wed Apr 29 21:48:52 2020 (r360477) +++ head/sys/net/route.c Wed Apr 29 21:54:09 2020 (r360478) @@ -745,8 +745,8 @@ ifa_ifwithroute(int flags, const struct sockaddr *dst, default: break; } - if (!not_found && rt->rt_ifa != NULL) { - ifa = rt->rt_ifa; + if (!not_found && rt->rt_nhop->nh_ifa != NULL) { + ifa = rt->rt_nhop->nh_ifa; } RT_REMREF(rt); RT_UNLOCK(rt); @@ -909,7 +909,7 @@ rib_lookup_info(uint32_t fibnum, const struct sockaddr if (rn != NULL && ((rn->rn_flags & RNF_ROOT) == 0)) { rt = RNTORT(rn); /* Ensure route & ifp is UP */ - if (RT_LINK_IS_UP(rt->rt_ifp)) { + if (RT_LINK_IS_UP(rt->rt_nhop->nh_ifp)) { flags = (flags & NHR_REF) | NHR_COPY; error = rt_exportinfo(rt, info, flags); RIB_RUNLOCK(rh); @@ -1064,7 +1064,8 @@ rib_walk_del(u_int fibnum, int family, rt_filter_f_t * rt_notifydelete(rt, &di.info); if (report) - rt_routemsg(RTM_DELETE, rt, rt->rt_ifp, 0, fibnum); + rt_routemsg(RTM_DELETE, rt, rt->rt_nhop->nh_ifp, 0, + fibnum); RTFREE_LOCKED(rt); } } @@ -1237,7 +1238,7 @@ rt_notifydelete(struct rtentry *rt, struct rt_addrinfo /* * give the protocol a chance to keep things in sync. */ - ifa = rt->rt_ifa; + ifa = rt->rt_nhop->nh_ifa; if (ifa != NULL && ifa->ifa_rtrequest != NULL) ifa->ifa_rtrequest(RTM_DELETE, rt, rt->rt_nhop, info); @@ -1863,7 +1864,7 @@ change_route(struct rib_head *rnh, struct rt_addrinfo info->rti_info[RTAX_GATEWAY] != NULL) || info->rti_info[RTAX_IFP] != NULL || (info->rti_info[RTAX_IFA] != NULL && - !sa_equal(info->rti_info[RTAX_IFA], rt->rt_ifa->ifa_addr))) { + !sa_equal(info->rti_info[RTAX_IFA], rt->rt_nhop->nh_ifa->ifa_addr))) { /* * XXX: Temporarily set RTF_RNH_LOCKED flag in the rti_flags * to avoid rlock in the ifa_ifwithroute(). @@ -2162,7 +2163,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi #endif error = (rn == NULL || (rn->rn_flags & RNF_ROOT) || - RNTORT(rn)->rt_ifa != ifa); + RNTORT(rn)->rt_nhop->nh_ifa != ifa); RIB_RUNLOCK(rnh); if (error) { /* this is only an error if bad on ALL tables */ Modified: head/sys/net/route/route_ddb.c ============================================================================== --- head/sys/net/route/route_ddb.c Wed Apr 29 21:48:52 2020 (r360477) +++ head/sys/net/route/route_ddb.c Wed Apr 29 21:54:09 2020 (r360478) @@ -131,18 +131,20 @@ rt_dumpentry_ddb(struct radix_node *rn, void *arg __un { struct sockaddr_storage ss; struct rtentry *rt; + struct nhop_object *nh; int flags, idx; /* If RNTORT is important, put it in a header. */ rt = (void *)rn; + nh = (struct nhop_object *)rt->rt_nhop; rt_dumpaddr_ddb("dst", rt_key(rt)); rt_dumpaddr_ddb("gateway", &rt->rt_nhop->gw_sa); rt_dumpaddr_ddb("netmask", rtsock_fix_netmask(rt_key(rt), rt_mask(rt), &ss)); - if (rt->rt_ifp != NULL && (rt->rt_ifp->if_flags & IFF_DYING) == 0) { - rt_dumpaddr_ddb("ifp", rt->rt_ifp->if_addr->ifa_addr); - rt_dumpaddr_ddb("ifa", rt->rt_ifa->ifa_addr); + if ((nh->nh_ifp->if_flags & IFF_DYING) == 0) { + rt_dumpaddr_ddb("ifp", nh->nh_ifp->if_addr->ifa_addr); + rt_dumpaddr_ddb("ifa", nh->nh_ifa->ifa_addr); } db_printf("flags "); Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Wed Apr 29 21:48:52 2020 (r360477) +++ head/sys/net/rtsock.c Wed Apr 29 21:54:09 2020 (r360478) @@ -929,7 +929,7 @@ route_output(struct mbuf *m, struct socket *so, ...) rti_need_deembed = (V_deembed_scopeid) ? 1 : 0; #endif RT_LOCK(saved_nrt); - rtm->rtm_index = saved_nrt->rt_ifp->if_index; + rtm->rtm_index = saved_nrt->rt_nhop->nh_ifp->if_index; RT_REMREF(saved_nrt); RT_UNLOCK(saved_nrt); } @@ -1714,6 +1714,7 @@ sysctl_dumpentry(struct radix_node *rn, void *vw) { struct walkarg *w = vw; struct rtentry *rt = (struct rtentry *)rn; + struct nhop_object *nh; int error = 0, size; struct rt_addrinfo info; struct sockaddr_storage ss; @@ -1730,11 +1731,12 @@ sysctl_dumpentry(struct radix_node *rn, void *vw) info.rti_info[RTAX_NETMASK] = rtsock_fix_netmask(rt_key(rt), rt_mask(rt), &ss); info.rti_info[RTAX_GENMASK] = 0; - if (rt->rt_ifp && !(rt->rt_ifp->if_flags & IFF_DYING)) { - info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr; - info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; - if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) - info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; + nh = rt->rt_nhop; + if (nh->nh_ifp && !(nh->nh_ifp->if_flags & IFF_DYING)) { + info.rti_info[RTAX_IFP] = nh->nh_ifp->if_addr->ifa_addr; + info.rti_info[RTAX_IFA] = nh->nh_ifa->ifa_addr; + if (nh->nh_ifp->if_flags & IFF_POINTOPOINT) + info.rti_info[RTAX_BRD] = nh->nh_ifa->ifa_dstaddr; } if ((error = rtsock_msg_buffer(RTM_GET, &info, w, &size)) != 0) return (error); @@ -1748,8 +1750,9 @@ sysctl_dumpentry(struct radix_node *rn, void *vw) (rt->rt_flags & ~RTF_GWFLAG_COMPAT); else rtm->rtm_flags = rt->rt_flags; + rtm->rtm_flags |= nhop_get_rtflags(nh); rt_getmetrics(rt, &rtm->rtm_rmx); - rtm->rtm_index = rt->rt_ifp->if_index; + rtm->rtm_index = nh->nh_ifp->if_index; rtm->rtm_addrs = info.rti_addrs; error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size); return (error);