From patchwork Fri Feb 23 13:32:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Huettner X-Patchwork-Id: 1903293 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=crIaimRu; 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=crIaimRu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4Th9tk0C7zz23l1 for ; Sat, 24 Feb 2024 00:33:01 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id F11D161771; Fri, 23 Feb 2024 13:32:59 +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 chz5e7AemhnV; Fri, 23 Feb 2024 13:32:58 +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 smtp3.osuosl.org 9736D61761 Authentication-Results: smtp3.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=crIaimRu; 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=crIaimRu Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9736D61761; Fri, 23 Feb 2024 13:32:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 699B1C0072; Fri, 23 Feb 2024 13:32:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id BBA02C0037 for ; Fri, 23 Feb 2024 13:32:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5F41141D82 for ; Fri, 23 Feb 2024 13:32:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1OSvJeqbhjOm for ; Fri, 23 Feb 2024 13:32:53 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f400:7e1a::60a; helo=eur05-db8-obe.outbound.protection.outlook.com; envelope-from=felix.huettner@mail.schwarz; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org DE44D41DE0 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=reject dis=none) header.from=mail.schwarz DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org DE44D41DE0 Authentication-Results: smtp4.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=crIaimRu; dkim=pass (2048-bit key) header.d=mail.schwarz header.i=@mail.schwarz header.a=rsa-sha256 header.s=selector1 header.b=crIaimRu Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2060a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::60a]) by smtp4.osuosl.org (Postfix) with ESMTPS id DE44D41DE0 for ; Fri, 23 Feb 2024 13:32:52 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=bgxLP5Bq3kv0v1qemzAb+ApbE3NCVwleP4dVjb/7Hi9o7NTq5lDY6vhOj+ebV8YQ2oZ1c+1Vkqjdz2/nZVwwRjWYMr18T0Q2CmF/l4u3ExyyvVD9pTF3yrKv+aXtZP3LvEDT8k/7f7y4bdf4aYz0AAoepcnsVfq788l5C5NRajogAoD7MQcMg0t+w0wUOKbV30NMDjTGYBR5Mzgu8xlMqZxybKK7J+11/j/9xNC8+kskiFAQUTxAiO+kryMP8y2/dLg9liqJNQGBjuaZbkpFPpPBH3R4AAe023qdtz+mNNyAlq6cAlFt8L6iZltuc6hW0b6G7hJd7pfnD6KIocHrfA== 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=Shn/jHoBHcMpnrB8rSCuZIxnZUMDjXEDHFBN+VK2fwY=; b=C9pxFRH6J1p8NaAX6leienLMm6xF/EoUY8VvnAhIPzkN0pHkWwAtk+Ead3t82RaotxPo9lX2C4j5fuu8oeyCvfMs+uXgrtBfPBJwfz0uqiNODuix3/h2rqD0O+N6pdKhRgODqRjvSpoyEY13DOqvGqb9kjhFeWn3SWUIHRFpcT1uIVWML6FYzY32HS0+sTyGvvtovxJodS/J+uKPrvdQXK0ebXVcFatZaDAHu2goTea/rK3OnqpO/ePczeb+yl3EMD60/6uNk7CJ1AZlxZS8IxFOFmwAhB/25YKTsfXkrerqoJxYdSF6bBt+6JiwNewRaDu0/mEyfv13tfHwcYWNTQ== 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=Shn/jHoBHcMpnrB8rSCuZIxnZUMDjXEDHFBN+VK2fwY=; b=crIaimRueKFgSeHqWhHUdpqDjLOe/18dRzjId1vW6DOwu09hqvTNQnwkc8IbMi4A48GJ7NyO0gtJ8uzHVsUct75VugmxaHPkwWi4FAJVXQ6AgugQz+iR10knlmorIibkTnivHiPqChUEN+9gEb01K/pqetlttdwCVeybzh2I4msUs5TBigNcWbdE6DC13r/MjMmcXBegg/HfcQa1fMwuM8xVv1F515vJZLg82oe2zBQKHhGy1LBlCrAy9ofbNjxnaLRZf3conG1rofBdaiMWYexdXyMl8SR6j317IlyHWkESxe236iECnuNPCRHXWirM9ETGCK6BH7ivURiOaURj6A== Received: from AM5PR0301CA0006.eurprd03.prod.outlook.com (2603:10a6:206:14::19) by AS1PR10MB5166.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:4ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.27; Fri, 23 Feb 2024 13:32:49 +0000 Received: from AM4PEPF00027A64.eurprd04.prod.outlook.com (2603:10a6:206:14:cafe::5d) by AM5PR0301CA0006.outlook.office365.com (2603:10a6:206:14::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.43 via Frontend Transport; Fri, 23 Feb 2024 13:32:49 +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 AM4PEPF00027A64.mail.protection.outlook.com (10.167.16.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.7292.25 via Frontend Transport; Fri, 23 Feb 2024 13:32:47 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (104.47.11.104) 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); Fri, 23 Feb 2024 13:32:47 +0000 X-ExclaimerHostedSignatures-MessageProcessed: true X-ExclaimerProxyLatency: 4998004 X-ExclaimerImprintLatency: 1366256 X-ExclaimerImprintAction: 09a0a7300f954367a359e10db99ca688 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+VhZCt4kXDjuCjJg373Ohg/3+RwnxhIRf2VIfSVjeZ8bLbvFK87x096+28OI9PSJwG14c66dTA+8mx6YaVnNw2tI/QBKGlJDD9EMYWZFhdI7vWLYM1A2MjVOnE7jExZTZdjc5Z/Ljfh5ukSLS8jTUflzJKAAbhDdI62jjJWVNoHJfvTV3Nrkpeo/R9LUWo2yWPiHeVM5t+DjHK2N7Vpo/m4vqlsiSISFVKF4zGEsk049zqvNlpPfTplFuP6nOgHCk5+dj4EJU1Kb39i7TN1O+DnbGke5HTa4PuwqdchBj9QekT1OcrABrpAe+RkzuWk+NfxLK52xX7n5LDhWiZO1Q== 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=Shn/jHoBHcMpnrB8rSCuZIxnZUMDjXEDHFBN+VK2fwY=; b=aom52pd+h4/n2B9BpYbM476vWGjX5aoQGxf0I+Lnf1wDkdwnL4U73btKCPT2rHSCqZoubtoK3yqQKMz9AQ8aZSTJvToQNyI5wB8eFMzfEjQ4YU2jsnRJgNt8AgYXf5zp5CT9XdVRBnS9pF2Om0wyisjtVMqogpbCH32Vy6v+50eodf4X04VzhC2oZZV8kQNt/MXPQkKIbHFZA4XKI9mL+/+c2GC1qHm84m2irEwAPD/tpA08ApdzkY3J3rOkuOTAF+/yE29Ohx7y9LDD5zff+qEPsBbUyN0UT5o6+W0y2tfJpBouUgUeGgB2eKcqTUc3RVKofFcOqgopWNOCfv0M+w== 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=Shn/jHoBHcMpnrB8rSCuZIxnZUMDjXEDHFBN+VK2fwY=; b=crIaimRueKFgSeHqWhHUdpqDjLOe/18dRzjId1vW6DOwu09hqvTNQnwkc8IbMi4A48GJ7NyO0gtJ8uzHVsUct75VugmxaHPkwWi4FAJVXQ6AgugQz+iR10knlmorIibkTnivHiPqChUEN+9gEb01K/pqetlttdwCVeybzh2I4msUs5TBigNcWbdE6DC13r/MjMmcXBegg/HfcQa1fMwuM8xVv1F515vJZLg82oe2zBQKHhGy1LBlCrAy9ofbNjxnaLRZf3conG1rofBdaiMWYexdXyMl8SR6j317IlyHWkESxe236iECnuNPCRHXWirM9ETGCK6BH7ivURiOaURj6A== 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 PAWPR10MB7652.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:35a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 13:32:46 +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; Fri, 23 Feb 2024 13:32:46 +0000 Date: Fri, 23 Feb 2024 14:32:44 +0100 To: dev@openvswitch.org Message-ID: Mail-Followup-To: dev@openvswitch.org References: Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: FR3P281CA0118.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a3::13) To PAVPR10MB6914.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:102:30d::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAVPR10MB6914:EE_|PAWPR10MB7652:EE_|AM4PEPF00027A64:EE_|AS1PR10MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: 6617c962-4d79-4c9f-1a6f-08dc3473ecf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ydpjCb+ayJqIDZgGxgiLxdKUv7oIAv8uBkv1oFPTgOymGb1GoGq2voJcTNPxu/7BF5NMwgHocwQfMGqzybYiXkTbemGpv6Hsob05M4BuoVJLSWPNDHT0oi/rZoSgQnJDFcSGBJFIe6/ee2x41DuysYwd++xbRbTrBfeuax2U039ybQy5lXxEZKg8kdHEJPYndL7c9WDPVbFd5qKlKCaIijV5Ab3Zzf8YouJW7nNMI9z9JkexvS+5SqbVsezNkIpXuHChKCCpq6Dc2Ln1OC5TOGb0ILnxACvBSuwtfXNDk+EO4tb7RVEIjBwpxqFKnyp31dSvoc+IT3c3ykgHZaAbP3zyxK02gMXkz/o3tLSbETgjSabirgtMYdQLKkZmsVRcrwjZAw533YbOmmiZq3v2fYsMstxGP4D8pfWdzswGdvMLWnqIEl1NRGyLwjmkSA20RzKBUJidqazi9f27jBo6p5JPxBlkSzAfoOAmrfteSr96C972yjSBNxIEiGINlzGC4R08bn5cNXN92zuvXzQSXQ== 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); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR10MB7652 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00027A64.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d68b7028-d0b9-4851-013e-08dc3473eba2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vEaNLxe2oO/LpzQC6jDw0sN8NtTE+dLsK8lSBnFvLPf3agrW7+E8mXCtrld3QtpKR146xparYvaKI1hx3PWVgz2o3YsGvkZO5P+BCSPOXHS1uiB4PQzT9l4c0QnCJiGuJv8sr914zShMYBn28YMAlzmOy+ILPYO2jRvU/IEiGXJV9HIdIWsW/aHILKo+fLBtq3VpoYSmoFWLJEoS4Z9CppP/2CBvmBDbCu2WMT7HGl3i3NYaaiQUj85wVdBZOrIwWqLan5dZI0Qq3q62Qp/FmylmOoouQ8d8AjySTr7hHRJinuc6n8ndHL+uDfQOs8i/S5B+Efbvd01Bj4zSptfEkfwLI+y73tDO8a80M9Ani5S5AvYiW1hC2P/IPPUS6LSeJEbZf6we+7JRhoxsNiuio67wleCeMqKrmgesnwKJ/qWZ/t2WhjOkDl4joAsWaxu09fgG3yjoIBCNWF0QGgRmpKtv6WM91rPILbRy1DMMkMZ4fVaWRM6aTx/KipuWuoNpG8pIFROQJNmP40DMfbA5+soAOikd00OAUSukkewaNTYRLi+8EHKQ35URP3MV0RDYHRyErq9Ez8Klu9fUcaAPyV399TDGClwpc080a2pDZDDpbuz3nrz1lRM4LiOPhi3mepBJ1RMdGxAEP7PHBjv+qA== 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)(36860700004)(46966006)(40470700004); DIR:OUT; SFP:1101; X-OriginatorOrg: mail.schwarz X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 13:32:47.8702 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6617c962-4d79-4c9f-1a6f-08dc3473ecf6 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: AM4PEPF00027A64.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR10MB5166 Subject: [ovs-dev] [PATCH v4 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 --- 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 98e494abf..43eaa534f 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