From patchwork Fri Mar 1 14:39:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TGVuYSBXYW5nICjnjovlqJwp?= X-Patchwork-Id: 13578549 X-Patchwork-Delegate: kuba@kernel.org Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (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 50D1643AD8; Fri, 1 Mar 2024 14:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=210.61.82.184 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709304001; cv=fail; b=SdZkeE6Jm68Tkijskv6KaizWqbYUZIG/lLpWgjEC7hew0t36ID/zohUJ4/mMBFolrU54bAONtIFKiZeFccZ5rlzpVwsF38Hnm8X6QeYQI7Kk9DhB4xpC+SGcWfMJ4pQmWbAgK6ZelYZgHMGahZUgdZGlLEA4mbFwYThiLY7UbpE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709304001; c=relaxed/simple; bh=1wI/ZuIgWuldPl8BVCyreCquuC5I2HMyxkFNRZZXgdU=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=j1p7kryQcofiERKXH6UmrchgwuWgZdJAHns+1a+ZWuLbRfRsqVmPynANjb+KvCX7Ap8pPfa7jxlzeeXsKeu1wTe3FrfOaAgcIZPAnVKYOPWc3zmBgMPn+t+aZgymBvEIcY/7pKeIZYyFWgBgaAbKuqmABGsh9uJH+1hkreCheNs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=OBvXv7My; dkim=pass (1024-bit key) header.d=mediateko365.onmicrosoft.com header.i=@mediateko365.onmicrosoft.com header.b=MRLEbWIo; arc=fail smtp.client-ip=210.61.82.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="OBvXv7My"; dkim=pass (1024-bit key) header.d=mediateko365.onmicrosoft.com header.i=@mediateko365.onmicrosoft.com header.b="MRLEbWIo" X-UUID: 9064396cd7d911ee935d6952f98a51a9-20240301 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=MIME-Version:Content-Transfer-Encoding:Content-ID:Content-Type:Message-ID:Date:Subject:CC:To:From; bh=1wI/ZuIgWuldPl8BVCyreCquuC5I2HMyxkFNRZZXgdU=; b=OBvXv7MyLKKkkHgb3rmCiCmCJtA0NHDf8vPALabz9g/gvF41R8MyTPb3zkiMg6Ygaa/6pVERe6DK+vtKRKkhDJV4HMNZaYp9lxOvRaiafONxHI7Ns+9Ba4OrcUAWBRFf+CC3U5DZOo8ijUW2Qto2LL7QcvqXl9iH+ooQXV08v8Q=; X-CID-CACHE: Type:Local,Time:202403012239+08,HitQuantity:1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:07c51b4c-53ca-4201-b812-33a3e4d6e776,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:6f543d0,CLOUDID:7b678184-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES :1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 9064396cd7d911ee935d6952f98a51a9-20240301 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1953996615; Fri, 01 Mar 2024 22:39:52 +0800 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 1 Mar 2024 22:39:50 +0800 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (172.21.101.237) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 1 Mar 2024 22:39:50 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mZgMCDQtlS3bzNwvtP0VuP3FPNBXlYnsv7xSEEZ9oFPrrHqy7yvtkw4+eYvlSeWL7N3O9iK1etWiSjdddH9vSuE0HIMabJ3XScmRinSc09oMNZH07QfhEMIHtidd7LlX0l1z8jZGtM39W6fVegE17efNB6eJDBHuQm6X9nv29KXkVXupdEdsdl5rp+yprFDKa3sWZs1L/r5UIWC//5rJXAuVWOR57avRGtu47g97fLJAtO8eSk0+C9aKUNSYWDxV3NM7cvarbUvkSFbwHWVHcNodMiBRoKUFf18f3Kgnzuu1rqbw9AEubNmGZK4ugnkWeTIiGgwiDJHRnTj52NN03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1wI/ZuIgWuldPl8BVCyreCquuC5I2HMyxkFNRZZXgdU=; b=adsONNBFu0D0iWTOvABQIc1TPODFEOtZp3y92Iq/4qomZpBOHfcxSj1Wl3pasYX4wFgsCCKJgym9Y3srKZkAmQ+OO/bouUSuq4PKk3CTT6cElHnMexnWbsvX3vow0qKMIHB0VFhiuuLJypLG02k2KOXdUK6ZQ6uj3mH/HrfaAbRc3kb9ond9MHI7Inmp4BiFY+xgmj1mnIPRoGDbXaJx6dWf6KlapWzgOC4XNR3CU1QJTimslMbjQpBwnIxQeho8xazHxga2vV/Sl9IMbdHe+uVR+TOO8qWYy11dDGIDm5JMsORncjdz+yYbDZM7UtC1ocoQafavEc/825QGeT2cVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mediatek.com; dmarc=pass action=none header.from=mediatek.com; dkim=pass header.d=mediatek.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mediateko365.onmicrosoft.com; s=selector2-mediateko365-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1wI/ZuIgWuldPl8BVCyreCquuC5I2HMyxkFNRZZXgdU=; b=MRLEbWIoh65ku5AiHHSgbfNuZ0N1muF+/kfyRkcu2KGs5e7QHtTmyFfrDo2LO84eH/2vOnWntDtcFNVxZN0QNOr/JbGLEg4S0tIV2V82iuyr7bN4OJEruY1vWKp6Ynyf8+fHSKfPbdTv546LDTavzWeeTMbJA8V7Zi0pRkB4PqA= Received: from SI2PR03MB6463.apcprd03.prod.outlook.com (2603:1096:4:1a3::9) by SEYPR03MB6904.apcprd03.prod.outlook.com (2603:1096:101:b1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.41; Fri, 1 Mar 2024 14:39:46 +0000 Received: from SI2PR03MB6463.apcprd03.prod.outlook.com ([fe80::c74b:551:1197:a8c9]) by SI2PR03MB6463.apcprd03.prod.outlook.com ([fe80::c74b:551:1197:a8c9%5]) with mapi id 15.20.7316.039; Fri, 1 Mar 2024 14:39:46 +0000 From: =?utf-8?b?TGVuYSBXYW5nICjnjovlqJwp?= To: "kuba@kernel.org" , "davem@davemloft.net" , "edumazet@google.com" , "pabeni@redhat.com" , "jiri@resnulli.us" , "dsahern@kernel.org" CC: "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , =?utf-8?b?U2hpbWluZyBD?= =?utf-8?b?aGVuZyAo5oiQ6K+X5piOKQ==?= Subject: [PATCH net v4] ipv6: fib6_rules: flush route cache when rule is changed Thread-Topic: [PATCH net v4] ipv6: fib6_rules: flush route cache when rule is changed Thread-Index: AQHaa+ZOlmtrqOmtQEu54Vg0yp9zeQ== Date: Fri, 1 Mar 2024 14:39:46 +0000 Message-ID: <09f2ab1b7946339da5092e10aa216e07c579c60b.camel@mediatek.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mediatek.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SI2PR03MB6463:EE_|SEYPR03MB6904:EE_ x-ms-office365-filtering-correlation-id: fcf5b3e3-176f-40bc-9702-08dc39fd70d3 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: N4b+kuMGbZOc5+9+wvLlZ3M4xTOSY+pGiEq9euUOwzZjaUeUgpgA2jRUH5hjA7h6C9T7aDhX9jHIgm1xD6UD1i1zFnaW9VmqLbWwuxytOeHhG+IYZ5kbOZZBKV4PkIIe5pSGsxq6I6N1ey7IOGbQSuqjoOp+1C6/pY8SHTziMFERqEQaSsPkRAdBBv1H4Tx8ogs4FmdTXQYSHsOxKhrq0zcC/F+IrNiGBttcYR9zARhJTZqnNhqZN/ZyUW+GXVFK8ZKK6xmKPxgA0wBrINRruejmm+a6r4Vq5bQqaHAaH1vrj/LFwmIafhBuq1gAC8DwhlnplMMNur3nnmA+P9WFhMRO0DRUNOE9NZqnn1aiOsB5hG4K4Ji70j6aNvF097ZoI/ICBSf8tiETXtyGQHW4EVrYS8tPSzLcOK25NulwO3r++gsw7Zd5BpCe8f7bzyP1P5yinJt+GpEhby/rvC1GlVTuX84srI1x8Jp9WW0klZ2oiwGtjgNFdhKa8npHgwpbrfoTy9IqqeLsuV2Wuy4AKMSsCBRz25kpXYK9W4HeKI8w1JmWgWv7IR0S6fnRlDxLM27mkwG39Qsjz3izf35GhIe8HGx+a7n/ii2WkoPXdEUntnBrjf3TcxD/KrNSgkhdDQRz05213MsMemEOmkiS5r8LiG3Xykfe03CfWBZisrhkKz2bNoh9cBbQGBcAayluq5k+gH9YxcfvePVWRq7euxmjpSvox3SjpSYdv2sD/s8= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR03MB6463.apcprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?2DJB8G6e3sc0+04Dpj/ZMqYosiBS?= =?utf-8?q?hI1DaRgTk5ki/Z2fbST90IPB8K9sOGc70vrrFBHr2FZuWoZKky2hAZHOHj5XMGcD/?= =?utf-8?q?+/+z8dhFrRRkNLZx2a/mn0WNP3Bx+Cqv6RlEiw7Po9RM9rX7y1cdP7Oc9tx44TSUo?= =?utf-8?q?bOcqy/ouIme5LpUpvVcnim4BgDihIvL3oCP2aiuJMGhJTvViUedaY9ay8RxLtXa4l?= =?utf-8?q?0GtLiR9LO+E+btv98cBsG9lyv3Q+T90+cdC43VdlZRFvg591VQU6NNsQbYMF1WwL6?= =?utf-8?q?Ysdb/Dj49CiUWg+HwHS+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w7aK0jD/jeKpUQGIc2Xer/A5M+7Qbwr8kOms989Wi5a34ljDNdJjxmLrTk?= =?utf-8?q?7PRfrA/re/fUyHoFjpoSf9nLQYYLNsEcC5aUzpnvpYltHxLyVSBRuHM+VWbeJQLHT?= =?utf-8?q?RKaeBYTf0YFSNEeuKBOvHwWl+hyPIpl46obkWe3u7q/5fseveihD8VeA1YHQdF7NL?= =?utf-8?q?CETAFhYoeXkoPyRsVfF1BoKcrAMkz6u1juvpCv+jY/Adr7khLCLPKES70n3JvITML?= =?utf-8?q?UMy0bjzGtNtCFRb69175RLRbWhiNTjMtVQThWMnED9TQ36MDGuGZDK1bw+exqzEaf?= =?utf-8?q?ZU7VeiV2e9eWw8TX/+4nx1mMgyioVUckufJV7D+BMhOGJXQu/VIYSRZHhTG/cTz4D?= =?utf-8?q?rj4Ccol8C0ZjUv/LqJaBuBajfjZbXh1/LQ=3D=3D?= Content-ID: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SI2PR03MB6463.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcf5b3e3-176f-40bc-9702-08dc39fd70d3 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2024 14:39:46.2130 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a7687ede-7a6b-4ef6-bace-642f677fbe31 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Pb2Q3gIw/6uLuhAm4z09yOtG7C2vgM0fEM2lboblzqAvC67nyeBLk5BXbfsxjKrkeyJusgOPJ5SFvbBb4IL4AA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR03MB6904 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--4.350300-8.000000 X-TMASE-MatchedRID: 0WNpcueVtr5KgFU/G9flJJD6BbDN9+jOYQXxsZnRwoIXdhT0BAdFzset ivb6XlQxK5BT0yfou/uGbUz6XveLzjRLrEWBxI92T7jCYv2QJPGBHKTJ+sfXGfgnJH5vm2+gxsr 6m7RljBGi+5bTokBGbwG2ORx9Eyap0H/zLeBgX2+Sa1tNw2nFhPhs+N+bSEhBdow/ybqqTpJsKk k6TlZET7DVfJtjpo/VkZOl7WKIImrS77Co4bNJXbq9UFRTJ0kKxEHRux+uk8ifEzJ5hPndGabAl nVWE5jintGRmrM/4XxQhfyspTgOBueQr5hu0jq2aaRt/SWgFUy4iKxJ3a9x9ir8zqbLIYsuynnS /I7E9onn1Y0o3DUz8lZpsTgWmBmFE440GA1tXyvUoWT7XIVDwsFvg0QncNcfVlxr1FJij9s= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.350300-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 1DDF6867E5AF02883D6365977BDD687ABECDEC2D033356FA1B31C136D38D72532000:8 X-Patchwork-Delegate: kuba@kernel.org From: Shiming Cheng 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 Reviewed-by: Jiri Pirko --- v4: - add "Fixes:" tag. - update subject as requested. v3: - update patch description and name format in commit message. v2: - modify flush function same way as ipv4 flush cache. - use tabs to aligh with existing code. --- --- net/ipv6/fib6_rules.c | 6 ++++++ 1 file changed, 6 insertions(+) .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, diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 7523c4baef35..52c04f0ac498 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 = {