From nobody Mon Mar 28 09:16:02 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EE1551A41194; Mon, 28 Mar 2022 09:16:03 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KRn9v24T2z4sW1; Mon, 28 Mar 2022 09:16:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648458963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0PAxzj0WMwrNw3H+39Zme5YWN4EZf6YO0+BXck5s9iA=; b=XJSezmssCKAFyajokuRiMxswEd4ogy+h5MD3Vl8Z8gub3COjI57OE79JzGK3qj3QJNqAhZ MObAhcVverzSCNzyptrQXe8q9NQqEHcjTsHt+WenHtNtguAERVdCEzzodiS0hL9ZekDT0P t6kvI8TBIwlF6mMDnXjScQl+x+KXtaVVdYLiCKVKbUU9Npia4YE3jy4QwW6stjiOBzfN0t MPoCgj6gppM0CxHnl7qqq8WLEnMcRPfwBAGIIzd7s0HT3xBNfoDl+4HVDY+ZMdGaej3UuU k0wmy+ismYVx42PmgqLYUmzEuMKJG+bkmemWJ+BtCRGWR8d8/vWK56ortoezTw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E3C6327109; Mon, 28 Mar 2022 09:16:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22S9G2ZL087711; Mon, 28 Mar 2022 09:16:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22S9G23G087710; Mon, 28 Mar 2022 09:16:02 GMT (envelope-from git) Date: Mon, 28 Mar 2022 09:16:02 GMT Message-Id: <202203280916.22S9G23G087710@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 519bdbb448dd - stable/13 - nhops: split nh_family into nh_upper_family and nh_neigh_family. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 519bdbb448ddc176c856db14fa90d6c4ba720c8d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648458963; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0PAxzj0WMwrNw3H+39Zme5YWN4EZf6YO0+BXck5s9iA=; b=khC/1XnomDiU4FBmX246xLWRKURxZxPtf/svcgE2yOcH3LxMIwfnuYlKO4xK1GNxtT8kSg FUov7iuNGPq2lT1nhixMl8glPRZ3HFQcpY61hA2+9BxrO35t/M5PBYm3/+tL9cSdIWgt5O D71Pq4WNeENtmA1elWPb+WkJYJWl02z/CqDEiy6w8Jh04+3/O5nISs8eVbYP0AP77jx20z Dg/lv6I+fJUANq/m0P0WnRGr0MIY28zdulxBFBfHIFSYNXWbC+I/j4g5yIvu2Tu5EM//vB kjtdqNlipI7SsWQltMQQBCxcs09i1XshzlITmRg470K4iEtaVyslbnn37A25BQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648458963; a=rsa-sha256; cv=none; b=EbYBOyC/1OCWGf6AJEoLMK+20YLBfy9A95utsL9zMi5hwcRJSnHiMZzGeMdasCk0YUJnR/ VLiYSRA4fy/2ZSiZdqIQ8jE4KZVAtkxK+7A1Dbz1m3JilrYnSGd88eVyJLxowtOOd4Fw7x gQq7L2USB9skfV7zEiXjmS2b3RURgkZvLEFtjUEyZPTdRUFQSFNWbx3F1l9Zxp+qv2Q65b rkGmt4GurQlRSfaaj766fIX6gcTM3xKyMGxpzsSmUFekhdLfof2TWe1oQoCLXU1qK03mOM 5h6rvxY6Iv8Ysy1t5Ku/b8PPtxvZ/H6Q3+YkFN1VA/M20w+NQRug9WOCz9T+WA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=519bdbb448ddc176c856db14fa90d6c4ba720c8d commit 519bdbb448ddc176c856db14fa90d6c4ba720c8d Author: Alexander V. Chernikov AuthorDate: 2021-12-26 18:07:37 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-03-28 08:47:52 +0000 nhops: split nh_family into nh_upper_family and nh_neigh_family. With IPv4 over IPv6 nexthops and IP->MPLS support, there is a need to distingush "upper" e.g. traffic family and "neighbor" e.g. LLE/gateway address family. Store them explicitly in the private part of the nexthop data. While here, store nhop fibnum in nhop_prip datastructure to make it self-contained. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33663 (cherry picked from commit 823a08d7403c475fea0ecbbfff021fa8db274879) --- sys/net/route/nhop.h | 3 +++ sys/net/route/nhop_ctl.c | 60 +++++++++++++++++++++++++++++++++++++++--------- sys/net/route/nhop_var.h | 5 ++-- 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/sys/net/route/nhop.h b/sys/net/route/nhop.h index ce18cc04e163..1d37a84b68b4 100644 --- a/sys/net/route/nhop.h +++ b/sys/net/route/nhop.h @@ -179,6 +179,9 @@ enum nhop_type nhop_get_type(const struct nhop_object *nh); int nhop_get_rtflags(const struct nhop_object *nh); struct vnet *nhop_get_vnet(const struct nhop_object *nh); struct nhop_object *nhop_select_func(struct nhop_object *nh, uint32_t flowid); +int nhop_get_upper_family(const struct nhop_object *nh); +int nhop_get_neigh_family(const struct nhop_object *nh); +uint32_t nhop_get_fibnum(const struct nhop_object *nh); #endif /* _KERNEL */ diff --git a/sys/net/route/nhop_ctl.c b/sys/net/route/nhop_ctl.c index 21aefcc7a83b..45830cbb14c8 100644 --- a/sys/net/route/nhop_ctl.c +++ b/sys/net/route/nhop_ctl.c @@ -28,6 +28,7 @@ #include __FBSDID("$FreeBSD$"); #include "opt_inet.h" +#include "opt_inet6.h" #include "opt_route.h" #include @@ -58,7 +59,7 @@ __FBSDID("$FreeBSD$"); * Nexthops in the original sense are the objects containing all the necessary * information to forward the packet to the selected destination. * In particular, nexthop is defined by a combination of - * ifp, ifa, aifp, mtu, gw addr(if set), nh_type, nh_family, mask of rt_flags and + * ifp, ifa, aifp, mtu, gw addr(if set), nh_type, nh_upper_family, mask of rt_flags and * NHF_DEFAULT * * Additionally, each nexthop gets assigned its unique index (nexthop index). @@ -278,13 +279,17 @@ fill_nhop_from_info(struct nhop_priv *nh_priv, struct rt_addrinfo *info) rt_flags = info->rti_flags & NHOP_RT_FLAG_MASK; nh->nh_priv->rt_flags = rt_flags; - nh_priv->nh_family = info->rti_info[RTAX_DST]->sa_family; + nh_priv->nh_upper_family = info->rti_info[RTAX_DST]->sa_family; nh_priv->nh_type = 0; // hook responsibility to set nhop type - nh->nh_flags = convert_rt_to_nh_flags(rt_flags); + set_nhop_mtu_from_info(nh, info); if ((error = set_nhop_gw_from_info(nh, info)) != 0) return (error); + if (nh->gw_sa.sa_family == AF_LINK) + nh_priv->nh_neigh_family = nh_priv->nh_upper_family; + else + nh_priv->nh_neigh_family = nh->gw_sa.sa_family; nh->nh_ifp = (info->rti_ifp != NULL) ? info->rti_ifp : info->rti_ifa->ifa_ifp; nh->nh_ifa = info->rti_ifa; @@ -401,6 +406,7 @@ get_nhop(struct rib_head *rnh, struct rt_addrinfo *info, static int alter_nhop_from_info(struct nhop_object *nh, struct rt_addrinfo *info) { + struct nhop_priv *nh_priv = nh->nh_priv; struct sockaddr *info_gw; int error; @@ -410,8 +416,8 @@ alter_nhop_from_info(struct nhop_object *nh, struct rt_addrinfo *info) /* XXX: allow only one of BLACKHOLE,REJECT,GATEWAY */ /* Allow some flags (FLAG1,STATIC,BLACKHOLE,REJECT) to be toggled on change. */ - nh->nh_priv->rt_flags &= ~RTF_FMASK; - nh->nh_priv->rt_flags |= info->rti_flags & RTF_FMASK; + nh_priv->rt_flags &= ~RTF_FMASK; + nh_priv->rt_flags |= info->rti_flags & RTF_FMASK; /* Consider gateway change */ info_gw = info->rti_info[RTAX_GATEWAY]; @@ -419,12 +425,16 @@ alter_nhop_from_info(struct nhop_object *nh, struct rt_addrinfo *info) error = set_nhop_gw_from_info(nh, info); if (error != 0) return (error); + if (nh->gw_sa.sa_family == AF_LINK) + nh_priv->nh_neigh_family = nh_priv->nh_upper_family; + else + nh_priv->nh_neigh_family = nh->gw_sa.sa_family; /* Update RTF_GATEWAY flag status */ - nh->nh_priv->rt_flags &= ~RTF_GATEWAY; - nh->nh_priv->rt_flags |= (RTF_GATEWAY & info->rti_flags); + nh_priv->rt_flags &= ~RTF_GATEWAY; + nh_priv->rt_flags |= (RTF_GATEWAY & info->rti_flags); } /* Update datapath flags */ - nh->nh_flags = convert_rt_to_nh_flags(nh->nh_priv->rt_flags); + nh->nh_flags = convert_rt_to_nh_flags(nh_priv->rt_flags); if (info->rti_ifa != NULL) nh->nh_ifa = info->rti_ifa; @@ -458,7 +468,8 @@ nhop_create_from_nhop(struct rib_head *rnh, const struct nhop_object *nh_orig, nh = nh_priv->nh; /* Start with copying data from original nexthop */ - nh_priv->nh_family = nh_orig->nh_priv->nh_family; + nh_priv->nh_upper_family = nh_orig->nh_priv->nh_upper_family; + nh_priv->nh_neigh_family = nh_orig->nh_priv->nh_neigh_family; nh_priv->rt_flags = nh_orig->nh_priv->rt_flags; nh_priv->nh_type = nh_orig->nh_priv->nh_type; @@ -561,6 +572,8 @@ finalize_nhop(struct nh_control *ctl, struct rt_addrinfo *info, /* Please see nhop_free() comments on the initial value */ refcount_init(&nh_priv->nh_linked, 2); + nh_priv->nh_fibnum = ctl->ctl_rh->rib_fibnum; + print_nhop("FINALIZE", nh); if (link_nhop(ctl, nh_priv) == 0) { @@ -608,7 +621,7 @@ print_nhop(const char *prefix, const struct nhop_object *nh) print_nhop_sa(addr_buf, sizeof(addr_buf), &nh->gw_sa); DPRINTF("%s nhop priv %p: AF %d ifp %p %s addr %s src %p %s aifp %p %s mtu %d nh_flags %X", - prefix, nh->nh_priv, nh->nh_priv->nh_family, nh->nh_ifp, + prefix, nh->nh_priv, nh->nh_priv->nh_upper_family, nh->nh_ifp, if_name(nh->nh_ifp), addr_buf, nh->nh_ifa, src_buf, nh->nh_aifp, if_name(nh->nh_aifp), nh->nh_mtu, nh->nh_flags); } @@ -782,6 +795,31 @@ nhop_select_func(struct nhop_object *nh, uint32_t flowid) return (nhop_select(nh, flowid)); } +/* + * Returns address family of the traffic uses the nexthop. + */ +int +nhop_get_upper_family(const struct nhop_object *nh) +{ + return (nh->nh_priv->nh_upper_family); +} + +/* + * Returns address family of the LLE or gateway that is used + * to forward the traffic to. + */ +int +nhop_get_neigh_family(const struct nhop_object *nh) +{ + return (nh->nh_priv->nh_neigh_family); +} + +uint32_t +nhop_get_fibnum(const struct nhop_object *nh) +{ + return (nh->nh_priv->nh_fibnum); +} + void nhops_update_ifmtu(struct rib_head *rh, struct ifnet *ifp, uint32_t mtu) { @@ -845,7 +883,7 @@ dump_nhop_entry(struct rib_head *rh, struct nhop_object *nh, struct sysctl_req * pnhe->nh_fib = rh->rib_fibnum; pnhe->ifindex = nh->nh_ifp->if_index; pnhe->aifindex = nh->nh_aifp->if_index; - pnhe->nh_family = nh->nh_priv->nh_family; + pnhe->nh_family = nh->nh_priv->nh_upper_family; pnhe->nh_type = nh->nh_priv->nh_type; pnhe->nh_mtu = nh->nh_mtu; pnhe->nh_flags = nh->nh_flags; diff --git a/sys/net/route/nhop_var.h b/sys/net/route/nhop_var.h index 76984df0497f..facf8a7a546b 100644 --- a/sys/net/route/nhop_var.h +++ b/sys/net/route/nhop_var.h @@ -74,12 +74,13 @@ struct nh_control { struct nhop_object; struct nhop_priv { /* nhop lookup comparison start */ - uint8_t nh_family; /* address family of the lookup */ - uint8_t spare; + uint8_t nh_upper_family;/* address family of the lookup */ + uint8_t nh_neigh_family;/* neighbor address family */ uint16_t nh_type; /* nexthop type */ uint32_t rt_flags; /* routing flags for the control plane */ /* nhop lookup comparison end */ uint32_t nh_idx; /* nexthop index */ + uint32_t nh_fibnum; /* nexthop fib */ void *cb_func; /* function handling additional rewrite caps */ u_int nh_refcnt; /* number of references, refcount(9) */ u_int nh_linked; /* refcount(9), == 2 if linked to the list */