From patchwork Wed Feb 28 15:38:56 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: 13575723 X-Patchwork-Delegate: kuba@kernel.org Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (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 2A6F41487DC; Wed, 28 Feb 2024 15:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=60.244.123.138 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709134756; cv=fail; b=Ic8wt5LBLRJ2DWt8JJr59vBTxGnimwLCEjvVkgvj2jEXZo929Npr5M0R7yTlNLeFp/fp4CQkDwlZwnABZORQ0QVBSXIgUoP7T8ZBzCuNMs3A7EV2E/6NdDrMpt3Pk94VcPfJxgPk4llP9QPGnCsWVIFyepM+DFcDYwUvYcvs7xc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709134756; c=relaxed/simple; bh=UXxUNaLGSROf2xTrnRKTB5pxoI6VbYtFN8L6JrOJBRQ=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=hOLd11eYWyvSIme0TQuIHaQm+KdGsYq8OfeiAgyvYOBKHY2XElkp7cMg0/tNey3z6CXfQgA+DxRpY+7zxvs2HX+MtXgc2qxg5+EyDFrGykPOfKJ0fB9bNMCprtIIFHS+jzFwuvl4akMmq1bml9qNrerSIYf2DPF7CvROySWcEs0= 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=USpv8WmN; dkim=pass (1024-bit key) header.d=mediateko365.onmicrosoft.com header.i=@mediateko365.onmicrosoft.com header.b=BZ4kkfcY; arc=fail smtp.client-ip=60.244.123.138 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="USpv8WmN"; dkim=pass (1024-bit key) header.d=mediateko365.onmicrosoft.com header.i=@mediateko365.onmicrosoft.com header.b="BZ4kkfcY" X-UUID: 7e4db054d64f11eeb8927bc1f75efef4-20240228 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=UXxUNaLGSROf2xTrnRKTB5pxoI6VbYtFN8L6JrOJBRQ=; b=USpv8WmNhC9TrSt6Cn7uWhg6XjLaOBKo+LBFS55bq6KyyhHHCQyavwUKwY+pnWY4MzFU57fxGkm5t7V0QW7286TlTHiorEFA9bd49CYOGa6aJl98CuAo2fADBuk9fdSN9/Rmq/7mdoc4KbrTWV6l1eSp2K7XUiEOWgge3VvmYBs=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.37,REQID:797efcf4-94ec-40f7-ba8c-04804dcad735,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:c06cd08f-e2c0-40b0-a8fe-7c7e47299109,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: 7e4db054d64f11eeb8927bc1f75efef4-20240228 Received: from mtkmbs14n1.mediatek.inc [(172.21.101.75)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2061893283; Wed, 28 Feb 2024 23:39:00 +0800 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 28 Feb 2024 23:38:59 +0800 Received: from APC01-SG2-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; Wed, 28 Feb 2024 23:38:59 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UDLcarmWxEFsxI/qlR1FgCfk2DxzjanqU1ImdT2Kf1hwu8J7LmkSLVEn3cKrGW9jGT4JcIjoFQW8QavZ8El11twdx0oZdXrcwqGqb1yHKntRRK+iTBB49lx0nmmq/hirQ6r23SRsRFw3yoI9XZyHPnaiOLPkmvUoEJjO7s62eS+nSQRakkt/FpiE+/tAhOvsf6J7ZH0XLjC1JvJauso93C9fNAJLwGvZTcFJ1+5RXPv/ES/XTKXFisVoUqnYtS7Syl5g81wXAyjvdMs/LeXrABaWtjylDivGCTxuKCIMr8mJCmve6LWIBaY1GezCHMmCeLqr6CFHny85i8t9oM9fwg== 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=UXxUNaLGSROf2xTrnRKTB5pxoI6VbYtFN8L6JrOJBRQ=; b=U2U6DezO5iggoSzYt6IjRLIkY1mstTM6PB2+lEcVfyoGUnSHOF6aJfUfBqhGziNGqNfXIV+yK3vQat5fmBTiCyhmaWpsaDb0mW5xDi8Hr1YsdP8PQiUXibWhGjSr08S5w9I88OxRnTNebcGJ8dh/N2/PT5z1+Z2dplRKSAV9pv9fM68oo4X9d7NdBdLNwisYkY9IoxdgBrgcEvFHuCl4o6+c1J2xt5brV9Io03CBCEp/FSA846U7nbGwWW0hXSc+e6sDBB5tTFStW24pf8EjK8lTEzaKFXFd7YB4pKc6HTF0TlEEgvEYrdOI3WBYcyULcwUFJgjCFDaQO2PivCsT8A== 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=UXxUNaLGSROf2xTrnRKTB5pxoI6VbYtFN8L6JrOJBRQ=; b=BZ4kkfcYtzeiTeXhy9u0swawq/uMhpldeMtCW7x9tSJrNk3j7RITuPUILnw9PxBjW0zhvAgaIo0Qs3Ca6Mf1soMBb9dtRQH7gX3YDUdklxxjtpEo+CpgxBEaSLxqNelav3V7m3E1polULWYqoTrwmckDOoAPyEkh/6/Bp1MTKRU= Received: from SEZPR03MB6466.apcprd03.prod.outlook.com (2603:1096:101:4a::8) by TYZPR03MB8560.apcprd03.prod.outlook.com (2603:1096:405:68::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Wed, 28 Feb 2024 15:38:57 +0000 Received: from SEZPR03MB6466.apcprd03.prod.outlook.com ([fe80::8814:cbff:5bbb:98ea]) by SEZPR03MB6466.apcprd03.prod.outlook.com ([fe80::8814:cbff:5bbb:98ea%2]) with mapi id 15.20.7316.035; Wed, 28 Feb 2024 15:38:56 +0000 From: =?utf-8?b?TGVuYSBXYW5nICjnjovlqJwp?= To: "davem@davemloft.net" , "kuba@kernel.org" , "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 v3] ipv6:flush ipv6 route cache when rule is changed Thread-Topic: [PATCH net v3] ipv6:flush ipv6 route cache when rule is changed Thread-Index: AQHaalw91Rv7H6OFS0Wr4eaCYscTYA== Date: Wed, 28 Feb 2024 15:38:56 +0000 Message-ID: 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: SEZPR03MB6466:EE_|TYZPR03MB8560:EE_ x-ms-office365-filtering-correlation-id: 26519958-9382-48f1-5b5a-08dc3873602a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: hR7IFUn/zvhxk5bkyslFWpRVeEiLVoLYZwVQNSYhynPMApSlj2bcYVPgrYIOoSliUqS0E8S28YL9t3nWgvglVYBuUPYkMaNUXv15nXsvRiNIMiV+S51NdOnMZZgiKaukfgCG36I44yrnFBOSEAAUj3nHnje5DvfsA0az78DkQLeip2JKC87bQRVcyjqzUjMqmGkuddP4CIzMQiRjqHkqDSPXpdmZxKVLyjaWj8DuJSB8ZspiISs4rbAUSL/ixf92oTYYaDiwU5N5gTj/TwqyMGGCmsgRzovxl1CaeeyeT1vDdsPcXNjVPVZNviX51bFDiqC3OIElHAY4gjmYGOVB2Jas5XE7FUyk7vVtDKMAUGF/xr/nYdi1DlFRcCEAXsnj0OfdxB39txx+qkBrJy6izkuJggVD7131R3KcfXD2qrC2By1zAAX1ZuQ/wk7O2QnBb30sYEB4+JC0bt3DOaLdLI+u1CIPCuZ1FBsoWwnhuNzUMAjG1gv2uFbYzffGCz4owUft6fMZL5FIfCB/vQCH/n22XmPuaGveHYp7eJFh0QIqxT904ZN8DwSuFFvaviSPFRvb7k+F6ahpTe9JpKbIt6OmrMP4k00RWHdV8Q1bxl9L6SQL2nfHHGWDLlusZ/5HsFniasMQDgLcJdZT9+/WWY0cRBrR3Q4m3CSRkWOpw0QF0BDH+rBxG1Msu52E5AGveTlv3Qm9E/foKMJF/syvVwBaMCFSwfFTNiXLFB1yoAg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR03MB6466.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?OO3m9dDvy1gjxsxk/x+9bTkgqiTp?= =?utf-8?q?EMYk1nrl0jZTcygB4Wtelxn/XXwlxzMfPhlvDp5fB4mNzEZI/kuUGTp8tSAQ67+1Z?= =?utf-8?q?V7e/eK8hy03gfVozxrr9TyziKz+nUBgIMsDD4LdPcXnyu6KbWdEnk6NESfJwq6VNr?= =?utf-8?q?rI+JaLde5qIB2MmmKahKcLBlRoLJYKqBUIEUuWgv3qicNSIjMqlFHawjidV73Iku9?= =?utf-8?q?hh5jnUtk+OSNj2iSdP7kkv4JFtyCmXGfcEYDJFd3ZqJgurFPGedy/doqyoo2Pwv/X?= =?utf-8?q?zz8koC/6ynIZwxf8/cYFgNxbkZMBpAeodl0I22uBbn/DUkGfIsYz7q+ky2142sm1f?= =?utf-8?q?kde0J9JbwY2Td0F4McjIKDJZ+2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4M7ZAe9MwFkpwsJotxDKqPLQfjiOkPPkn6?= =?utf-8?q?mhZFekdb5D7O0x4zI7xVD4Kg6G+WbVRep0Bn+pHd1PsvtaG/JAEI1QFU8fQWyoKjx?= =?utf-8?q?GjDQVDEJVLPN4z2oV9XoTn7jvaXi/nHO9NQg/R7B/b2Zs2TQAOO6CwTdTLmlG7L5s?= =?utf-8?q?OK+1fvla3UWSQj4qs0UdggnnZxBFzgJG0FoZS8bxu4A0Ra72cPRLGkRPn0DuM5dZn?= =?utf-8?q?yjujWxlZIpobTcgOV+bqZtbweyzMzkCjrT/SsaIetNzx6TkA7T2qxeR1zNMfsFe91?= =?utf-8?q?YqqC5rhiMW8vN9EIrTV6bfLuy7R289sFDQ=3D=3D?= Content-ID: <9EC294021F721A4795BFD46FB476917E@apcprd03.prod.outlook.com> 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: SEZPR03MB6466.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26519958-9382-48f1-5b5a-08dc3873602a X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2024 15:38:56.5292 (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: pANkv+HxqMlmJSR+vbvPsmN7Qmz8OAHD25N1IurM6OwlhomH8BvW25YosGcEE8516dz+38Njj8kvSv/WuNUr0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR03MB8560 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. Signed-off-by: Shiming Cheng Signed-off-by: Lena Wang --- v3: Changes according to Jiri's suggestions, update patch description and name format in commit message. v2: Changes according to David Ahern's suggestions, modify flush function same way as ipv4 flush cache and 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 = {