From nobody Fri Jan 13 21:24:44 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 4NtvZN6kN8z2qkS9; Fri, 13 Jan 2023 21:24:44 +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 4NtvZN3SP6z40FL; Fri, 13 Jan 2023 21:24:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645084; 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=VwFNjJvxzuKExWXWfLubqbdSkB21Hr8f/Cj3PZoXv+Q=; b=uwoyxax9ouGqVz/Gz+MjThoqf8tnL2leAh8EM/ksJbrfo8AAdNZ/bxNEbXTfLyIPnlxhtk ODUTajB6fwjMd5DLK+B2eG1EGrWH+MXqzjeC1neJ5v/GM0WWjdfpHsB9GtDTkeJ267j3Zj f3JcE5jeEwk6q5msaf9nrmAx7OWYPFWsTvxL0w4Yjfa9FeXEHQnaV+U1JUwkSLpY9ojpcG t/SHkPAzZ0gbGWAanX3qIEEpsUAVmeu+F4iwiBJJwN2S7mE5S8PI1QEEjBKTxQ3HSGYPSB 8F6oqJn5/RN1fnHHpla30X0mH/jdJYpkavmqKeYRI8oqykWDma2Ha3nEpSxMNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673645084; 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=VwFNjJvxzuKExWXWfLubqbdSkB21Hr8f/Cj3PZoXv+Q=; b=vX/zyLt0W/j61iMsut1PPPN89vZeWNQHQvwmtNF4t4ma7h2tYlHSgF5jGb0Vg3Cf3ibL5j D4wnpW4XduLQt2i+HMjz5miELIeWPjZc33T+lnKqZJvs3HDoZhhAGLpbylry+j76y8VTpE msza4jK3sJvu/JqZUtT8Pf1DJeWI0QroURPXkLP4L3mYlzE1DJr5HMPdqOI9yiNOQY4v6C v36DtXIzeuoiT9QC4/skpPNIgpFA1pMaiLzaSObqZHpEQlxySqkoTtHkvJgymwNpss7vIf b061msq8z50WMT+3gl7wRyuB7UvLy0whF+eoV7njzjcyNFRwK3Bn2AdproiX/w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673645084; a=rsa-sha256; cv=none; b=NUDrEucbJE145xt5GsFb8wsOCyTlZPT6llBp4fh9hbaswNFmaI/Mer5nPrZ+oILiKQRgvx m61+UYv8aF7zp5Zm/lhzpQ9+T2XWXZaLbS4mHOjOZAkugQ1zrD3Pq3LTfb4MnddVT9GxuC NcpXbjcqzf3Ts/qB6PtvMq1yvyuoj6ek2giPyqc7OH+lea3wHHhMxST4Nwl/6yVTmCOz9y XcmpGhUMdKRJ57icSNag9dljYvcJw4zw3Z47sMJ598ltvXjddVTrPJGJZrTna1Xlnl8puq qSwzXbW4MIfs6JCHIfvzFxW7tuOFgoNW/u4zutlwn51h6ADWetSsvYIm/0qfhg== 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 4NtvZN2Hb0zND7; Fri, 13 Jan 2023 21:24:44 +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 30DLOiQD040553; Fri, 13 Jan 2023 21:24:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DLOiKu040552; Fri, 13 Jan 2023 21:24:44 GMT (envelope-from git) Date: Fri, 13 Jan 2023 21:24:44 GMT Message-Id: <202301132124.30DLOiKu040552@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: ede90c997743 - stable/13 - routing: fix RTM_CHANGE nhgroup updates. 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: ede90c99774338479be58e88e9bce800f54bf12b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=ede90c99774338479be58e88e9bce800f54bf12b commit ede90c99774338479be58e88e9bce800f54bf12b Author: Alexander V. Chernikov AuthorDate: 2022-06-25 18:54:37 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-01-13 21:18:25 +0000 routing: fix RTM_CHANGE nhgroup updates. RTM_CHANGE operates on a single component of the multipath route (e.g. on a single nexthop). Search of this nexthop is peformed by iterating over each component from multipath (nexthop) group, using check_info_match_nhop. The problem with the current code that it incorrectly assumes that `check_info_match_nhop()` returns true value on match, while in reality it returns an error code on failure). Fix this by properly comparing the result with 0. Additionally, the followup code modified original necthop group instead of a new one. Fix this by targetting new nexthop group instead. Reported by: thj Tested by: Claudio Jeker Differential Revision: https://reviews.freebsd.org/D35526 MFC after: 2 weeks (cherry picked from commit c38da70c28a886cc31a2f009baa79deb7fceec88) --- sys/net/route/route_ctl.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c index afe0a024b832..8a61db449462 100644 --- a/sys/net/route/route_ctl.c +++ b/sys/net/route/route_ctl.c @@ -57,6 +57,11 @@ __FBSDID("$FreeBSD$"); #include +#define DEBUG_MOD_NAME route_ctl +#define DEBUG_MAX_LEVEL LOG_DEBUG +#include +_DECLARE_DEBUG(LOG_INFO); + /* * This file contains control plane routing tables functions. * @@ -999,18 +1004,17 @@ static int change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info, struct route_nhop_data *rnd_orig, struct rib_cmd_info *rc) { - int error = 0; - struct nhop_object *nh_orig, *nh_new; + 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; uint32_t num_nhops; - nh_orig = rnd_orig->rnd_nhop; - wn = nhgrp_get_nhops((struct nhgrp_object *)nh_orig, &num_nhops); - nh_orig = NULL; + wn = nhgrp_get_nhops(rnd_orig->rnd_nhgrp, &num_nhops); for (int i = 0; i < num_nhops; i++) { - if (check_info_match_nhop(info, NULL, wn[i].nh)) { + if (check_info_match_nhop(info, NULL, wn[i].nh) == 0) { nh_orig = wn[i].nh; + found_idx = i; break; } } @@ -1030,13 +1034,8 @@ change_mpath_route(struct rib_head *rnh, struct rt_addrinfo *info, } memcpy(wn_new, wn, num_nhops * sizeof(struct weightened_nhop)); - for (int i = 0; i < num_nhops; i++) { - if (wn[i].nh == nh_orig) { - wn[i].nh = nh_new; - wn[i].weight = get_info_weight(info, rnd_orig->rnd_weight); - break; - } - } + 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); nhop_free(nh_new); @@ -1188,6 +1187,15 @@ change_route_conditional(struct rib_head *rnh, struct rtentry *rt, struct rtentry *rt_new; int error = 0; +#if DEBUG_MAX_LEVEL >= LOG_DEBUG2 + { + char buf_old[NHOP_PRINT_BUFSIZE], buf_new[NHOP_PRINT_BUFSIZE]; + nhop_print_buf_any(rnd_orig->rnd_nhop, buf_old, NHOP_PRINT_BUFSIZE); + nhop_print_buf_any(rnd_new->rnd_nhop, buf_new, NHOP_PRINT_BUFSIZE); + FIB_LOG(LOG_DEBUG2, rnh->rib_fibnum, rnh->rib_family, + "trying change %s -> %s", buf_old, buf_new); + } +#endif RIB_WLOCK(rnh); rt_new = (struct rtentry *)rnh->rnh_lookup(info->rti_info[RTAX_DST],