From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0066.outbound.protection.outlook.com [104.47.1.66]) by dpdk.org (Postfix) with ESMTP id 627781B1D8 for ; Wed, 14 Feb 2018 12:31:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=cGIr+jMcYIUYyrjWf1Kuwyy73S3aLtJeAf7x37RFt3A=; b=qerzRfjaO1nq0BJDV9YHQwODOr/V1XZrVOX7/MLxegQQ+j2BDxBJjfzpTgW5YqcgfO/CK7n6jj4akx5dmyj4JNs9W13SOcL/5bXO0o2PaUL19n8f7Nf5gK7NMrO2bS46utZGZRIuYwQ6B6pLTuRnUR83MCc2KzJMQImFlnN/Els= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR0502MB3887.eurprd05.prod.outlook.com (2603:10a6:803:c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Wed, 14 Feb 2018 11:30:58 +0000 From: Ophir Munk To: Ophir Munk Cc: stable@dpdk.org Date: Wed, 14 Feb 2018 11:30:32 +0000 Message-Id: <1518607832-29015-1-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1518546947-20932-1-git-send-email-ophirmu@mellanox.com> References: <1518546947-20932-1-git-send-email-ophirmu@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: AM5PR0102CA0023.eurprd01.prod.exchangelabs.com (2603:10a6:206::36) To VI1PR0502MB3887.eurprd05.prod.outlook.com (2603:10a6:803:c::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0bb49e15-0e53-49a9-9fb9-08d5739e6b9f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0502MB3887; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3887; 3:KDKwMY16nm7drtRAOydhl7TTgUAgp87FHgTJe31VYqMW5rSSbI1137HC8HcF26z8RUyLZ1svhUydYHh2bZfU6m/xEk8G318nfD+V/hE/oPJiDVCE/bPeBBHH4FlQfX1C7uk0Mu5RvEroLUtBvP5WnYR8zORTGkPD4NdxYm0Gbdpqm56Up6uUPb0MOf+wTz245Wl8DHcETghQcp4CA0e/GO4rGMI7X+kIeOICe2oJVjsAusRRBQBa8/E/uBTv/G/A; 25:6DuappQIAJES6ildW/iov7OCim/Ly6TdIdbDT7LEr3CNnzM2bOk3maVRcXmpHVbyhCh4UrbrjqzByHBOxqskWb8FZGhOVkMAgOj8WRc+dF96Yk2foIyoRMbf3l+9rGBFCZcbzhwnpOyrpA/ma4h3QbTMHgjCPdDIfJAxg6JJ0WxqOPrOox4gFOG95m3g1dGfJbsO4ddux0sM9QcfDTdawGtro8sVFneTvso0MmOhRUFgwqVvT9gTeMWErqxPp2u2wpOn7CNU193JqyMyKmfKcz9vphKbgpVJbzeFnlH0upHEFqq5jNRczDpGgIwowftdOcmdDwvmbr8pDjZsGgtqdw==; 31:hqB+0FU1Lz4s9d54YXlhXeN0bZU1jDFjWZsmQTC8POWrwXTabbQruMVZZnlwrOA9ZevPG0bKYynY/FO8MEuyL2aC6HSf3VEOZZIP+uolRCeF16fayAyQxfMRBQeCm42o022BWgjEFDCdmn9QMzqqJMBfhm1sc0vViRN1/bD7xNFBkZRP231E4Jo6PzJkibc9TUlKIgj+n6ppqf/1EqiFWI3yOW68WKVXfNY62DyCpS8= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3887: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3887; 20:H19luOaRe2g45HrHbA8ylG6wxSGezOV6OKhAW/rFFQmzrjrIvpjH2/9H5hCCYFvqMYWAMr03xalIqM2Qdt4FpYCbecY0zBZTLDrhp6Q5LlKVpjYR0NA2X6MxU5Bgq1LkQ7rbCJ+GXJon9gahFg54/kqRgjDod6/egJ9ViwzrxwbRYfModiqZQ6sx3CqAu5IvFaD6cT4yuhpL8s0h47mYkLq+/imhaQ+36iY5OGNTh3/P301N41aCrtGo9FcV8em9KvoYUuJnBM9y9Xs1XQ62YskRI0S+5bLz9qGgFBWRrZPYx4HPG1WOoY4tnk2KdJKEyalAewfmU7+ZrxF4WdMk6KOQDutD/XddERB+Y31SbEnYRH77GxhBYBSkkgbuQp5gCY7R8boPCkKBgdJtLzpewW5O7LDPfuKqMV78meMs1ucRK8+KYig9+0WRVDg28xmG2GtzVghblucPbl9FHk7uvjRVSlU/jU2TSn2/UinyM27AcjKHeOJUNSo4yIPetBpT; 4:2PDnMjXtI+FF6ir7vlaxKMKI2SdoGbeTbQRluxH5qb7q2eYXEt3d+6DMpgfLz5CjGbGCYK/ZwX9P8YMSwrdi0xZT95iUjLjHGjY4wmabzg6QH7p+BaRNXUzc/VK/wAgUAq0jobw2bYztBD7emeKpNYf5KZr7/QpxVnRgaTHo0ymmKj8/x1qYfCTElhRIkziVDNahJXsc6+JeOU/j2xekxZmS7bx5MDE41OeDqPQTJmiGgzfMOPkcv0NBctur5DVXc1ig0eIv/ukNga7R9Gx3yw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3002001)(3231101)(2400082)(944501161)(93006095)(93001095)(10201501046)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:VI1PR0502MB3887; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0502MB3887; X-Forefront-PRVS: 0583A86C08 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(376002)(39860400002)(366004)(39380400002)(199004)(189003)(6666003)(4720700003)(2950100002)(8676002)(81156014)(81166006)(21086003)(106356001)(16586007)(316002)(16526019)(6862004)(7736002)(305945005)(68736007)(36756003)(47776003)(50226002)(69596002)(3846002)(6116002)(105586002)(8936002)(66066001)(25786009)(86362001)(4326008)(50466002)(2906002)(48376002)(26005)(37006003)(478600001)(55016002)(5660300001)(51416003)(97736004)(76176011)(33026002)(53936002)(52116002)(7696005)(7049001)(59450400001)(386003)(6200100001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3887; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0502MB3887; 23:yWffYdd1kWFyrHQrJ8KbYqZ8ajbYYVFs0y/JLuV?= =?us-ascii?Q?ewtddj97yR7p3n4YduXRBrCr42YKrj3I62DRkHJjYeYpUnjiXcwE0NVvHu+F?= =?us-ascii?Q?K7WhGHxVPTqhN3g4nfY5ihGf1MoXsbbieW08UziaWxCoBed616hqiXxBueRo?= =?us-ascii?Q?GW492RWUZRqvG3c38kc04yV16aBDnLxk/luuAhHaXr1cZW59quCY0uIeqyuY?= =?us-ascii?Q?9ulWOMsF+oQk+Nin9tCGvyiGOdnpp7Sty+6CfLzGsg1lYF7KlALjbulOR4Cq?= =?us-ascii?Q?EF9r0heW0qKgQdHRw5UsEqpHu9iPVgCe0sjrpsYX7Lj7kQy5BkRqEywaWidD?= =?us-ascii?Q?26tH1nRnzxPwBj1JAvpNtJAoVKV1FQ0x3zEnzPWm1pkvkzwDhneThqFXJCGP?= =?us-ascii?Q?tFgelMSR0MeqI5Jnm/K28ygUi6pLYhewjar5sA6Pf4MVXMoApVq05LKgq5+W?= =?us-asc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3osh27p5zsOSZbOGfj3MPB27UKVNz0NXSG5pPRNM7WjsbcHsd3frdPLY3N2OYTD7eV5wuwFA1jWtd2NJMYZzy7o6fWq2nYlJxPX2EG92bx08Rqrb8LRYKMp+pTBtbF636kkT5s4T2dtPgbPigGsRMVDSxERbqGK/zGDH1WMjfGUaJah+MizasOi8tu0Ia5iKbEbiARNi1PiwwxzF0djaDX2q4WSknCgjKVTJOk7EaAz8fsHt2B9ormROzjKlRKSHerx21++P4b2Aaphf9Vn1QvGRf/sx0ZO3i6ricH36bN6fNrPMq5GfDm5E=; 5:pM2a7+bgGglsWM0s2E0alKMrBQEV7rCJ8Yd2nd2FyGj1wJRyhqGlI9WDJMxVUJou3IAaJZmuhCFMSUIvd83ccEhwW6p/eWaxohwOEVlXBMP93BduVEMcDR+lln6nnMaU9PQZPT48TaPsjClNmnoYQ3oyYekf+vYpAelHpHX6avA=; 24:WQUerzaupS9Utm4ZuvbfgGOXMmWomgfyst2cRuzxAF5OWrF7Gfbp3L9rUsWPgp0toc494+oylhsnhSizVE1QDht7q+Ji0iAu1gUi5++M6Pw=; 7:uCK9eCw/jauZbaY87T43NNeSciMAncuEXemWUQtF+IP2HYH+rKx3BGxa8US9P2bztlRS3ZOzvTcmA21fhpcEkTbD+KJqjfD9QOc7PmmELhHmlSL49qYU47ZQIGbVf54xa60broYgPOonibNvOi2RbwaGn1kK9/AEIjrdcGqa4Im6Via9lfmfx8hQc4M5s//lFoUgBR73feXZkQmTbe0bElc/RbmldQasDsoQ2u1VoWFn2A6SmnsCiWNvPM5GOK/4 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2018 11:30:58.5287 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0bb49e15-0e53-49a9-9fb9-08d5739e6b9f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3887 Subject: [dpdk-stable] [PATCH v3] net/tap: fix promiscuous rules double insertions X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Feb 2018 11:31:00 -0000 Running testpmd command "port stop all" followed by command "port start all" may result in a TAP error: PMD: Kernel refused TC filter rule creation (17): File exists Root cause analysis: during the execution of "port start all" command testpmd calls rte_eth_promiscuous_enable() while during the execution of "port stop all" command testpmd does not call rte_eth_promiscuous_disable(). As a result the TAP PMD is trying to add tc (traffic control command) promiscuous rules to the remote netvsc device consecutively. From the kernel point of view it is seen as an attempt to add the same rule more than once. In recent kernels (e.g. version 4.13) this attempt is rejected with a "File exists" error. In less recent kernels (e.g. version 4.4) the same rule may have been successfully accepted twice, which is undesirable. In the corrupted code every tc promiscuous rule included a different handle number parameter. If instead an identical handle number is used for all tc promiscuous rules - all kernels will reject the second identical rule with a "File exists" error, which is easy to identify and to silently ignore. Fixes: 2bc06869cd94 ("net/tap: add remote netdevice traffic capture") Cc: stable@dpdk.org Signed-off-by: Ophir Munk --- v1: initial version v2: add detailed commit message v3: textual fixes to commit message and code comments drivers/net/tap/tap_flow.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c index 65657f0..551b2d8 100644 --- a/drivers/net/tap/tap_flow.c +++ b/drivers/net/tap/tap_flow.c @@ -123,6 +123,7 @@ enum key_status_e { }; #define ISOLATE_HANDLE 1 +#define REMOTE_PROMISCUOUS_HANDLE 2 struct rte_flow { LIST_ENTRY(rte_flow) next; /* Pointer to the next rte_flow structure */ @@ -1692,9 +1693,15 @@ int tap_flow_implicit_create(struct pmd_internals *pmd, * The ISOLATE rule is always present and must have a static handle, as * the action is changed whether the feature is enabled (DROP) or * disabled (PASSTHRU). + * There is just one REMOTE_PROMISCUOUS rule in all cases. It should + * have a static handle such that adding it twice will fail with EEXIST + * with any kernel version. Remark: old kernels may falsely accept the + * same REMOTE_PROMISCUOUS rules if they had different handles. */ if (idx == TAP_ISOLATE) remote_flow->msg.t.tcm_handle = ISOLATE_HANDLE; + else if (idx == TAP_REMOTE_PROMISC) + remote_flow->msg.t.tcm_handle = REMOTE_PROMISCUOUS_HANDLE; else tap_flow_set_handle(remote_flow); if (priv_flow_process(pmd, attr, items, actions, NULL, @@ -1709,12 +1716,16 @@ int tap_flow_implicit_create(struct pmd_internals *pmd, } err = tap_nl_recv_ack(pmd->nlsk_fd); if (err < 0) { + /* Silently ignore re-entering remote promiscuous rule */ + if (errno == EEXIST && idx == TAP_REMOTE_PROMISC) + goto success; RTE_LOG(ERR, PMD, "Kernel refused TC filter rule creation (%d): %s\n", errno, strerror(errno)); goto fail; } LIST_INSERT_HEAD(&pmd->implicit_flows, remote_flow, next); +success: return 0; fail: if (remote_flow) -- 2.7.4