From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10089.outbound.protection.outlook.com [40.107.1.89]) by dpdk.org (Postfix) with ESMTP id CA2F11B05 for ; Fri, 25 May 2018 01:09:07 +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=Wj65Vsu25JGae2o9UcV9yTN+sAh/FkZ1CiicXyB0w/QD1H/qv0L3SZJtFJ+pYKlWL4XIZs1iQdcAzW18NA+EYbIYWSXt17shEYq3cSVJCukPFXQqJASRrBrIE/DJszVlr/ConAA73RZlRDZVAbehp2O78WP68yqldVuXtuBQx4o= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR0501MB2307.eurprd05.prod.outlook.com (2603:10a6:200:53::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.797.11; Thu, 24 May 2018 23:09:05 +0000 From: Ophir Munk To: Ophir Munk Cc: stable@dpdk.org Date: Thu, 24 May 2018 23:08:55 +0000 Message-Id: <1527203335-29760-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: VI1PR0901CA0092.eurprd09.prod.outlook.com (2603:10a6:800:7e::18) To AM4PR0501MB2307.eurprd05.prod.outlook.com (2603:10a6:200:53::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM4PR0501MB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HoaVXq/0LfUYWLCpAyRzhsCp/vEByExhWfVav4Y4F+bkH7duUQLGWpPb1jlIFo+awM7u+w2lUWXXHKlfHVsh1uVvy0TWbawTtxQ63dOCIn2pzWn6zXYes+o2rUZIsea1fwsWv5ooCgtXPfe5pA7PzcbnK999OF+Zc3rjaR+8AZH2KAyWHL/zLsQ0c373FxWef4UppVdMH3Ng1lR5OcxZ2BFmAtMPS3n3ASn1O3P+Zi5vbWb1JClw4xZrjNPlMd1otoPY0LmRoNeiKzTE2sOzcKpxlN/cNmZy9/jxfODE8SZSANzqysxyqojHmY4bBATxqiO+/SgLs/xYRSZFx4dabF9Sb7579OemiKJ0V3H2J9LTFDPCiOGuzialZijIS1AphahDgEPY0GDRR7o6pctDK; 4:Q4oBj4lcAmv3PD/uhckcv2c7EDr53hf1CTwLOoB7QCBwsBxLKrSPWCZQjj+lyuv115N7/MPYp9bVdquE6jgwFaQD7zbrpmLa9vix5VFjRFB50HzRCHRuOdqozLPLzm/MsVuNz0jhRCPKda04rlDMyaWrkWyA7JwWggRcRurYPpsm3Owo4U7XbWjLtNR2Gm+C93vZkEHRs3sVKXHEj1SY4ZSWYgVVSoeR0HTjopu3h770S7xTICrMIqKXJY19NJEhBQCEjPVQ/ehalcnJhWe68A== 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)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM4PR0501MB2307; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2307; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(39860400002)(396003)(346002)(39380400002)(199004)(189003)(53936002)(5660300001)(8936002)(476003)(2616005)(956004)(4720700003)(21086003)(486006)(6666003)(50466002)(4326008)(36756003)(6862004)(66066001)(386003)(59450400001)(68736007)(55016002)(305945005)(86362001)(51416003)(50226002)(81156014)(81166006)(7696005)(2906002)(8676002)(52116002)(16526019)(7736002)(26005)(48376002)(105586002)(106356001)(16586007)(37006003)(316002)(33026002)(478600001)(97736004)(69596002)(25786009)(6200100001)(5890100001)(7049001)(47776003)(3846002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2307; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0501MB2307; 23:C4pBB3hF8UwraB47egrI2KLQ+36MXhGabvIZH2C?= =?us-ascii?Q?jRVi9cIDTKFG8pdwMcPljSPYkvUS9O+s6qfvq9wkRBQbpIM4EL7ZWNf6GJls?= =?us-ascii?Q?7ZXqMoECERIuavjJNSiffya3tPMDiFFoMJfpyk/yPTYFlDUi81f6Lrlat+kz?= =?us-ascii?Q?0r/xsTo94i9IOWUbjXyg8NWK7If8psyOllvDqAUUgZdb42VxKghf4JovB/cY?= =?us-ascii?Q?y2/uK/Cycyqeio4Xvh+W21p0VBWSx+igC78IfN8+gtBAP3dU2EfDDCEdHmh/?= =?us-ascii?Q?tMp3OSl+gubUlvfQFrp+rUtso6BwZejnhWiCXllI+vDVJhhk2zcSjJxZvl8w?= =?us-ascii?Q?G/w3owqKt8h0tS8tDUk1YpJxK5kptL4KEwzZP1qdvs23yTNupHeST1O4MEjl?= =?us-ascii?Q?GpJXsBUizN3zlvsk+f+DYGkGAtICj+1CyEhFffHpWrn6uZXBzGZFc390fDCp?= =?us-ascii?Q?JYoL14WHbFPozX+/kl4YoJ+mJN9jTAHc3vvZ2rdfn1ptoAiH2xsBITSmocqh?= =?us-ascii?Q?IhhekjeMvs/1ovldPDVPfT3Vh9YGaNpjgMq2JwcNKsWnnkFsCtGBybZVyB5O?= =?us-ascii?Q?f6XtIijOYWUIZbq8dl6bEImPQe4BaeEnxAiGsl/kNK9BvzSXMjbh12tB0V0Z?= =?us-ascii?Q?qCEXru4Xey+ZrpP/C/x3uL484RBFUZFSky+29bX1yEcKEWQzQHf3YLIAfZbY?= =?us-ascii?Q?oO6Q+DQ2B6zFmf4h/IURIkyUKjCxs2wuQrq+oJkQaVJoWT2n+GFyI4Z2HwWX?= =?us-ascii?Q?hpUvmWPJxCg2nMhQszKZMxsEmi/bu3obpcZtDlS78Rhrg2D14pdBA7TggTCs?= =?us-ascii?Q?kVCuORGiCawHuqHf/9VRVYTso/aUwPA2kAE3TmUOPypH5CKbSxQlW45PPcyV?= =?us-ascii?Q?EubuHQg2AYkhUZzCTdkTOLZKfn1mabDcsEcrBD0jyCAbpAdL0idnLVkCtsT8?= =?us-ascii?Q?rhgBjKQMBntJDvhYXhQ4HxdHHYrujpgXQPiCo4h474oO6d5HAzpCJ0u8xA4Z?= =?us-ascii?Q?Mi/+7Lyhwx2gSj+MwWBTVtSiWwFohPx8UMf6+z8G5PiguRZEEK2LmJqALDif?= =?us-ascii?Q?5MSBx2c86wgkY1rwrStZ8NGlExyVh/49Lp88x0qTn3EyMmmfTwartvSt8FJE?= =?us-ascii?Q?KjOE46xPdoI7Qoiures64BHE1Pp81D77syOu4I61ulOeHXWIpj2dBivvawht?= =?us-ascii?Q?3sf8radhHPHJwZW5CPUXjBvUNx2pwLPuvEzw1StsgLp7RSgszoTZMY7w8hrs?= =?us-ascii?Q?YcoOOz9PHmi3wdKHFaGNqel+1TxHh1MzwxRicExVRa0TtMhP6c56M3xXXQR/?= =?us-ascii?Q?/kg=3D=3D?= X-Microsoft-Antispam-Message-Info: +ajwoMuZRsVFnmv5GJiOZSE2tvOwcp1h9YkoKORWvsKl5hS/t56ch1qejF/ljAU92610hAFehbt7yCAP0sP+yygp223IfFe0JYJnFMWeOAnNkU//1lvSSXDDlM79jhwSNDd4ppZ8Vg3P0+VFTyKW9lF8l7/ZDhu2VvnqJmmIGTIdIUr6bqsIkoJZkWyHMBr9 X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2307; 6:Hih8m7cnDnhxHTZ3oiWx++fJHSdV5J34saBntG5kJulcanxGxqO+xRGMHMX7OusEaHkQ7wEnkNni+DqTJrE42WuI5gLmVlv/m/3W6fKQLGQ44AV2BfOLIef7AKJEsx0GeuSMyr/eTuG6gjYxDsSxTS9F5MeFLW7RhZ4UY1L6jzqextMENZZ0AC5gA9KA+GBOnbdWo65+D+jmkWZ/K9MihYOyBi4YAclQOL8J067vGCQM+y1lFsA2qqRS1TtFpq02OMC3JzSdQZozdH0r3YOskl+uce/DhjEh4kMlC6oeemdOWnn/QsfQPb3pHi9XmYEcxF+O9lRDKditrt4YpNSq8en7AVoQozYpcFXfMb7SMA2xBA8jo6HkzKK6klAbYQmz3CE25e4rJyuMXshdK0JBjtrGfwz/zvf2HR/3S/n58kU+TvTKZI2yipAjybBtEp9+QZUp5hhmbgtEoHe05IWmZQ==; 5:fr0M+DGLRT7VBVq960wuX1d/zSo8DWPTLkvIpqYudo4cB9wRK+p58SkS0sBv0jYPPDLiRizYCLCRH4JIqNT7MXZOZmLmrXu+HjVTe/+seM/cBcPLAivlt23NJ2LtliFpZSTzArti0N5yYmvHbKvQt1kK/1Y2mcMyvQZbVYgAQZk=; 24:YOCsXVr84hxtPbuWMt4Q7uyNcZTgvMdwE+SJndepRAPspyE3uoLy3neXQzHIJYUdWNauCKep67C5TJiFa6nceVIBUklBFoyV/+s+O3NRPEI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR0501MB2307; 7:IUARLIEv7CHVe7Dk3+OSBfaTzOCkqPbUvn7ZZXDZhfrWkPiX4K+2cEH7LFvknbRBT6Js6YcODHo/+WfRayX4ixAOnUzx1IeDovs1FK0bpjETHzrUFTnWdi0yq4EI3nFs93DmqFKvz52Nf3vp86lCV23zFgnqcb2iCh0+unIYMELhEZdAxTdcMpdthiXpAEp7pM38iWzKBf9K8rr+k3Y1ppec16QDWAZj5G9SjBpOLFDim/c4rfm9tgJGcHTQ/X8C X-MS-Office365-Filtering-Correlation-Id: 437cfdab-39dc-4c99-e89b-08d5c1cb58f7 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 23:09:05.2956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 437cfdab-39dc-4c99-e89b-08d5c1cb58f7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2307 Subject: [dpdk-stable] [PATCH v1] net/tap: fix keep-alive queue not detached 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: Thu, 24 May 2018 23:09:08 -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