Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2382975lqp; Sun, 24 Mar 2024 17:00:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYoNweF2cKj72UynmRJBdZSvmphbjOr8OjhJb069cKe8UcKWEuSEJHXklF8WoBiggGn9EpjDTIWUPtkVYt86k+Bst2vsG7qaVjCZC3EQ== X-Google-Smtp-Source: AGHT+IEDjVEJOn+0hZcr8L4NqTWJtMpwDv8BSrshYKlhEk1mv2RjcNR4x+9GyuM5SZ7hyhKGagDw X-Received: by 2002:a05:6358:282:b0:178:6c79:6ccf with SMTP id w2-20020a056358028200b001786c796ccfmr6758759rwj.17.1711324844119; Sun, 24 Mar 2024 17:00:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324844; cv=pass; d=google.com; s=arc-20160816; b=cbph6wpEv37OQIQMX6gtEPdX0ec5pe2QN8P6/G7v9yU5g9NaTviYRI/YPh4+TAhhAK 3xsH/4Mxx0jEZkZya/YNIXIx/gU/LQiZVyI04lH2Wth2CvE2YW4cmwMBO7KYFc/eJHyp Y4Wg//0A8CkuY6ovT8ZxjIvatMfGTrp+aUIV6RmJMcPRwxXbNHkFmgvL/R9wB+DgZSGS ObM8Xqk6ccqXNLehBRjJ4oJ6HPgbZ2UQshPJqFMW9t0vfN6bLmSBjuIK7moLHoejE07q 7BDB5xc82R8wy3jjLTLOlYracJhD20475gasf4oN6M/mbiwHrgGXGQ5AWQTjgWyrPWqC FGpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=teCOMGBqgbSdiG2K6PA2Oa3Ip68BTZhXVr3P4umgDcE=; fh=a40m1cIRpERCNllX3KCGlQH0a9Lw4vzrfu7HykomUeA=; b=NFOuv/F85eJRclusOismJH5iYiC7p6fipTT24Dbm825HayxX7ERd1HnJ0aJ4IwgavP b1QtXiKmmN8734z9zZIp9AnRjvhrQniT1S/Y+q6oExnE/NZmysn2shiLmuH8cC3bSvS1 5teVqMEC1mVkCuq+Zj+/KqiDwX0crXGTGJV/Pjb8TukKIq/MU98Fu8SYftPsJzlEodh0 X13vjsrKcM6mAmrzyJRiobazgUOaBjPWVOoCobULn1K6ouV/GAD9yekrX3+IikeHQ8Cm sSGCVBRqF3meOpDBWs8T0idFrHb8jpte7PDFh7TDYkxZ+C+44hiTIDsVe0Yg9vxcYuhW BmeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PTc0FlSN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q37-20020a635c25000000b005cda184c281si6135480pgb.199.2024.03.24.17.00.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:00:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PTc0FlSN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113216-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 80FABB22EF6 for ; Sun, 24 Mar 2024 23:46:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C96E51802AB; Sun, 24 Mar 2024 22:40:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PTc0FlSN" 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 DFD9813C830; Sun, 24 Mar 2024 22:40:17 +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=1711320018; cv=none; b=UEhOgKao/FgvPpXZiIhSiEf62kMCYUknlP5Wb82uOIwURuGCtLPCWscM+fBdAHcAU2mWKoRIudP9rptp9x5/XBCcdxczxqIny0jgUAPx54N3wOtfL2yOPKrhh2d3mPsC4j/g8YZdXjfbkH/5f4PfSP3y2pfFHAWv7j4h5tQQuJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320018; c=relaxed/simple; bh=eH0vhInP9O3buHkVrLjIuiVn8EvjiIiqgfKW7ScCJVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=afGpopiv3GYEGnaJ3j9ltRI/3ULuh3mGfiuV/Q8Kygz6LyEMT7jRTSivNpiQ5zcxw5vM7YtTJcuRyIaPRIv0pZPdszESP914ltZmKMKTydtkhjUGi3Z5J6K1SfawIVNZs9DqQ2VLxqTBL3BgFIuQAfjsOoWK7m9w4EwFwQV2Fvs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PTc0FlSN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 938D2C433C7; Sun, 24 Mar 2024 22:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320017; bh=eH0vhInP9O3buHkVrLjIuiVn8EvjiIiqgfKW7ScCJVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PTc0FlSNYyrVKXU9FFcy4Zp9BY/vOH9yx6Pr8B90yWPYwWlkBQ2K5hBSIJQ3vmhko t4wigHqcQBEfnw/FnEhvWlBKlSqERSmdsPecadspG9w9tEQTJfvQ83xAT6vN9zR0Ds 4TcHkS1HG0G3rZPP3TytcbwA2fvxg1cbe27X2v7WSDc6ypLKMsKjAznOkhUCxRvHDk dGeXxc4+HI6IvIwurDM7KEkOtFyWJdcnw6BrVISOHPN4aMUC57wgaD5h2JK6lyypZY rEt3hxCu7AOfmm42RYLFmI0s0LTY2fM2TqTOUyBLoJI7XtGpnPFrmbXLTB2P0Dhkut 4Wo62UzDvMqYw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shiming Cheng , Lena Wang , David Ahern , "David S . Miller" , Sasha Levin Subject: [PATCH 6.8 325/715] ipv6: fib6_rules: flush route cache when rule is changed Date: Sun, 24 Mar 2024 18:28:24 -0400 Message-ID: <20240324223455.1342824-326-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Shiming Cheng [ Upstream commit c4386ab4f6c600f75fdfd21143f89bac3e625d0d ] When rule policy is changed, ipv6 socket cache is not refreshed. The sock's skb still uses a outdated route cache and was sent to a wrong interface. To avoid this error we should update fib node's version when rule is changed. Then skb's route will be reroute checked as route cache version is already different with fib node version. The route cache is refreshed to match the latest rule. Fixes: 101367c2f8c4 ("[IPV6]: Policy Routing Rules") Signed-off-by: Shiming Cheng Signed-off-by: Lena Wang Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/fib6_rules.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 7523c4baef35e..52c04f0ac4981 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -449,6 +449,11 @@ static size_t fib6_rule_nlmsg_payload(struct fib_rule *rule) + nla_total_size(16); /* src */ } +static void fib6_rule_flush_cache(struct fib_rules_ops *ops) +{ + rt_genid_bump_ipv6(ops->fro_net); +} + static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .family = AF_INET6, .rule_size = sizeof(struct fib6_rule), @@ -461,6 +466,7 @@ static const struct fib_rules_ops __net_initconst fib6_rules_ops_template = { .compare = fib6_rule_compare, .fill = fib6_rule_fill, .nlmsg_payload = fib6_rule_nlmsg_payload, + .flush_cache = fib6_rule_flush_cache, .nlgroup = RTNLGRP_IPV6_RULE, .owner = THIS_MODULE, .fro_net = &init_net, -- 2.43.0