From owner-svn-src-all@freebsd.org Fri Aug 28 23:01:57 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 82B5C3C5404; Fri, 28 Aug 2020 23:01:57 +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 4BdZq92tT8z4b4V; Fri, 28 Aug 2020 23:01:57 +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 4627B1BE7E; Fri, 28 Aug 2020 23:01:57 +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 07SN1vrg003489; Fri, 28 Aug 2020 23:01:57 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 07SN1uhd003488; Fri, 28 Aug 2020 23:01:56 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <202008282301.07SN1uhd003488@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Fri, 28 Aug 2020 23:01:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r364942 - head/sys/net/route X-SVN-Group: head X-SVN-Commit-Author: melifaro X-SVN-Commit-Paths: head/sys/net/route X-SVN-Commit-Revision: 364942 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.33 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: Fri, 28 Aug 2020 23:01:57 -0000 Author: melifaro Date: Fri Aug 28 23:01:56 2020 New Revision: 364942 URL: https://svnweb.freebsd.org/changeset/base/364942 Log: Move fib_rte_to_nh_flags() from net/route_var.h to net/route/nhop_ctl.c. No functional changes. Initially this function was created to perform runtime flag conversions for the previous incarnation of fib lookup functions. As these functions got deprecated, move the function to the file with the only remaining caller. Lastly, rename it to convert_rt_to_nh_flags() to follow the naming notation. Modified: head/sys/net/route/nhop_ctl.c head/sys/net/route/route_var.h Modified: head/sys/net/route/nhop_ctl.c ============================================================================== --- head/sys/net/route/nhop_ctl.c Fri Aug 28 22:50:20 2020 (r364941) +++ head/sys/net/route/nhop_ctl.c Fri Aug 28 23:01:56 2020 (r364942) @@ -244,6 +244,21 @@ set_nhop_gw_from_info(struct nhop_object *nh, struct r return (0); } +static uint16_t +convert_rt_to_nh_flags(int rt_flags) +{ + uint16_t res; + + res = (rt_flags & RTF_REJECT) ? NHF_REJECT : 0; + res |= (rt_flags & RTF_HOST) ? NHF_HOST : 0; + res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0; + res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0; + res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0; + res |= (rt_flags & RTF_GATEWAY) ? NHF_GATEWAY : 0; + + return (res); +} + static int fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info) { @@ -258,7 +273,7 @@ fill_nhop_from_info(struct nhop_priv *nh_priv, struct nh_priv->nh_family = info->rti_info[RTAX_DST]->sa_family; nh_priv->nh_type = 0; // hook responsibility to set nhop type - nh->nh_flags = fib_rte_to_nh_flags(rt_flags); + nh->nh_flags = convert_rt_to_nh_flags(rt_flags); set_nhop_mtu_from_info(nh, info); nh->nh_ifp = info->rti_ifa->ifa_ifp; nh->nh_ifa = info->rti_ifa; @@ -397,7 +412,7 @@ alter_nhop_from_info(struct nhop_object *nh, struct rt nh->nh_priv->rt_flags |= (RTF_GATEWAY & info->rti_flags); } /* Update datapath flags */ - nh->nh_flags = fib_rte_to_nh_flags(nh->nh_priv->rt_flags); + nh->nh_flags = convert_rt_to_nh_flags(nh->nh_priv->rt_flags); if (info->rti_ifa != NULL) nh->nh_ifa = info->rti_ifa; Modified: head/sys/net/route/route_var.h ============================================================================== --- head/sys/net/route/route_var.h Fri Aug 28 22:50:20 2020 (r364941) +++ head/sys/net/route/route_var.h Fri Aug 28 23:01:56 2020 (r364942) @@ -212,22 +212,6 @@ struct rtentry { ((!NH_IS_MULTIPATH(_nh)) ? (_nh) : _SELECT_NHOP(_nh, _flowid)) #define RT_SELECT_NHOP(_rt, _flowid) _RT_SELECT_NHOP((_rt)->rt_nhop, _flowid) -/* rte<>nhop translation */ -static inline uint16_t -fib_rte_to_nh_flags(int rt_flags) -{ - uint16_t res; - - res = (rt_flags & RTF_REJECT) ? NHF_REJECT : 0; - res |= (rt_flags & RTF_HOST) ? NHF_HOST : 0; - res |= (rt_flags & RTF_BLACKHOLE) ? NHF_BLACKHOLE : 0; - res |= (rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) ? NHF_REDIRECT : 0; - res |= (rt_flags & RTF_BROADCAST) ? NHF_BROADCAST : 0; - res |= (rt_flags & RTF_GATEWAY) ? NHF_GATEWAY : 0; - - return (res); -} - /* route_temporal.c */ void tmproutes_update(struct rib_head *rnh, struct rtentry *rt); void tmproutes_init(struct rib_head *rh);