Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2543028lqp; Mon, 25 Mar 2024 01:55:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVDWkWWwY7aeeKB2slRPEWnHO/RJN+j6QZ5Jb4VSketoRoOuwRcS2J24pkEhzHA4ttxXr2VjXfdaQB5l3RIJaHME/HNhJnzJpUwFaaKUg== X-Google-Smtp-Source: AGHT+IE8TLB8c0vk5OMkA6/gOS3VcoHcx4coLeGDP3NaRvYMUexfDXCVrkd+ieMzEpidRZH+m5d8 X-Received: by 2002:a17:90a:6d24:b0:2a0:79b9:8696 with SMTP id z33-20020a17090a6d2400b002a079b98696mr520342pjj.8.1711356908461; Mon, 25 Mar 2024 01:55:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711356908; cv=pass; d=google.com; s=arc-20160816; b=gk0aHC3ko2J8EngkFogXlwjoxhVmKLuYmcP62k0n+3AI48TV8qbgztGJeReKhkUSE/ 8Zx79V+tsSiy90UKRUcGiJ0HpC9BkxvKjlEYexSepxVTlUKbLc+WTm1a8YyUQY7a0OAj lymw+xNDw1G/JF5M4dphvmwxGtbvhRHeY7wM6pUsmWzwCrhMlSOVInq13cd2VNPP+QWw HbY8WQ1HvwdUokOEiAF0Xjhfbp6Q4OidAKmm78gMqY3/vjU++YzuPsZWkfd64Uf2KTsn AslItd5FVTL3s5iALHg7FpKs9M/nDbbljDco13y79L/C97Ho6II0kNvOte+Ctzpugh4+ PpJA== 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=sgXVcOhNS6TY9kfq3vPIVOED4WFIxR1X6F7oZcUUWBg=; fh=a40m1cIRpERCNllX3KCGlQH0a9Lw4vzrfu7HykomUeA=; b=oDXps+IHrcKyK2u0pJyjTR2CUTa89CqGwDGv8lLPVwtCYkAQKxy9f8WIIAD8ecDWmW Uap5dHC8cM/9UjTRzKWXsiR/NKrwygXfiQPoe8rixrPX66nYTaHINntTixC4I2Fj/N9G vvmJklzEUlVLAGnRFLFLQrG220lKsl7SYHQ4lOlO3SBLBDfFckugDgNvrSNBzTgMZ3Ih X2f0gaotlVtGFByQaEwo0L73hsfJqxSMnGY5mkfCez+VJ8uyj7716ssFktNlvOvRBi9/ rUJnRhVKNI5TjBiPw+cI3wUu5aAXIWXXJlAnaoddkt1OVwf7IThUVTitqczk/IwC7R1Z d3yA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dGJUUAzd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115935-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ds11-20020a17090b08cb00b002a001f3f12bsi7280135pjb.36.2024.03.25.01.55.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dGJUUAzd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115935-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 A5081B2E7D2 for ; Mon, 25 Mar 2024 08:11:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD93B38E6F4; Mon, 25 Mar 2024 03:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dGJUUAzd" 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 D5DCA15ADAF; Sun, 24 Mar 2024 23:15:36 +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=1711322137; cv=none; b=RzLCRSuK8aGQdYw6sxPvWoIRLe7NxxkAr5US/nM415u4VCGpHC9ys3q+gGKLWK0Wh3ZDShNyAYmGpUPWJBIYHcxjliltZKRz8w3Dg6O+OQMaYD9PNRf7FSrY480Y0KPrHl2uzK7Am8IUH/E4brjWVXg1gxMPqnyIr14IQx/PqUY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322137; c=relaxed/simple; bh=pNcFH+ooFkIv/Gh6pWZygMrI9+wZ6KT5OyHzXrzdBTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gHNLKW9D6Ffl0cInj/mIGZe7s6C90ckPicejyT1+7j05X4UhVqhgtzR1Cw1L6Z9BcoTibLuk7wLYeunHmOHjBayZee67CTamq3Wx+o0dSOAtmOxRHbTOvAFnz6DxvJGTG7Lb19ObLtcdg/rojrUY4BoIeWO2xbXJ73wq8h97czs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dGJUUAzd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E148AC433F1; Sun, 24 Mar 2024 23:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322136; bh=pNcFH+ooFkIv/Gh6pWZygMrI9+wZ6KT5OyHzXrzdBTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dGJUUAzdMFkWyyteNhsCzKqNfrMyldmEqzu0XDFmgjfLh2LQmgp7hiFGVJxySLzKm FlQzhUpmVfWd/fIo0bx/DEVk7pY8DYUXHmYulW+PfLCJQ/RR4E/YIelVwHJYKppoa2 byIKM1tGmrKU4UYxIKC2prFlO/O1/QTJ5ErvMcs6z6ra/sMazvdO+nk+hbWJkmxwWg 2yLho7ZWBcDniN3/YQDUJI7u6wezmnM51rEBuJx/+6//O7VbapXHF44IiUPZvsT8GM l0OCkDBApzGTNljWA4TuRO/y6FrZSD0FoS1iNC51itqaAncYp3nWt6XXdDEIvN2Tv9 9GYSNspQxL+4A== 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.1 213/451] ipv6: fib6_rules: flush route cache when rule is changed Date: Sun, 24 Mar 2024 19:08:09 -0400 Message-ID: <20240324231207.1351418-214-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 7c20038330104..be52b18e08a6b 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