From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30061.outbound.protection.outlook.com [40.107.3.61]) by dpdk.org (Postfix) with ESMTP id 2A2081B295; Wed, 14 Feb 2018 12:32:31 +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=VPRD8ekahS3VBcmxWTsUIIvupI5FzUicMHmsFtbpAiHogiZOr46EY/IrW1OmoFLfBytk8udlKW92jmIhFOfcNzdRdP+ocT+nbR1wrRCKe4UJFIWTFr6y7JyMyDkBaQEcILJEKSrFWX/xmy60OWzDBizID3p7nJvcnPYQkm7zf/4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0502MB3884.eurprd05.prod.outlook.com (2603:10a6:7:87::27) 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:32:27 +0000 From: Ophir Munk To: dev@dpdk.org, Pascal Mazon Cc: Thomas Monjalon , Olga Shern , Ophir Munk , stable@dpdk.org Date: Wed, 14 Feb 2018 11:32:19 +0000 Message-Id: <1518607939-29121-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: AM0PR0102CA0059.eurprd01.prod.exchangelabs.com (2603:10a6:208::36) To HE1PR0502MB3884.eurprd05.prod.outlook.com (2603:10a6:7:87::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4d86650b-6860-4a15-65df-08d5739ea113 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:HE1PR0502MB3884; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3884; 3:+IMqFeIofkmCW9tBwkJEsKbZq8vVWdUkkUFmAqmlVdzXO7Y4VEqQg3g1K+W6CgtB7bAxryjUwYllLhsUJLk+zv3zYGgejC2UNrXE2NDDAMfB9WI1b1DyajlIJsgyzwORHRj5qayxWWcp62kXMRto0lb//3P3KE85oH39U7RAdY1vUTpoCRZS36Ql7kQI44s9aSEPZsYwQk3khw40oTc2F/AtnemY7X3Pxp3jVJ3aUeF2JQtrVRUHeumaqZ9rnsxi; 25:NnIcyCnq101Df07N3LTMTNP9OHTDDPLLUH6gYIOwUYh4qZy5tL334SYGRxRa27EDJwuDtXBVWQc4obakFHdvoRLdh0i+sJaPbU2yVYU9eAFW0ChEtv/w925TSmuwlGah0uUbEN79cxCx1HGSJOUUqm3KDgHSo9q4zpa9FnAH/+31/E69/5tNLuvIyFdEoDRuE7YQ1suWAGGe3vl7JHWjf0ccwS1M4RX4TLyz7m+Cdn5k0DA6XOl7zfO80qocuqqGlXuqp9EPVJZGUBUPAsXEXVacroRxI+cJc7dL1wvNO75KGIyUqI4AOTuaQ0okFKd6J/qEymxQ4qEql1yTMM9pVA==; 31:WQ+ezKnfj7BO95208K9GVA6E8BQcb+URhcxMNI3DXsnQAXHeL2xIjWQ5Yj1HdHMgUlKUqeoHAmg3cftI2ydSI6aJiSkqI/Puuskvuk55Cwa9anc5tVSNslThdATh4D1H4OPNz0irGLY8laieJYQlNBTz1Sm6oo8CJ/MgpepAiTjMTDHCFDRBYl9guq68kqgs4bgbXXsel+Bhi3nSkldQ9NpPrdCxGdkPpmhh+Ykxl88= X-MS-TrafficTypeDiagnostic: HE1PR0502MB3884: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3884; 20:/lyYFb8CQhbjX6ixJ4jVIDrmYU5P+KFFWK5JtmoRrNKResWYjRVHiJpDKIfPuNnDpcaoPF5nvMOiP9A4St8hiEBdNGHVv3RNO2673hxeLT5JWcKtrvH/RW9NRy/Ta0qf+qYjPGCw4kfuz41DpvdL/H4cIKAOtuQ63FVFhRApHpdZpH9w+6m2u8Gs1uIgrI12Si8KT2F1T/ku03mxNTSyQFbqQbtn/m3GUOiyria81sGsHLy7rQFilbd5k+p/P70nImY0SbAZL7F0YFe8ofajogcFRac+XkizBYszkVtSMAtb5azXpo6j3WQDM/n7f4uZA45QvfzRJOe1C8j8Js7F5BSMGfySg8ulH/5FVlsEU4qQI7UgZOE6CCc2549Os/qeMWMQE6qahHcvy8rwFMfX1OhEfMKFIVOrwShVBNabzoWj8TToa5Cex2ldTdovMpPdLn2EmygAg1czrvq6L43/FK6DUCZxccXQN5q7SeihL0AaCvyTLGxY94z/bd2SmQjD; 4:ITUC3weWdPsgXuqirmn9X1MkQfqcJ5Qo1zp2a+UbfXgU0pwSwN8nk+0Kr9JaHi35kTnGlBthh2seO+S2Oo66S+eJOM+5s33fmvYA7aGVqHTAG/D35jczyfxvElKbZiaX8YRh067HKont91qqJ/vw+p5IRvHsy0X7m2Xgv+94bCAEif0h4z57QsnEgKl/tRBXxFzM37/IiwWlDM/YWLYZFsbucGPnq3hheKZcEI3Dt4bYlwVUHiAWjs5RBjeZ3ffZjTaShwKEgtqQ2tXa22Rx1w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231101)(2400082)(944501161)(6055026)(6041288)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0502MB3884; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0502MB3884; X-Forefront-PRVS: 0583A86C08 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(346002)(39380400002)(366004)(396003)(199004)(189003)(6666003)(53936002)(26005)(52116002)(4720700003)(50466002)(478600001)(8936002)(51416003)(21086003)(7696005)(50226002)(106356001)(36756003)(55016002)(2950100002)(6916009)(66066001)(48376002)(47776003)(186003)(16526019)(16586007)(2906002)(54906003)(3846002)(68736007)(69596002)(6116002)(97736004)(105586002)(316002)(8676002)(25786009)(305945005)(7736002)(59450400001)(386003)(33026002)(81166006)(81156014)(5660300001)(76176011)(4326008)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3884; 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; HE1PR0502MB3884; 23:XhqBcpZIHo6TFD1F+GMv6bKWdT79oIR2v0U6ZX4?= =?us-ascii?Q?YDDo3oMnaudYPcziPMeudbouo5SzSqyi2BQuG7ChMWVbldY0wErScH4U9ppd?= =?us-ascii?Q?/okezV5uN1CW6vT+Yrsl9Iy/YQPcVUQO3kcfxT93YWZQlye2PKgW4/BMKc0U?= =?us-ascii?Q?bwlcNkbaH2Mvfmoq7zjOurrIuSRVhvDkF1FdqbUpCDQ7BtNmV6yerzUnAeHX?= =?us-ascii?Q?KsryzeFYiRcNjmvuo75BU5xS3igVJYy8hmgGhdZh/QLuNLD3JpbeY3Dv7UNQ?= =?us-ascii?Q?qmRff0HyMPbaNHqRgbtqLgm44qv6r0iEphIrFlHX/mr0LTXlHKZDkbCi/klK?= =?us-ascii?Q?23zVRdRKjh5AI7OTD8pxuewdIQDLEHGlZGOLm/C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soft-Exchange-Diagnostics: 1; HE1PR0502MB3884; 6:ToC9rD6jAPi1IRZrMhO4gOYS3ve9STbwq1z/XCJ4FpV0ixaUbWrEhupOYAiyqsDgjJ61eL6dKIy01pzqC8LmVYSWV//mi7OCWI0vLitkk+r/oq61gQdHJecVRCG4BRL/Jy/pfabckbiMppk0uKtrspAQ6HPCAlJaiPYjDmD5FCfirkq4l4I6uZP3wUTgXh8QxbdB3vx9aSnZwfFhEnFz0v5OSFHRq7w/+hI39eD/w7bqPxKRMG0l4LcnZps2hFt8JV7x/8l5lY2ZbjI87JM8DlGtyEXjaecLHQw3Tl6hyjsWWBxR+TacwqHWHBiSKy+o9j81PAqgTG6Yx8d0eejtIGn03G36plVph0w84yEAc0A=; 5:mCG4PlwnAslt5S9E+Xn3Mhjtuf7nmj33r++OyBu8gisA8fmObTHDLuWIn05YfEj4yzvU9+Pj49o079xR6GHdGSG+gkIuaL+mXrD32IoQN3Lr6/wkMoKW/jYZh+shp6V5Jzhl2lJCDu91XAnR6c83/x+vBCfEOA0rTrRW8xbI0yo=; 24:GkgdRSM+Cx5xZQi9LFYAXhwafKMB2tnNecWpUDgFYtuzgBNgrx1FqX0wzOd8IXKn+UU4iUfZFxdroC5TMLH/x8hZCfpj1uU3El9m8vS3W2U=; 7:F8w9hUvgcasOf3h2uzbtKCxkbjtbkI+dbkCypJr+P4Ziz1dt8ucfYV8uERJo8v7aww7ZPxjBc+05G8VuWIFnWkfZ0E+eyxr4GV0nHSYQ8KHsaGVOYUxMmuWmL3RFahzbiQl3Ag2Iuz3xmiHLvvJad6hqiJw+RSvh7OZdWi6L9uC84mzHik4SxFNKuHMDMfsba0E2PW8P/6TNXActxvsaGgVSu+H1f8+lC201vcXK5O/pZ+Q1w+Usx5gp7UXIn4om SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2018 11:32:27.5816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d86650b-6860-4a15-65df-08d5739ea113 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3884 Subject: [dpdk-dev] [PATCH v3] net/tap: fix promiscuous rules double insertions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Feb 2018 11:32:31 -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