Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2576675lqp; Mon, 25 Mar 2024 03:15:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWxgf5pPGLnVN32/zoNLZc3xTrBWPPCb6hBrapqNh+6J/PFR8xv5YZ4Haag8XpzaXod3YYl5TZWX04SrE3/FyDUsWDDzwQ5QSCrEHFhpw== X-Google-Smtp-Source: AGHT+IFzUddCyezLuYg7fJMkhA6hvom6+h50qaOWAyb390padfSMOCKad+yxjkzgjQXycF6uS5nk X-Received: by 2002:a17:907:97c7:b0:a47:49f0:78de with SMTP id js7-20020a17090797c700b00a4749f078demr3901563ejc.73.1711361752083; Mon, 25 Mar 2024 03:15:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361752; cv=pass; d=google.com; s=arc-20160816; b=B2PwT9j98teqpLdjr1npsJ/KrPihXAXkDil5fq3tQ7JVYkLgX20UfFAMo0VB/pSzJV bnvfRvCvIhlK4yv19NfBVFpUC7brZGRn8FA+9TTQ9zWvNQNHIEFH4emjMjIKJSj3ieGv 8OxTtjOjTBX2pT0TUChFk2ONe2pRWshWgKa9Mt5839AdV4VW4A4qRuZEC8wP2JA4HQ7l WT1ndX/bx+JolFZA7UB5Hpq77EoB7wB9wI/9GzBRcB4ZxJY2D6KDbZ+cT0B9zFfcU6mb Kjqicf4UKjA5YFRoHGgqv49SKYWVqPdFNd0MiTo7cQjLPwaVqiQsFbiXBED3qwGzH5bx TZcw== 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=CfoJuOeiRwQegFw7jaDu39nKxp9csuus3sHCoF5gGtA=; fh=a40m1cIRpERCNllX3KCGlQH0a9Lw4vzrfu7HykomUeA=; b=JgHJ9P8ldMui0xQAAPhNYa3MEedEw2ieL2BAH90WbKAVW0eBS0woJVeuahH09kXM/E jJsZTw8X7hCiQ0NiSKpSp6E10uiz67M9EP7r4nZu8DnNekIDWgIJlqc9VRXktDNyOu/7 9wGLmiFuJXQtoPG4dickOliAa3mTyWKRYODQfhk4XaJyTJuNI3TzmebYdKT8Ogef1eFi TNAWhySh7cE2hHhQd3bBUjY2qyY3nm9iUHQSJb3vZROPLzAF82/r10wfJS/ic/cTrTc/ NRfb5Qlo5crT+wRO0CR2MHkfLD+CwaPzxqBOTxah1RKcR42pfDY/XOWx9gHUSo/5DZhv kFxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JaD5+qBa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g21-20020a1709061e1500b00a45ab47d3fasi2360909ejj.75.2024.03.25.03.15.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JaD5+qBa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116155-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CB7F91F32470 for ; Mon, 25 Mar 2024 10:15:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C6C92827A5; Mon, 25 Mar 2024 03:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JaD5+qBa" 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 1990117B4F2; Sun, 24 Mar 2024 23:42:00 +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=1711323720; cv=none; b=a4YvQcqHZRelowLXjJvAeZnfOCFsRG5JobvU9L3ccCHuQ97C5CCoxzhMyEY57QE0p7SuZFvQKrRRryK+/m3hJT8bW1NXqMKwQ5Z8ZHpjPfNIEmWKeuE4iiPxEre2DpCgyfIQB3nOFJhO3CGcf5X3R2Qm9e/DyHGgq2JuCrfNz0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323720; c=relaxed/simple; bh=M5igGWHTOyNDupa/8vuugdNBXY6bKFjuOK6U+k+WEVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NGLMASRq0suxidL9WUg4AkJmTA4RYekAYurHI/z+7gB9P1ZNW/gl8MD69DF65Gpl0LNaJZEED3ShbR3zvlmpJYPC9AHxKE86VAzPcmNHBKRnlVgKD5oRLKOnaY0PInGyuLS7NCBztJwdSvMSb5gxnCFu/0HG/vEJD0KD641k1M8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JaD5+qBa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27E88C41674; Sun, 24 Mar 2024 23:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323720; bh=M5igGWHTOyNDupa/8vuugdNBXY6bKFjuOK6U+k+WEVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JaD5+qBaVb3Fv1wvS7UXsEfr/qEHDjBRYXlHJkae7wb1KKIHo33+ueDn0uFvGhLWf AdtAqzjjKXOxL3xErrDW3bpzDQV7csDpifcj6zYrad5WFNZJy8NFLs3Yaqo7oCaWuu S0YwyPwO1/ybVxrfnrRuQINiLpFbKc6hsYf0gRP6EU3WJSLh5w25DYgH88SmzUl/X4 u2FYeWQNz+NQfuwBA8wSr2xoliF8/zk5fBWBeBdhg0SzO4odcOO/GXU7VbgKK3lFnG KL7tmsJOLoXsxeTzWG641M+pbyw1Yp8afbK0kbJwaPIn+99KBCFF9YOSHYrcVAktmz V4A1/GyhzUkSA== 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 5.10 093/238] ipv6: fib6_rules: flush route cache when rule is changed Date: Sun, 24 Mar 2024 19:38:01 -0400 Message-ID: <20240324234027.1354210-94-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-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 3e4c87b29b115..55cd23b7a9357 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -446,6 +446,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), @@ -458,6 +463,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, .policy = fib6_rule_policy, .owner = THIS_MODULE, -- 2.43.0