From patchwork Mon Mar 4 08:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Huettner X-Patchwork-Id: 1907416 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bmPGm0Cz; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bmPGm0Cz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TpBWm5mq7z23fC for ; Mon, 4 Mar 2024 19:22:28 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 79E7A40B7B; Mon, 4 Mar 2024 08:22:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nFm2jUpLwjCx; Mon, 4 Mar 2024 08:22:24 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 29CEB40B38 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bmPGm0Cz; dkim=fail reason="signature verification failed" (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bmPGm0Cz Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 29CEB40B38; Mon, 4 Mar 2024 08:22:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 005B4C0077; Mon, 4 Mar 2024 08:22:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 39A2CC0077 for ; Mon, 4 Mar 2024 08:22:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1977260B66 for ; Mon, 4 Mar 2024 08:22:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id voR-UFF4GHOw for ; Mon, 4 Mar 2024 08:22:21 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f403:2606::600; helo=eur02-am0-obe.outbound.protection.outlook.com; envelope-from=felix.huettner@mail.schwarz; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org A0E0A60AF5 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=reject dis=none) header.from=mail.schwarz DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A0E0A60AF5 Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bmPGm0Cz; dkim=pass (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=bmPGm0Cz Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on20600.outbound.protection.outlook.com [IPv6:2a01:111:f403:2606::600]) by smtp3.osuosl.org (Postfix) with ESMTPS id A0E0A60AF5 for ; Mon, 4 Mar 2024 08:22:20 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=KNJuUmdTSdB4xBVHzHQhel9rNCCqrqtMIp6eTBMJKMq3Tu+2HXT8JgQKtmzHmkptDeBKYvEtm8689TVTpiWHJr9/WHyDeVzJujrKXJUvCvwdn4Z481elg8FcthfYccWfPPjXwOUdOMP2qdOtFo8eLoKs9yWaW2IzQDH2R4VIcFehYAatUI/X6WAu+z/c6+0fJSh9aIeX7go3UE4MAyYtjyyAXs8o5++XvovIe4cEQGKyXxOg2XPgO6fM4S2bmOXR8lUi8M4BdGMV6IF3vVCicrSLQ1zaTJlR2e/XBHKcUj5Xy2yh5n4uqOBi3Vsi09ezYtlfLk9UAyfn8IbK0tmwgQ== ARC-Message-Signature: i=2; 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=XjFPDiSRmRpKpaCXEV7j9/sfGAyAnJhh35vT2IXqVuU=; b=LTtM+kef1ItsF/3O/RxB2pAOctSC3kbiG4zuKa2ps5r/aT+dRTqxzzITq6aB4/XR3JZOsLyWXQeBWlTS0rijoN3q1eSPds29rN+o2th/5SzfNW9VtC7kTjU3CV13H93Ijw8en9P8HFQj8ZXUMvn99d+uywvGgVAGxe1NDu/pjPf1EB3JEUH31cE7U14HJOALiSB71N5HS0eQTt0x6uqX1yREtolO+Qi0ceLF96rA/EQpllgmDQa7v9XgY+oonTqaHTJEmRwHzfv7WwBgWtNjk6TcE41r0RzOi+Fhaiuiq8o61qSjEyLzqLQChkVMlYyfAQW0TZm+QN21c0cnMs6wIQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 52.169.0.179) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=mail.schwarz; dmarc=pass (p=reject sp=none pct=100) action=none header.from=mail.schwarz; dkim=pass (signature was verified) header.d=mail.schwarz; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=mail.schwarz] dkim=[1,1,header.d=mail.schwarz] dmarc=[1,1,header.from=mail.schwarz]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.schwarz; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XjFPDiSRmRpKpaCXEV7j9/sfGAyAnJhh35vT2IXqVuU=; b=bmPGm0CzGbXQaPirjphfvPydBxDGceeeNlpcQoKDUJlfmd/HG0vPEErYXxBmEOAMqGTCmzyCNwLinfuANbrey7VtEQzAuc1nOJpqEtajyYo7BaI3Xo6kvBr1zG2n44D7WPyU0OblNKat+Ft1xiZrmcWGhQk9ygfezlHehc0DtSs55FdM6iM8QwEIr2HTrG2XIIMD2Hv8xHTwF3mSmIViu7izdjNNM67vaZIvGbIox84alExpakZcJG/q3imZ/ad1yGlm0QYq17diSqafww4PrFXMcdSn8rQboT3pH7Gn9Y+dWMMcXZcnXDs6dWNSzO8igkkkf/JgP7CdKNNfSQDOew== Received: from AS8PR04CA0108.eurprd04.prod.outlook.com (2603:10a6:20b:31e::23) by PAXPR10MB5277.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:28e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 08:22:16 +0000 Received: from AMS0EPF000001A9.eurprd05.prod.outlook.com (2603:10a6:20b:31e:cafe::7c) by AS8PR04CA0108.outlook.office365.com (2603:10a6:20b:31e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38 via Frontend Transport; Mon, 4 Mar 2024 08:22:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 52.169.0.179) smtp.mailfrom=mail.schwarz; dkim=pass (signature was verified) header.d=mail.schwarz;dmarc=pass action=none header.from=mail.schwarz; Received-SPF: Pass (protection.outlook.com: domain of mail.schwarz designates 52.169.0.179 as permitted sender) receiver=protection.outlook.com; client-ip=52.169.0.179; helo=eu2.smtp.exclaimer.net; pr=C Received: from eu2.smtp.exclaimer.net (52.169.0.179) by AMS0EPF000001A9.mail.protection.outlook.com (10.167.16.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.7362.11 via Frontend Transport; Mon, 4 Mar 2024 08:22:14 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (104.47.12.51) by eu2.smtp.exclaimer.net (52.169.0.179) with Exclaimer Signature Manager ESMTP Proxy eu2.smtp.exclaimer.net (tlsversion=TLS12, tlscipher=TLS_ECDHE_WITH_AES256_SHA384); Mon, 4 Mar 2024 08:22:15 +0000 X-ExclaimerHostedSignatures-MessageProcessed: true X-ExclaimerProxyLatency: 6565777 X-ExclaimerImprintLatency: 1963249 X-ExclaimerImprintAction: c819b0f08dfe40598167def17043208b ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecD4zuUh/nUXveFM0YQ2WFkonWbssPA5K/Si3cKwc5LpI/+gnZZr3xNv2VZzosXyKGTtd09lMIfG5rmIjIoFIHG4O96OTydWUVjjj3T9MZJQQISkQyCBDGttfQC4/a3VZQ5ngaKg1eR54mL1/lr3yjwcPPWEQv0fT+x4Hvs4W3xCkuqK70p2vcMovSESgAK4oOR3RqxR2YzoNPcxiGA3lBT66uEi26qqNdTeZOVZHjSQtMG6hPSUieDqxECCGsIjSSAjFX25/jTwPFfvCFyC6VlOFtToQ+I6s5dAjT/CNI96c4NykbD70KXCe7cXd5qP7ft3POG4NGVgtFSSOHx9Hg== 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=XjFPDiSRmRpKpaCXEV7j9/sfGAyAnJhh35vT2IXqVuU=; b=JFTPe0EQmBR95axI5ShOmU7KpdXD7xN6605AbIQsqdvZpzjrzJDD/o3v8qxedHqzrY0cqCvEGOXzgdwOTNydbEx5y3BAjsmBrF3jz9rOZJaxcXMbvzRi/t5Pk0+ljoLmjr7QQmKjs24sQCBqm461azp2JRBWVta9MT51WUib7na7ThzeM1ecMBMw9eYLXJQtH6K0UjwzHY0UrYrdbbrnFV6qs4PaiAm2LEWO3Ju4h83D56UTyBzx7h0rvLcmTTu5HmoqmD1seD/UIrbEc5/HNgJ2RMKc5iIp/4t1gx+cH/azdbg9Mcn8bYLK0T9kmzoAhXQCLfcio2yspD4JN0LKxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mail.schwarz; dmarc=pass action=none header.from=mail.schwarz; dkim=pass header.d=mail.schwarz; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.schwarz; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XjFPDiSRmRpKpaCXEV7j9/sfGAyAnJhh35vT2IXqVuU=; b=bmPGm0CzGbXQaPirjphfvPydBxDGceeeNlpcQoKDUJlfmd/HG0vPEErYXxBmEOAMqGTCmzyCNwLinfuANbrey7VtEQzAuc1nOJpqEtajyYo7BaI3Xo6kvBr1zG2n44D7WPyU0OblNKat+Ft1xiZrmcWGhQk9ygfezlHehc0DtSs55FdM6iM8QwEIr2HTrG2XIIMD2Hv8xHTwF3mSmIViu7izdjNNM67vaZIvGbIox84alExpakZcJG/q3imZ/ad1yGlm0QYq17diSqafww4PrFXMcdSn8rQboT3pH7Gn9Y+dWMMcXZcnXDs6dWNSzO8igkkkf/JgP7CdKNNfSQDOew== Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=mail.schwarz; Received: from PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) by AM7PR10MB3685.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:13d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.38; Mon, 4 Mar 2024 08:22:13 +0000 Received: from PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM ([fe80::3cb1:ce2e:b6c:7798]) by PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM ([fe80::3cb1:ce2e:b6c:7798%4]) with mapi id 15.20.7316.023; Mon, 4 Mar 2024 08:22:13 +0000 Date: Mon, 4 Mar 2024 09:22:11 +0100 To: dev@openvswitch.org Message-ID: Mail-Followup-To: dev@openvswitch.org References: <7fc55e71ef28fc4575c0005e34599e86aefd7f51.1709537628.git.felix.huettner@mail.schwarz> Content-Disposition: inline In-Reply-To: <7fc55e71ef28fc4575c0005e34599e86aefd7f51.1709537628.git.felix.huettner@mail.schwarz> X-ClientProxiedBy: FR3P281CA0113.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::12) To PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAVPR10MB6914:EE_|AM7PR10MB3685:EE_|AMS0EPF000001A9:EE_|PAXPR10MB5277:EE_ X-MS-Office365-Filtering-Correlation-Id: e3b2bd9b-efb6-418e-7a11-08dc3c2432f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 4ypm0BQ2tBth1eROjsUdGTnKZsufQt2VFnFn2pFKw/IH+z4pyIPV7jM5HRMPLTTG739h4o9B7cNaxUsrBk9u7DouvtCd58dNKwDtt/0G/vHRoMZQAWXnUepkL1p76xyWIpUs6NDxzWwjH+KXCScLbWKc8fg4H20PMPOcU+k7jxNW2F1R7Nx7pi3d8NYSF9w4914BUUdpp3wGIl1ERd3ymijhcEL3nVflk1empfzftWYk3VJ/3ZvosPTYI6i8UcVKuhJxxrQPTk9OmqTm+Oa2lf+//hLKJzYsYL233UNdcqZIrhQglntXMep/TJeHK2nLptmkIIAg5gITqMTzBHNOoaYTStYsr801pnf5RbsZjL1dxygbnGqPO6gllrvmsouzAnxcvbNIPX/yfdBeYRA1R39IagUiKw6CUrYwDTGAmcPeWEonCO1lTAJboiaDEaFm/qRvPXNWr0kkbgk+Bf3bLUM3fAlazmbzzHjA8vzKMPeTGof3T23M2OY6YwrZ6t0gO3Si0XfhZ742r+g/MCky5NZT0oK4smtkmMXGVVDaCb7aFH4+xTfPja4Or02BawC5UGqOF0ZAXrhAAsYMT7rSEDGNrMqXXPHyIw3Q9ACR4G4= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230031)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR10MB3685 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF000001A9.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 1e2f1666-c7fe-4f88-5cab-08dc3c24319e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1sCaeTjnCKeViX2TwuzO5JR7dwE0Y3H2mrjen+ZWljzYG0jqCR2BAo2SuyEzbjUNVLUuKP9BwBL7R7mibzVM1l5ZZJqidJW51WPP57hN3MNkYtO36+yGAvGHNa8E5y8otHFbRmYF1Jc1Nry1nsSl34EPTAsVEanD2IxGWLr5Q+BbKwi1a/qeQ8cHVMk1wxXUu42G5aoZ9nr1w6ZDfkWKHGBr7NKwqBNiXv+rbplXlPyfli+SbpBkg0gjMQ0TNjq+FY6gYy4t4gRYXNdaK2TqLiNHMscIFvQ9HDGEUfeU1k5NXtONCf5WgDFuz4spCiRSp97y2IZipr3+P2f7UQ3EHokAhR/B+LtnZIOezEOFPBEvR+7b0AXjK6WvYZ0P4DlfLGQrOduue9rktm54Q1ghz6EzFZRW7nj1VnjyBXus9ih1urV71MFaJ7+AxOVNsdPEGWsRNu7/TvxQmHCVX/3L4PdsC3gA2aZgcigrgYNKcHjwCYqrSoETCnMZsVhcTmr0sPERIQHePUK78EMV2jEjZgtp7YuPIkkIOLo3gVc+rPBB6OYBDKNRPoylPVPRhprE1d9PKxTdJKtcQGwBDrK654yb3KQ8tnmpASG9BkkeJ6mu/jW7/wkSGChjti27JlJtV1+6k6UYWHcVnLBZXk8guN4VcgdI77A6zBbcDayh8C/5EulMqHZn+P6eSTKIOn/SAUZeDP1EpKd1yzu1dqBczA== X-Forefront-Antispam-Report: CIP:52.169.0.179; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:eu2.smtp.exclaimer.net; PTR:eu2.smtp.exclaimer.net; CAT:NONE; SFS:(13230031)(376005)(82310400014)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: mail.schwarz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2024 08:22:14.7924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3b2bd9b-efb6-418e-7a11-08dc3c2432f5 X-MS-Exchange-CrossTenant-Id: d04f4717-5a6e-4b98-b3f9-6918e0385f4c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d04f4717-5a6e-4b98-b3f9-6918e0385f4c; Ip=[52.169.0.179]; Helo=[eu2.smtp.exclaimer.net] X-MS-Exchange-CrossTenant-AuthSource: AMS0EPF000001A9.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR10MB5277 Subject: [ovs-dev] [PATCH v6 2/2] netlink-conntrack: Optimize flushing ct zone. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Felix Huettner via dev From: Felix Huettner Reply-To: Felix Huettner Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Previously the kernel did not provide a netlink interface to flush/list only conntrack entries matching a specific zone. With [1] and [2] it is now possible to flush and list conntrack entries filtered by zone. Older kernels not yet supporting this feature will ignore the filter. For the list request that means just returning all entries (which we can then filter in userspace as before). For the flush request that means deleting all conntrack entries. The implementation is now identical to the windows one, so we combine them. These significantly improves the performance of flushing conntrack zones when the conntrack table is large. Since flushing a conntrack zone is normally triggered via an openflow command it blocks the main ovs thread and thereby also blocks new flows from being applied. Using this new feature we can reduce the flushing time for zones by around 93%. In combination with OVN the creation of a Logical_Router (which causes the flushing of a ct zone) could block other operations, e.g. the failover of Logical_Routers (as they cause new flows to be created). This is visible from a user perspective as a ovn-controller that is idle (as it waits for vswitchd) and vswitchd reporting: "blocked 1000 ms waiting for main to quiesce" (potentially with ever increasing times). The following performance tests where run in a qemu vm with 500.000 conntrack entries distributed evenly over 500 ct zones using `ovstest test-netlink-conntrack flush zone=`. | flush zone with 1000 entries | flush zone with no entry | +---------------------+----------+---------------------+----------| | with the patch | without | with the patch | without | +----------+----------+----------+----------+----------+----------| | v6.8-rc4 | v6.7.1 | v6.8-rc4 | v6.8-rc4 | v6.7.1 | v6.8-rc4 | +---------+----------+----------+----------+----------+----------+----------| | Min | 0.260 | 3.946 | 3.497 | 0.228 | 3.462 | 3.212 | | Median | 0.319 | 4.237 | 4.349 | 0.298 | 4.460 | 4.010 | | 90%ile | 0.335 | 4.367 | 4.522 | 0.325 | 4.662 | 4.572 | | 99%ile | 0.348 | 4.495 | 4.773 | 0.340 | 4.931 | 6.003 | | Max | 0.362 | 4.543 | 5.054 | 0.348 | 5.390 | 6.396 | | Mean | 0.320 | 4.236 | 4.331 | 0.296 | 4.430 | 4.071 | | Total | 80.02 | 1058 | 1082 | 73.93 | 1107 | 1017 | [1]: https://github.com/torvalds/linux/commit/eff3c558bb7e61c41b53e4c8130e514a5a4df9ba [2]: https://github.com/torvalds/linux/commit/fa173a1b4e3fd1ab5451cbc57de6fc624c824b0a Co-Authored-By: Luca Czesla Signed-off-by: Luca Czesla Co-Authored-By: Max Lamprecht Signed-off-by: Max Lamprecht Signed-off-by: Felix Huettner Acked-by: Mike Pattrick --- v5->v6: none v4->v5: none v3->v4: - combine the flush logic with windows implementation v2->v3: - update description to include upstream fix (Thanks to Ilya for finding that issue) v1->v2: - fixed wrong signed-off-by lib/netlink-conntrack.c | 52 ++++++++++++++++++++++++++++++++++++----- tests/system-traffic.at | 8 +++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/lib/netlink-conntrack.c b/lib/netlink-conntrack.c index 492bfcffb..d9015d9f0 100644 --- a/lib/netlink-conntrack.c +++ b/lib/netlink-conntrack.c @@ -141,6 +141,9 @@ nl_ct_dump_start(struct nl_ct_dump_state **statep, const uint16_t *zone, nl_msg_put_nfgenmsg(&state->buf, 0, AF_UNSPEC, NFNL_SUBSYS_CTNETLINK, IPCTNL_MSG_CT_GET, NLM_F_REQUEST); + if (zone) { + nl_msg_put_be16(&state->buf, CTA_ZONE, htons(*zone)); + } nl_dump_start(&state->dump, NETLINK_NETFILTER, &state->buf); ofpbuf_clear(&state->buf); @@ -263,11 +266,9 @@ out: return err; } -#ifdef _WIN32 -int -nl_ct_flush_zone(uint16_t flush_zone) +static int +nl_ct_flush_zone_with_cta_zone(uint16_t flush_zone) { - /* Windows can flush a specific zone */ struct ofpbuf buf; int err; @@ -282,24 +283,63 @@ nl_ct_flush_zone(uint16_t flush_zone) return err; } + +#ifdef _WIN32 +int +nl_ct_flush_zone(uint16_t flush_zone) +{ + return nl_ct_flush_zone_with_cta_zone(flush_zone); +} #else + +static bool +netlink_flush_supports_zone(void) +{ + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + static bool supported = false; + + if (ovsthread_once_start(&once)) { + if (ovs_kernel_is_version_or_newer(6, 8)) { + supported = true; + } else { + VLOG_INFO("disabling conntrack flush by zone. " + "Not supported in Linux kernel"); + } + ovsthread_once_done(&once); + } + return supported; +} + int nl_ct_flush_zone(uint16_t flush_zone) { - /* Apparently, there's no netlink interface to flush a specific zone. + /* In older kernels, there was no netlink interface to flush a specific + * conntrack zone. * This code dumps every connection, checks the zone and eventually * delete the entry. + * In newer kernels there is the option to specify a zone for filtering + * during dumps. Older kernels ignore this option. We set it here in the + * hope we only get relevant entries back, but fall back to filtering here + * to keep compatibility. * - * This is race-prone, but it is better than using shell scripts. */ + * This is race-prone, but it is better than using shell scripts. + * + * Additionally newer kernels also support flushing a zone without listing + * it first. */ struct nl_dump dump; struct ofpbuf buf, reply, delete; + if (netlink_flush_supports_zone()) { + return nl_ct_flush_zone_with_cta_zone(flush_zone); + } + ofpbuf_init(&buf, NL_DUMP_BUFSIZE); ofpbuf_init(&delete, NL_DUMP_BUFSIZE); nl_msg_put_nfgenmsg(&buf, 0, AF_UNSPEC, NFNL_SUBSYS_CTNETLINK, IPCTNL_MSG_CT_GET, NLM_F_REQUEST); + nl_msg_put_be16(&buf, CTA_ZONE, htons(flush_zone)); nl_dump_start(&dump, NETLINK_NETFILTER, &buf); ofpbuf_clear(&buf); diff --git a/tests/system-traffic.at b/tests/system-traffic.at index 07d09b912..d87d6914d 100644 --- a/tests/system-traffic.at +++ b/tests/system-traffic.at @@ -3376,6 +3376,14 @@ AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=,dport=),reply=(src=10.1.1.4,dst=10.1.1.3,sport=,dport=),zone=2,protoinfo=(state=) ]) +dnl flushing one zone should leave the others intact +AT_CHECK([ovs-appctl dpctl/flush-conntrack zone=2]) +AT_CHECK([ovs-appctl dpctl/dump-conntrack zone=1 | FORMAT_CT(10.1.1.2)], [0], [dnl +tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=,dport=),reply=(src=10.1.1.2,dst=10.1.1.1,sport=,dport=),zone=1,protoinfo=(state=) +]) +AT_CHECK([ovs-appctl dpctl/dump-conntrack zone=2 | FORMAT_CT(10.1.1.4)], [0], [dnl +]) + OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP