From nobody Sat Jun 25 19:30:45 2022 X-Original-To: dev-commits-src-main@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 966738681DF; Sat, 25 Jun 2022 19:30:45 +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 4LVkc52LJtz3Q3S; Sat, 25 Jun 2022 19:30:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656185445; 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=GqIkSOWCVIJfJmbuM+zFou8GFuLErD3F8le+yWGz7vo=; b=u7X+78TYfHZwBQX6MBmO0TIQOtCVl54h+hl4vYeqMJFTqqsR1nKOSueNRtzc7O66PrY0PE X5jF7d+WEoIKYSaR9MDC07r5NqEodVD4fd1tUOBdy23VMsktKeSEYKSCZ48L5ffFE9ch9y kKvo8IWfbSJKnyDd51cM1A7Dqwb18dhnQmHXlLgMDbQZKmEIWM83+PcahedWsUft8fSHCz ZCUXKQoBY22AaGZIzqrFNI2Hu1iF6gfm0C4bSnnkYhY/L59XLNTUzy+V+p28kZhaIWFyfC wdzNnG9aALHD5d/tKsymFPrZPE+pF/HQriraNmoGoQpGoEYPbEwzwefYCLXG5w== 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 30A8E25C0; Sat, 25 Jun 2022 19:30:45 +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 25PJUjJ2039391; Sat, 25 Jun 2022 19:30:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25PJUj63039390; Sat, 25 Jun 2022 19:30:45 GMT (envelope-from git) Date: Sat, 25 Jun 2022 19:30:45 GMT Message-Id: <202206251930.25PJUj63039390@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: c38da70c28a8 - main - routing: fix RTM_CHANGE nhgroup updates. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: c38da70c28a886cc31a2f009baa79deb7fceec88 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656185445; 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=GqIkSOWCVIJfJmbuM+zFou8GFuLErD3F8le+yWGz7vo=; b=I5qNcegaUAPaIp2nHGEpo0r7DQsLr/mtoTBn/WuhRywPghpLg/n101p2FWk+9uws2DE30q POoz3r+60QUkaraMH23lMxVNyqiOz4pwp2+XmJwHxbCh4VgMtlhoiaSLeUTRCSeFs7c2Zd HFOWO3Hd9J0P6PI9/+s48ijcdbe6rYwMOIygSw7OrJHdo+vngu5G2jsdxW1KSrclS5huQk mXrQfCaZsF+gW2O37VxnZNaGB9YsmpmchLpH3gDbfLb1wg1rzmIgLAAc6mpQEysHvqTpPH 47yh5EbYH21tBnIi+zwtex8f5HpHAQJxRgmzKxOZ0UylxL0067oV8cFySLxvrw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656185445; a=rsa-sha256; cv=none; b=v4Sq1K0IOF9L/VVW0dg1dViKBx062cdupHBAPFSn7yPE43otykWnclH9QmSPZcJ5fQSRgE 3jBZNkVklWLwDhB+ZfCNUwU+y2Keuz0N3VSKVX/vIpgUw2roe/WIcAsYXciavPHkUwe0bG O118OFS8rt/LbhgU/q7t61dd+r1iMK2dgc+dRcqTXA/b1Y8svPIsDz2Xle8PlQmH0pW1cZ YqA7Ea2jVPiGt2WmQ4/tQcKSfueP/aG/2RM8e0BC6Q5UnD+vmR6xMYPGNy2WsP7DB9rkUG ieZdfGClMrTIRzl7rWU/5aIFxkVIFt1uVTIQ1yp1R9m2yXnpAmZghXyitLKuRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=c38da70c28a886cc31a2f009baa79deb7fceec88 commit c38da70c28a886cc31a2f009baa79deb7fceec88 Author: Alexander V. Chernikov AuthorDate: 2022-06-25 18:54:37 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-06-25 18:54:57 +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 --- 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 3b480c6fd6ea..80312b7c717c 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],