From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 063FF154430; Thu, 17 Apr 2025 18:39:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744915158; cv=none; b=RqVNq3BE/EE9hLvcF1QnuwdtsGAmRnVFp+CfbWtp1BhVzeAViLM8ODfnIfRBNKozSeqCLeZm+TSlqVSpA1vzxl4yalv/6ILN/UhteRI4uTAS6tDnehZp+npiPLP14MEGlPnMK8hz2z6esG0l/meQaYr6nnQyzk9IO8OPRdK0ziI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744915158; c=relaxed/simple; bh=mEZC15uMM7YfkIGDPjidC3c4hAqsDKZXgxQyosKI9m4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ia3utXan2uDDkBaIszyizSH4/cXdEHk6iYWJ+Egt51SDQJRQZcthddsFBSZpFivOkhksed+7ga7z7I3IXeq3UrLPDBt83ld5Ptt7ZuUOCaIQLkge9vv4JhqidKIWm081b8OcpYsJxpmE/CWkJsbGv68VQx+aGUl39ZDb+2T/6L4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gw6q/ppJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="gw6q/ppJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C0C7C4CEE4; Thu, 17 Apr 2025 18:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744915157; bh=mEZC15uMM7YfkIGDPjidC3c4hAqsDKZXgxQyosKI9m4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gw6q/ppJ6izROePiDcoyL2kigO+fW7xdA7s4S2TLwmO1cEMbLbAIoEF8smnVvuuwm 5KASfIpJI5ip2iS+hLdVSauMog2I6+7qxh0HoyxMHItfsdsypYXZxbYwWEfPqygEDx W0k6SE1FhZPyuWXrLCPbYscKFRXozKZUKSd9GPsI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Willem de Bruijn , Ido Schimmel , Willem de Bruijn , David Ahern , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.12 037/393] ipv6: Align behavior across nexthops during path selection Date: Thu, 17 Apr 2025 19:47:26 +0200 Message-ID: <20250417175109.086395890@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250417175107.546547190@linuxfoundation.org> References: <20250417175107.546547190@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ido Schimmel [ Upstream commit 6933cd4714861eea6848f18396a119d741f25fc3 ] A nexthop is only chosen when the calculated multipath hash falls in the nexthop's hash region (i.e., the hash is smaller than the nexthop's hash threshold) and when the nexthop is assigned a non-negative score by rt6_score_route(). Commit 4d0ab3a6885e ("ipv6: Start path selection from the first nexthop") introduced an unintentional difference between the first nexthop and the rest when the score is negative. When the first nexthop matches, but has a negative score, the code will currently evaluate subsequent nexthops until one is found with a non-negative score. On the other hand, when a different nexthop matches, but has a negative score, the code will fallback to the nexthop with which the selection started ('match'). Align the behavior across all nexthops and fallback to 'match' when the first nexthop matches, but has a negative score. Fixes: 3d709f69a3e7 ("ipv6: Use hash-threshold instead of modulo-N") Fixes: 4d0ab3a6885e ("ipv6: Start path selection from the first nexthop") Reported-by: Willem de Bruijn Closes: https://lore.kernel.org/netdev/67efef607bc41_1ddca82948c@willemb.c.googlers.com.notmuch/ Signed-off-by: Ido Schimmel Reviewed-by: Willem de Bruijn Reviewed-by: David Ahern Link: https://patch.msgid.link/20250408084316.243559-1-idosch@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 987492dcb07ca..bae8ece3e881e 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -470,10 +470,10 @@ void fib6_select_path(const struct net *net, struct fib6_result *res, goto out; hash = fl6->mp_hash; - if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound) && - rt6_score_route(first->fib6_nh, first->fib6_flags, oif, - strict) >= 0) { - match = first; + if (hash <= atomic_read(&first->fib6_nh->fib_nh_upper_bound)) { + if (rt6_score_route(first->fib6_nh, first->fib6_flags, oif, + strict) >= 0) + match = first; goto out; } -- 2.39.5