From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0057.outbound.protection.outlook.com [104.47.0.57]) by dpdk.org (Postfix) with ESMTP id 95205DE3; Fri, 25 May 2018 01:11:28 +0200 (CEST) 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:X-MS-Exchange-SenderADCheck; bh=aRqTSSes2HVkKmCxapCyFAZ3ykEDz9kLUFZo0L08bzE=; b=gdG/4wLd2lNEfKxrjQ/M8jKbce5OVqBS36cAZTttGhFmBJ+v4BtZQ3ISEcQbi7UU4DKUNxtKtoTJaVUbpowh3ciLw6JcEQVF9wklKq11iam3SSauuGXDdZMD+esMJ78gU4wWrr3eAOEA8YcMqFAUtirRGh4D3c0kYSlszNvqA3c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB6PR0501MB2310.eurprd05.prod.outlook.com (2603:10a6:4:4c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.16; Thu, 24 May 2018 23:11:22 +0000 From: Ophir Munk To: dev@dpdk.org, Pascal Mazon , Keith Wiles Cc: Thomas Monjalon , Olga Shern , Ophir Munk , Shahaf Shuler , stable@dpdk.org Date: Thu, 24 May 2018 23:10:40 +0000 Message-Id: <1527203440-29861-1-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0701CA0031.eurprd07.prod.outlook.com (2603:10a6:800:90::17) To DB6PR0501MB2310.eurprd05.prod.outlook.com (2603:10a6:4:4c::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2310; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2310; 3:W8QQWMnRQYqhFns1EboDnsApPc0p73QhwbNwl2fRmZLvWQricjfFWMpqzsCFFOKkBNPstalkd724m2dvHe7JtxyY87lCTNnvqr91D+0X3myIOz5KzT6qUutW28WSWo/iuNs+RngYctvQUe9lK0rkZ1dTC4PlPkWc3I0AIMhbRQBWl5lZgFbPMgmJnN1FZzlPS3tsWXuRXYB0EAbVwXFuuUdVvCektvWrOy/k1BBzfCF2zi84esHRAhmkmmUs8yoZ; 25:VPdQDv8MJpm2eTV+CboW2m5ETorP8w1imfA7BCwlwlJanXy8C+npnrEnpOmoxOeIEC7WSYddShFDiFm6nW5ykmY1KxtYlRaxmeQUBPeJecNSDLzYpZljaSe0ICzpkt85jLFpWi4HivvGG+Y/EZzzOa+fY0T5eR8Th6TUlo7wqowYPDmNxUbwEmMYtAPH2/6WP/k0KJyfG76yNar1rRknbL4ijxVYzYSsBDc1B8SPyDO2sjWe/0LlaNhy0K7/3OuLqTyKp07/bTkpEPpH8N1BftSZoivIrA7LdlfFTFYyz5oGcfDVTrGMPL/VoqJQf7hq8GWAC8UDKkjQUoVReFWeyA==; 31:PWovA7Cn3DToDdI6JfeWrDiWiM3+BMWBEs9Ns2B18s/Kq2D7+epnRPxHviURohbASuEDNLrAhIo8yg7lmzkfWiw+rz7mUY+lWLUrNON8YKpQ8b4wwqUGI3rycfaQVWpoUTnCLDIDFITVezynkZl05+4B8+FZdweoFmIerwMT8jw7SN7p67GLpm3pHJl5hdnVShiXeWGzRlAL3C6xM7oNoHkH6gxsijSeoibUPP2IGWc= X-MS-TrafficTypeDiagnostic: DB6PR0501MB2310: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2310; 20:LTL51/BW3QAUzRpmMq4G+wKT1yt4knYXJ1rnqLMrXyZ8XTlfYhsiUAg5liUqzV0tpuaqV4/oNrNNJsrqAQ7TRBX34MBmNiMN7C6kwWNbkga/4eFrsCiiHMdfv1er+G6fRLaRhU1bAW9aS3JA013tQQb5EWn7T4kjnUib/LaYr5+ysRgLbwteRToSMcNjwdGzllTuoRWxpXOQ70Ry2viQeoCI7x77/2nAi6bRXJnshbjvUXOP3HNLO7koE5/uvc1dmab6TiuMR1n1DlDKxE9nauYHM2n0hdlYiSZq/zZYE4IolbTF2wNZYgc3TDhnpVHPwOvr0tyCPMjEaKQQA5NUwVwC7q6us5uWa7PhSlDuNCTPsgP68SyaiWDAyBeFB4BavO6cPgQNLmHAMubLlmu1P1Vc3vt66p9uHdpi3gtmyNpGYduCkhR9W0UmKZ1UJnd6CYavtmj4blDsdHjEqkDBUDeOGEQbhL8cXGykZKcQFSyyHF2J8UNUimLqwr1OdlVW; 4:LEechmlznQF1IbZMoGKRYI33gL5VHb+V0qBrQ3+4LkAdCfluHZCG4Y1gXHad65dTvdahjRxFtMcNOgafevLAgphlmdJtNLfJ1BEfxWeTla8LYebER6KHTWxliNGi6TVk3JxbfBU5b8HhpgXvhQaC8vpj/gZO2LKjmhiVVx8w2KWSEoaKgovSUK4s/cDgDCpqA7JPOS1VRK3xyePRvsTR5jkkV6cqPrLAqn/pil7T9Ld+ONWpWGj0q0owLiFoA9kADwU3AwzDDRn19vIegNZxXA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DB6PR0501MB2310; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2310; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39380400002)(39860400002)(396003)(346002)(376002)(199004)(189003)(2906002)(4326008)(50226002)(476003)(50466002)(8936002)(106356001)(68736007)(3846002)(4720700003)(26005)(105586002)(486006)(956004)(81156014)(2616005)(51416003)(5890100001)(81166006)(36756003)(386003)(5660300001)(6116002)(8676002)(48376002)(305945005)(21086003)(7736002)(25786009)(478600001)(69596002)(86362001)(33026002)(186003)(53936002)(47776003)(16586007)(66066001)(6666003)(55016002)(54906003)(7696005)(110136005)(16526019)(316002)(52116002)(97736004)(59450400001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2310; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:3; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0501MB2310; 23:XqS85OeVeqeoTPt/wMH+h1YaEpCf8eXqjcLz6dR?= =?us-ascii?Q?qvstdgSCgw/3ANJKBjFehBzblwUIzWULxTnHDyRlG+b9ZhocGTeS1rhPtAv7?= =?us-ascii?Q?LBeHNkXr/cUlBtyjITn6/qsUwkeeBHQREzkI+91Tc2hhrRb0hM1mNDfJTno/?= =?us-ascii?Q?u8y6Wu2eKR6mxicpSOTQmXUTquZpoU2ns50Q1RbDAgmBmK/DqFAEIq74UVID?= =?us-ascii?Q?eoMKC9CHVTOV/GlX5Xa9KPFZjpMMZtEKtnTddZj8BDyrjaxS3MZj7chKrfpI?= =?us-ascii?Q?NQm6tmECukMPQ6nmCX4uc/qHrzYMy9PwHRbyrY9TGSnkKO/Vk1jcnxPTKPB6?= =?us-ascii?Q?sdQo+HewLfWlSHcIS3CQS5UXY4/DhwuKxhHhjAV9LXM0J3L6Uhx2AMC3XfLd?= =?us-ascii?Q?l1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lW?= X-Microsoft-Antispam-Message-Info: H9amQ4E5eHshkOHnoVbEnETyqW+95wdckj7wrjiIUXItCDiHxjJmI7xh64C0SubrDy2202qhH6QvPdCD2WXu8VT9miYgaLADF4tAiTRK+NSwxKqyGQ9i9yw9qkXiT5mCxaAfpKMCyRPi4/v+6hJL3Wy/ZUJUPbKk2hI3Vd4pP7nSRTzNzfd3XSXAaDK9F5JR X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2310; 6:qqUWvtAl6VF19ohEcQh9cZ20v4K2ekUOsKeN3H/p2THA7EPpA2xCbrxse04AnlvtnC5Ynharat8ggTo5pDso266yK7WaCpmSgclDGneRVtGf0wxDXw3PQt3EWs0zgElvz9CX7lRUQ0rIMkR3fW6j8sx3SA+Wbwt7EWTpEPEN63CXwwFC+nZCBN85KIq8oh3WH0bDtqoXLLp2dV/jDDneJsKNryPbz2RG7IG5brjPPaXL4yXCZ9VHhUypDJMh1QC7azxTAFSPi+dgknnqqi2eG5DgUm7K+XA1blYYAJ7aQcswcjNw+NNPNmV8/EqT0OOSFNMjRHMbFLx/WLFWISY8vqlA30C+R1N9HmnKWbA07yxBOrYALB6SPY7mugRp6XmJVFZfssiY3H9GOhFNj96hutGjAmoHHrtZhbUcQYvwYwfiUzVeIY77BFEiA49lEZsj/29y1e+RbiNhM6clvX/Pyg==; 5:fxQOYss6IpMRKH17pd25zW1WvKKeB7+2XjuLYMyf6cxd3DxITj8amfZcOwMvn+z2dibGwt9zxJwS4sW5ONKQMyoJOhvTJ+AzF/fFijgv9PHlfTcafT8u7fbAp66zLd7rhfnIBi6Vp3VtAjfaSr3UvaqOCEB2Khu8NJNBuVOeLNE=; 24:GVrlr1baTGjrpcZtkVBqr+Opq8I8hs1rcEr3hPMosh4r5Srj5EmA01MV5myXenjdCLfEw1sy7KpoYszN0byvID9NsmCbfWp/XTLLIzmtHJw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2310; 7:RV7yN01wDh3mxY1jsV5sL4d4kYcF4fohr3PR2pu44qbc2nfRMy8YHDFg++YB1QIW7xEY9K7HXsuep0Kklr+fYA0phlFZUZs5uwYOjWDgoPmagxZIZw+t85oWY2OnjxwI+lrm+6J/7Fb/sONjYDUyX18Cglk7l7AthJQeYmPpcChLBPeV4OMDKqz7BKNYw+El0t6t9NDUSERv94DyUaCBn6sLGb0s+A5TvRROP/xUgV4gVh6xB8gYiGM+KJcSPpfI X-MS-Office365-Filtering-Correlation-Id: 4388e413-ea99-4702-635b-08d5c1cbab2b X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 23:11:22.2999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4388e413-ea99-4702-635b-08d5c1cbab2b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2310 Subject: [dpdk-dev] [PATCH v1] net/tap: fix keep-alive queue not detached 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: Thu, 24 May 2018 23:11:29 -0000 The TAP keep-alive queue was created in order to keep the TAP device in Linux even in case all of its Rx/Tx queues are released (in Linux terminology: even in case all of the TAP device file descriptors are closed), however, the keep-alive queue itself is attached to the TAP device like all other Rx/Tx queues and therefore the kernel will enqueue to it some Rx packets based on the kernel RSS distribution rules. Those packets are unknown to the application and will remain lost in the keep-alive queue. All queues are attached by default to the TAP device after they are created though TUNSETIFF ioctl call. The fix is to detach the keep-alive queue after its creation through TUNSETQUEUE ioctl call. Fixes: 3101191c63ab ("net/tap: fix device removal when no queue exist") Cc: stable@dpdk.org Signed-off-by: Ophir Munk --- drivers/net/tap/rte_eth_tap.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 310c7d8..c3af608 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -95,13 +95,20 @@ enum ioctl_mode { static int tap_intr_handle_set(struct rte_eth_dev *dev, int set); -/* Tun/Tap allocation routine +/** + * Tun/Tap allocation routine + * + * @param[in] pmd + * Pointer to private structure. + * + * @param[in] is_keepalive + * Keepliave flag * - * name is the number of the interface to use, unless NULL to take the host - * supplied name. + * @return + * -1 on failure, fd on success */ static int -tun_alloc(struct pmd_internals *pmd) +tun_alloc(struct pmd_internals *pmd, int is_keepalive) { struct ifreq ifr; #ifdef IFF_MULTI_QUEUE @@ -154,6 +161,20 @@ tun_alloc(struct pmd_internals *pmd) goto error; } + if (is_keepalive) { + /* + * Detach the TUN/TAP keep-alive queue + * to avoid traffic through it + */ + ifr.ifr_flags = IFF_DETACH_QUEUE; + if (ioctl(fd, TUNSETQUEUE, (void *)&ifr) < 0) { + TAP_LOG(WARNING, + "Unable to detach keep-alive queue for %s: %s", + ifr.ifr_name, strerror(errno)); + goto error; + } + } + /* Always set the file descriptor to non-blocking */ if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { TAP_LOG(WARNING, @@ -1020,7 +1041,7 @@ tap_setup_queue(struct rte_eth_dev *dev, pmd->name, *other_fd, dir, qid, *fd); } else { /* Both RX and TX fds do not exist (equal -1). Create fd */ - *fd = tun_alloc(pmd); + *fd = tun_alloc(pmd, 0); if (*fd < 0) { *fd = -1; /* restore original value */ TAP_LOG(ERR, "%s: tun_alloc() failed.", pmd->name); @@ -1425,7 +1446,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name, * This keep-alive file descriptor will guarantee that the TUN device * exists even when all of its queues are closed */ - pmd->ka_fd = tun_alloc(pmd); + pmd->ka_fd = tun_alloc(pmd, 1); if (pmd->ka_fd == -1) { TAP_LOG(ERR, "Unable to create %s interface", tuntap_name); goto error_exit; -- 2.7.4