From nobody Fri Jan 13 21:24:57 2023 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 4NtvZd75Kfz2qklR; Fri, 13 Jan 2023 21:24:57 +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 4NtvZd6Qq2z4174; Fri, 13 Jan 2023 21:24:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645097; 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=6B8EPyr6FXJ1VvY0ypENvIh9MXsVIJJRGlkb3sUmyic=; b=vzVn1xVjRmWNlrOA1/yiehfsOiY52CMgWMz6SWsU89y0GL4Khw+ltP8glU/phaDTBszJUh d1lkINSgAMgIE29rLHkoA7dCAp1wNu7a+f727axGLPa1OMUhpXvHNooAWBntndi/Zijr+W bfevCiK2xWaoSYq3bE6mZE0xg/q4YveI6TlhNX1mfFgBP3GGELb5dPMT3B5dgNpyZXjkDy S1T4ETn2dXtJuiHphKKfP6gwPmhibSQRIV6e2A92QYXjhLnxBLr0OaIf0HyWp+l2Gyevu6 MmPJEAE1MA+K9xfIxfYuHdhONt9DLuq3hzgOGYVOW8oLQFKGCXeG/BrbKyonFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645097; 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=6B8EPyr6FXJ1VvY0ypENvIh9MXsVIJJRGlkb3sUmyic=; b=kHuU5NwU/mDwrCc5Oj4E2hwLQMqTFoOVqs7DLjW0Ux/Q/RicFfBBksUPdiBREdGyeDMWxZ Yi7kjoubLgSX4VERIJJe5mQxsuQ69cauAP6Jg7nYTgQxY4ykzh0aQ8NaqiqnHwkcBYwS9d L3PECjWrzrkvDVKMR9Us3sGD08Yx6cOBUbQoLUajBkA5uxiMAhyLNA+DYkFw0GoPYV9Bsg RA/sA9CqxL+B9N6poNfYdxDFPcsutWjafQoBvW7mkuHH/QipX4435Sluy8wjFmCGEQBnil Mz/yfZMCukMiQudMlK10q37PVlJOh4sYiRDv3guFQfadf7o5NfWSiM1ouYKFpA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673645097; a=rsa-sha256; cv=none; b=PobkUkEDUY3k9063ZEM0Fdqv4xFjrxVR1+bcDUJQTXdftLDWhE0Cct8a5AIWa/frltoHCc lIzT85Bmx8IuPguDyGKBhU7JZ+/vS1yxlXpWtJDoTFiboH+gk2/Kzny/4+PFX7ujPAq2VO JBPZ+R7jz4KaxXau1+VRzo0iuoK1zOV3MO8KtvBMEtbjdqWOkJyIfKYi43ZA7mrfnHOupe NFdPlmQRGEZXci+Xs+AX4j9Y0QK6oW4Bx8ia/yPiH/v2ArXAX5AEFjS27hAVd9ZOgRTbd4 Hz21jKk7wplBzuI1o/wupEX2Qy44Prc35NXLhApYQlzh0VnkdA2m/Ry6uT34Zw== 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 4NtvZd5PptzNDC; Fri, 13 Jan 2023 21:24:57 +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 30DLOviM041174; Fri, 13 Jan 2023 21:24:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DLOv67041173; Fri, 13 Jan 2023 21:24:57 GMT (envelope-from git) Date: Fri, 13 Jan 2023 21:24:57 GMT Message-Id: <202301132124.30DLOv67041173@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: ba1ab2e5cf95 - stable/13 - routing: refactor private KPI * Make nhgrp_get_nhops() return const struct weightened_nhop to indicate that the list is immutable * Make nhgrp_get_group() return the actual group, instead of group+weight. 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: ba1ab2e5cf951906ceb85a4197c30b094507b280 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=ba1ab2e5cf951906ceb85a4197c30b094507b280 commit ba1ab2e5cf951906ceb85a4197c30b094507b280 Author: Alexander V. Chernikov AuthorDate: 2022-08-01 10:02:12 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-01-13 21:18:26 +0000 routing: refactor private KPI * Make nhgrp_get_nhops() return const struct weightened_nhop to indicate that the list is immutable * Make nhgrp_get_group() return the actual group, instead of group+weight. MFC after: 2 weeks (cherry picked from commit ae6bfd12c8c887b323d623c6c21d29f25622d42d) --- sys/net/route/nhgrp_ctl.c | 13 ++++++------- sys/net/route/route_ctl.c | 11 ++++++----- sys/net/route/route_ctl.h | 2 +- sys/net/route/route_helpers.c | 4 ++-- sys/net/route/route_var.h | 2 +- sys/net/rtsock.c | 4 ++-- sys/netinet/in_fib.c | 2 +- sys/netinet6/in6_fib.c | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/sys/net/route/nhgrp_ctl.c b/sys/net/route/nhgrp_ctl.c index bad237a334ef..f0b26916136c 100644 --- a/sys/net/route/nhgrp_ctl.c +++ b/sys/net/route/nhgrp_ctl.c @@ -598,7 +598,7 @@ append_nhops(struct nh_control *ctl, const struct nhgrp_object *gr_orig, */ int nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn, int num_nhops, - struct route_nhop_data *rnd) + struct nhgrp_object **pnhg) { struct nh_control *ctl = rh->nh_control; struct nhgrp_priv *nhg_priv; @@ -606,8 +606,7 @@ nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn, int num_nhops, nhg_priv = get_nhgrp(ctl, wn, num_nhops, &error); if (nhg_priv != NULL) - rnd->rnd_nhgrp = nhg_priv->nhg; - rnd->rnd_weight = 0; + *pnhg = nhg_priv->nhg; return (error); } @@ -718,14 +717,14 @@ nhgrp_get_addition_group(struct rib_head *rh, struct route_nhop_data *rnd_orig, * Returns pointer to array of nexthops with weights for * given @nhg. Stores number of items in the array into @pnum_nhops. */ -struct weightened_nhop * -nhgrp_get_nhops(struct nhgrp_object *nhg, uint32_t *pnum_nhops) +const struct weightened_nhop * +nhgrp_get_nhops(const struct nhgrp_object *nhg, uint32_t *pnum_nhops) { - struct nhgrp_priv *nhg_priv; + const struct nhgrp_priv *nhg_priv; KASSERT(((nhg->nhg_flags & MPF_MULTIPATH) != 0), ("nhop is not mpath")); - nhg_priv = NHGRP_PRIV(nhg); + nhg_priv = NHGRP_PRIV_CONST(nhg); *pnum_nhops = nhg_priv->nhg_nh_count; return (nhg_priv->nhg_nh_weights); diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c index 80682b7f3b87..394260e1421c 100644 --- a/sys/net/route/route_ctl.c +++ b/sys/net/route/route_ctl.c @@ -155,7 +155,7 @@ destroy_rtentry(struct rtentry *rt) */ #ifdef ROUTE_MPATH if (NH_IS_NHGRP(nh)) { - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops); nh = wn[0].nh; @@ -1010,8 +1010,9 @@ change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info, { int error = 0, found_idx = 0; struct nhop_object *nh_orig = NULL, *nh_new; - struct route_nhop_data rnd_new; - struct weightened_nhop *wn = NULL, *wn_new; + struct route_nhop_data rnd_new = {}; + const struct weightened_nhop *wn = NULL; + struct weightened_nhop *wn_new; uint32_t num_nhops; wn = nhgrp_get_nhops(rnd_orig->rnd_nhgrp, &num_nhops); @@ -1041,7 +1042,7 @@ change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info, wn_new[found_idx].nh = nh_new; wn_new[found_idx].weight = get_info_weight(info, wn[found_idx].weight); - error = nhgrp_get_group(rnh, wn_new, num_nhops, &rnd_new); + error = nhgrp_get_group(rnh, wn_new, num_nhops, &rnd_new.rnd_nhgrp); nhop_free(nh_new); free(wn_new, M_TEMP); @@ -1375,7 +1376,7 @@ rib_walk_del(u_int fibnum, int family, rib_filter_f_t *filter_f, void *arg, bool if (report) { #ifdef ROUTE_MPATH struct nhgrp_object *nhg; - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; if (NH_IS_NHGRP(nh)) { nhg = (struct nhgrp_object *)nh; diff --git a/sys/net/route/route_ctl.h b/sys/net/route/route_ctl.h index a670979df8c9..7a1f7f04be9b 100644 --- a/sys/net/route/route_ctl.h +++ b/sys/net/route/route_ctl.h @@ -135,7 +135,7 @@ uint32_t nhops_get_count(struct rib_head *rh); /* Multipath */ struct weightened_nhop; -struct weightened_nhop *nhgrp_get_nhops(struct nhgrp_object *nhg, +const struct weightened_nhop *nhgrp_get_nhops(const struct nhgrp_object *nhg, uint32_t *pnum_nhops); uint32_t nhgrp_get_count(struct rib_head *rh); diff --git a/sys/net/route/route_helpers.c b/sys/net/route/route_helpers.c index 6c7f16eb047e..5472465d4f5f 100644 --- a/sys/net/route/route_helpers.c +++ b/sys/net/route/route_helpers.c @@ -290,7 +290,7 @@ decompose_change_notification(struct rib_cmd_info *rc, route_notification_t *cb, void *cbdata) { uint32_t num_old, num_new; - struct weightened_nhop *wn_old, *wn_new; + const struct weightened_nhop *wn_old, *wn_new; struct weightened_nhop tmp = { NULL, 0 }; uint32_t idx_old = 0, idx_new = 0; @@ -378,7 +378,7 @@ void rib_decompose_notification(struct rib_cmd_info *rc, route_notification_t *cb, void *cbdata) { - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; struct rib_cmd_info rc_new; diff --git a/sys/net/route/route_var.h b/sys/net/route/route_var.h index e54ea08f4e80..403e432ea836 100644 --- a/sys/net/route/route_var.h +++ b/sys/net/route/route_var.h @@ -295,7 +295,7 @@ void nhgrp_ctl_unlink_all(struct nh_control *ctl); int nhgrp_dump_sysctl(struct rib_head *rh, struct sysctl_req *w); int nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn, - int num_nhops, struct route_nhop_data *rnd); + int num_nhops, struct nhgrp_object **pnhg); typedef bool nhgrp_filter_cb_t(const struct nhop_object *nh, void *data); int nhgrp_get_filtered_group(struct rib_head *rh, const struct nhgrp_object *src, nhgrp_filter_cb_t flt_func, void *flt_data, struct route_nhop_data *rnd); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index b116319d96d6..6826b4e82368 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -721,7 +721,7 @@ select_nhop(struct nhop_object *nh, const struct sockaddr *gw) if (!NH_IS_NHGRP(nh)) return (nh); #ifdef ROUTE_MPATH - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops); if (gw == NULL) @@ -2243,7 +2243,7 @@ sysctl_dumpentry(struct rtentry *rt, void *vw) nh = rt_get_raw_nhop(rt); #ifdef ROUTE_MPATH if (NH_IS_NHGRP(nh)) { - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; int error; wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops); diff --git a/sys/netinet/in_fib.c b/sys/netinet/in_fib.c index 8a6e64876b3d..957262fc70b9 100644 --- a/sys/netinet/in_fib.c +++ b/sys/netinet/in_fib.c @@ -196,7 +196,7 @@ check_urpf(struct nhop_object *nh, uint32_t flags, { #ifdef ROUTE_MPATH if (NH_IS_NHGRP(nh)) { - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops); for (int i = 0; i < num_nhops; i++) { diff --git a/sys/netinet6/in6_fib.c b/sys/netinet6/in6_fib.c index 614f8111409a..8a0760aff02a 100644 --- a/sys/netinet6/in6_fib.c +++ b/sys/netinet6/in6_fib.c @@ -205,7 +205,7 @@ check_urpf(struct nhop_object *nh, uint32_t flags, { #ifdef ROUTE_MPATH if (NH_IS_NHGRP(nh)) { - struct weightened_nhop *wn; + const struct weightened_nhop *wn; uint32_t num_nhops; wn = nhgrp_get_nhops((struct nhgrp_object *)nh, &num_nhops); for (int i = 0; i < num_nhops; i++) {