From nobody Wed Nov 13 21:03:58 2024 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 4XpbPC1LmWz5cb2W; Wed, 13 Nov 2024 21:03:59 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XpbPC0Xfpz4P6Y; Wed, 13 Nov 2024 21:03:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731531839; 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=wYPUXh0lrec0K0iY4ga38dPDGwcbDVFa8OqJBlPcMRQ=; b=JshWtNC8gelvhwk+j4U7klRpvtgc2zEm0umbAJb8C4nYMSlT4Cme9Uzz5uIiYu5YBortzF FIeqCOVeAZm6w6fNOOD63D0ANB/N8VcDNZgakX94Gv9EpIf1eGCRl2LlY5p7ID4s9OE1OK j12g/0YR+H3QMT17JZPnMBIhCWfyomsuqU1QmuCQy9RUb2+Lif/VVDM+qsVQ5h/5KzNjVK TR4kqfyFuPSkJ9x3H4C228EPFGzw24gP0mD7rcUQNGL5Xn5giRPGnZJyHxwInHdHRx7nvo 9bNPbariP2N84S7VCPjAjGOowQ8uGs9v5c195DzPX0DdBrz9EDZHDEiE4M6tMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731531839; 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=wYPUXh0lrec0K0iY4ga38dPDGwcbDVFa8OqJBlPcMRQ=; b=ZtV/OqEl+hBNSlGN46FWL/BvVTTc23MFLDUsAm9hegIHbqefVmfIorCpKH5wR8lzVWwN17 QW81j2EbLa9ZSfZVY2Hv3vqLZ8Thm1dVrMGcSHNNzuFvn5cprlzPmvsNp+KH9c4wguT2sM B6gRdge8D6lgJ3QGQEBJLqdHT/D4osRJqxTGaBZ63I7lG06GX7eazRpCyng2RY94jLni5+ g/i9Wo6m1DjZ/8yP2ntF6lTpayzHOI8/nQq+DmWl24ZtlGcANp5sPDoCYaWHGJIgnUlxA4 88cxjAukOji7buYOKjHg3Cx/ZdYfvpl7p4x356owLVbM0Jsb/BQ4b15PeJv94A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731531839; a=rsa-sha256; cv=none; b=xeJLd3FCnb26jLAgRfS1vJjeZDwUYI/Q7mP2eWS3x3s0qFyLXx/Z0s/o3cH9GVebj+IRMH Peec9nGj2y2t7Kfc+XcydqBgPxlxzqSECCf3Kb6ncEHpRyKP3qXse4CHOJURmQhne6HwsR ZINylrPEbS3xW3M+JLBc54MLNAhVgBnTw5EbaC1kuFqSILPHdu+Ryr11lNEB+3H0pikfjX UMSdF3949VobGqA6kt1IgA77efnX5cNVAHZ9CZ/beUjyhD9oe3kkjTfS1Qu0c15M4NsJ06 4Qy3hEv1pOxTkf9xX2ADIVBZStk1k93Mj/jg5sxGaWzrjTRh4X5H2j/b9TardQ== 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 4XpbPC05Ltz1939; Wed, 13 Nov 2024 21:03:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4ADL3wTS018675; Wed, 13 Nov 2024 21:03:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ADL3wng018672; Wed, 13 Nov 2024 21:03:58 GMT (envelope-from git) Date: Wed, 13 Nov 2024 21:03:58 GMT Message-Id: <202411132103.4ADL3wng018672@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: 1da4954c92ea - main - Fix failure to add an interface prefix route when route with the same prefix is already presented in the routing table. 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 1da4954c92ea7585b352ba830d3ee64ca69ada52 Auto-Submitted: auto-generated The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=1da4954c92ea7585b352ba830d3ee64ca69ada52 commit 1da4954c92ea7585b352ba830d3ee64ca69ada52 Author: Alexander V. Chernikov AuthorDate: 2024-11-12 23:36:50 +0000 Commit: Alexander V. Chernikov CommitDate: 2024-11-12 23:36:50 +0000 Fix failure to add an interface prefix route when route with the same prefix is already presented in the routing table. PR: 277125 Reported by: Oleksandr Ignatyev Reviewed by: ae, jlduran Tested by: jlduran Differential Revision: https://reviews.freebsd.org/D47534 MFC after: 2 weeks --- sys/net/route/route_ctl.c | 13 ++++++++----- sys/net/route/route_ctl.h | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c index a07a58737c1c..d7756f2a0eb6 100644 --- a/sys/net/route/route_ctl.c +++ b/sys/net/route/route_ctl.c @@ -772,12 +772,15 @@ add_route_byinfo(struct rib_head *rnh, struct rt_addrinfo *info, rnd_add.rnd_weight = get_info_weight(info, RT_DEFAULT_WEIGHT); int op_flags = RTM_F_CREATE; - if (get_prio_from_info(info) == NH_PRIORITY_HIGH) - op_flags |= RTM_F_FORCE; - else - op_flags |= RTM_F_APPEND; - return (add_route_flags(rnh, rt, &rnd_add, op_flags, rc)); + /* + * Set the desired action when the route already exists: + * If RTF_PINNED is present, assume the direct kernel routes that cannot be multipath. + * Otherwise, append the path. + */ + op_flags |= (info->rti_flags & RTF_PINNED) ? RTM_F_REPLACE : RTM_F_APPEND; + + return (add_route_flags(rnh, rt, &rnd_add, op_flags, rc)); } static int diff --git a/sys/net/route/route_ctl.h b/sys/net/route/route_ctl.h index 140f14aa9e4f..845df8ce1fbe 100644 --- a/sys/net/route/route_ctl.h +++ b/sys/net/route/route_ctl.h @@ -61,11 +61,11 @@ int rib_del_route_px_gw(uint32_t fibnum, struct sockaddr *dst, int plen, const struct sockaddr *gw, int op_flags, struct rib_cmd_info *rc); /* operation flags */ -#define RTM_F_CREATE 0x01 -#define RTM_F_EXCL 0x02 -#define RTM_F_REPLACE 0x04 -#define RTM_F_APPEND 0x08 -#define RTM_F_FORCE 0x10 +#define RTM_F_CREATE 0x01 /* Create object if not exists */ +#define RTM_F_EXCL 0x02 /* (Deprecated) Do not replace or append if exists */ +#define RTM_F_REPLACE 0x04 /* Replace if route (even multipath) if exists */ +#define RTM_F_APPEND 0x08 /* Append path to the route */ +#define RTM_F_FORCE 0x10 /* Bump operation priority to highest */ int rib_add_route(uint32_t fibnum, struct rt_addrinfo *info, struct rib_cmd_info *rc);