From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0086.outbound.protection.outlook.com [104.47.34.86]) by dpdk.org (Postfix) with ESMTP id CA069691A for ; Wed, 3 May 2017 13:21:35 +0200 (CEST) Received: from DM2PR03CA0030.namprd03.prod.outlook.com (10.141.96.29) by CY1PR0301MB0906.namprd03.prod.outlook.com (10.160.165.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11; Wed, 3 May 2017 11:21:34 +0000 Received: from BY2FFO11FD007.protection.gbl (2a01:111:f400:7c0c::104) by DM2PR03CA0030.outlook.office365.com (2a01:111:e400:2428::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11 via Frontend Transport; Wed, 3 May 2017 11:21:34 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD007.mail.protection.outlook.com (10.1.14.128) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1047.9 via Frontend Transport; Wed, 3 May 2017 11:21:33 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v43BLPtl008454; Wed, 3 May 2017 04:21:32 -0700 From: Hemant Agrawal To: CC: Date: Wed, 3 May 2017 16:51:12 +0530 Message-ID: <1493810472-668-5-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1493810472-668-1-git-send-email-hemant.agrawal@nxp.com> References: <1493810472-668-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131382840937681389; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39400400002)(39840400002)(39860400002)(39380400002)(39850400002)(39410400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(81166006)(33646002)(356003)(76176999)(2351001)(8676002)(50986999)(105606002)(50226002)(4326008)(77096006)(5660300001)(85426001)(189998001)(47776003)(8936002)(5003940100001)(48376002)(106466001)(2906002)(50466002)(86362001)(36756003)(53936002)(305945005)(104016004)(2950100002)(498600001)(38730400002)(6916009)(110136004)(6666003)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0906; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD007; 1:UR+U41yexXLx8OknjXsVyDl6K6RUPUzRRRMPCWMmpDZSe0H15B8OXh70/vmrfsXeBMXOv6BI29boZCGeANSM7MdloiY5NO3HV2jsb2E6UWb/Ch9ayIVaoUHX8NdbECXEgjcnvg7IByZaNvYHjoHtvy85XA2ZDxqpd9PV7ZWnh3ZJVQxNk5YkdFW1VaOzGrSP7BJwQeQcFvVe72TLt7PZCo3SvYsZmJgysZ5GD4z1/75yzs/g3VH2BdSBakt9q2CgWE7qogRcGRob9S1tGiBkcZb1l9RRnPy6vWuQTWOnSeQOQQZmYw0ffZYiyFdCKyEc7rTrkMn7dj94MeH2THwKOe+d8S9IhpxiOYzTNLccb8+0iekld5/wXLP65eS8tl43t9Zsm1KCJYV8J5syQI7gdOoOXTlE34TAGUpbnU5m6ezrcyXw3hLZIAIXe+K0hGUCyhFPQf9cRCy6euobQ4T6tNZKl1HFfzuJsGRxogVOF02CG4ATK4TQOC19aydKkpWoHoOY2d6ZD+2+49L8xNtoFongp75rko3ehooumjkaGByE1Y3lhaHp8wjzaGiiRKff6csbBWb3/+LD366X3INXL5gyE9qe/2MM8MurDF7ZvyBaY7FIc6mKAvrxQbTiKPPiwTkmB45tFEaxrDL71Dw9zPcfQq9nZ2KmR/XgDZaolw4= MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1d7c3a0-8d96-4cc4-a584-08d492168e0d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:CY1PR0301MB0906; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0906; 3:yZi0wOJnJ0at/9h7birAYeE0xUw5znM7ipkjPlJFnnNhTqWJCYIcXt8GoVN9jBuvi2AzIdp411x6N71qqmVCQDt3PWeSbW6dMNuink4oHf+j3+o+QhAbT6EOrHq53LIbkV8/+LBwsmrzTZrvbciLpT4bhRR8+JVtEoNe8o2GdLLXXth3PUR+1WOzhLj8ozGki0HkWN0mrlPjQwOtWtm46BMW38KRceQUoP7tgyt7j1YrdjTYXjg9ntjw68R/R/OB9Vx4wQNxzIO53ozA+xjqLwyHb3tLBgVEneDJbvBijnS6MUtnNkaEBx7bZsimlXllrDPBZb3Yw83IhSkwJ24cQV8KE9UoGtSDOu6NzSAFQhCSSYolS99PRXVFYtx4khMYWHgyt9TYJHMvoOg7sJrWK8z7QwjRDzF2jO+ROzG1qbUttcU7kNbZdfTMTvYVw+9d; 25:gW2SqaJggCvuykaHS2BC2kbJh06jPrDkKOq9xZHZgrPMcqG+dwrY871UWcbiEZJjH8I4x3OICN8u6gpmFoJXWvcyqD5r/i20TUlAw3ayYsFj4/2+DnIaSWfnfTReBatYVwF7zmQxLn+717rIY+LrPbY5N4OLBJWHcS8jWgMKrt72aXPJ9glXVIRwJuFtfrAPDpsMX1SUZysQDD/FHrAik3joK0OhI6rj6y0aXMk+EQCW7uzuVkL4u9mLjcspC722N070t0hmsWoyRkPcnRDt8Thg5WUjynVRZmEU50M6K4mesIOvqX9us3t3l7O67mH9SedzWd9KRqhWgsEYBKQRvmgFCcW5id4Tt7mG55JdH1PvelyjmOewKjbvQD+hbEGPR/gcD5DJE/mPEv9Nf8I9Tgj+9lXReccyx0hjlBZcqH/8LU8ztTOyaM8i+Bsl05nOSU92/Ul0YupqcCMGcdffww== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0906; 31:FIeGKthWLAQnChY04yROw72+LxwPDBh0VQROuu72sdeOgYZRN/3XKcwZD1mcZubaCj3I97AiGls/R+ihtteUV7IV5D3yXjWcC2fTiU7CfatbqRFjbLCSYkgMjhVu7I8cv+P7D9UOFT8FexADP1NybWg2Fx98wr+Pin2699JW3lOgsV4PXUIBrB5ojU+CfwmQCtER6GQ/wRhHmflCdlDqQVkZXanDCYEZQam3+szXwAkroENIwTi3jW1CGcvLUIxAzQ7LcGmOhRT25up45TyVF6xZX7doelMebOBruuZ1dvc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(8121501046)(13015025)(5005006)(13024025)(13018025)(13023025)(13017025)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123565025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123561025)(20161123556025)(20161123563025)(20161123559100); SRVR:CY1PR0301MB0906; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0906; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0906; 4:AK3Q8fTF1JufjS9hThMRYq9Rq2hVG5jQysth11TC?= =?us-ascii?Q?TGyGsaZ0YFIOr8IUg3gCwMa5gqqbYlS8EbK92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bUJSATlpDV7CP3EtJBFx4wFHzIQ6xzPYBAs4Cg=3D=3D?= X-Forefront-PRVS: 029651C7A1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0906; 23:2ipWr6pDKkWIrle8NvTR3ueVASFIwqe/jbfrIMN?= =?us-ascii?Q?s8Rn6Hpjvl7ez20tP0byxXV5RlmZx6QAfifgZo/DI94p4LSNtW1v9hiYNa00?= =?us-ascii?Q?Pwfl/ETTOovYCbUt28zieRpZs+icWSP0rUTFlt0enA+eSSa8UcUJRuMGtdW4?= =?us-ascii?Q?vpcJ2I2NPVdmL0gDkx6cfK5XPhHZdVjKP7VXAl2hotgaxQE5ijFS7aBgiZdr?= =?us-ascii?Q?Y3mD4xFGjywrKmKc7zJ+vagl+9sRWbUqOQakdW8ch2p+4+Y4dRc2pNgB+5F0?= =?us-ascii?Q?ERMZCJTIIOAnL8nTb0KubWceyXDey8uxjSQjkvzHgjA+ZQ2LsPRc5Aotkrh+?= =?us-ascii?Q?YZTxSL4y2XyULq31UsNC1i5dwLE6hDcvonqZf+7IGiN8TXhlmESqLjRuk5hN?= =?us-ascii?Q?jvOk80Zx/IQtcObTfRSrMbGzh6r9FNnvS43xNDXj7idNMS7MC9akuMrRYh2+?= =?us-ascii?Q?bq8/M1F8ZEY0CNCj9ivAOZeX0MGsR8h0Yuqth16CEoaZ1gjlncdDEQstZEMR?= =?us-ascii?Q?nBGV99qr0yd+npJRYt01+RW3jd1iV441bAy0wlhydFfuNvLXZIV7nclKBfdp?= =?us-ascii?Q?FXSNL85T9qaEl/ZmlIMoeQuOx5REp41Gm89p22cADljZBI4OINeXL7hSlXXj?= =?us-ascii?Q?FwBS1ZXMKzYLmddMQKL7Faz4IT+tueIaxu26AvKHGsM469mIYEDvgxRY1Fhu?= =?us-ascii?Q?p30+feFevSmJmu/tAZ6JfR6G8iIjT0XL4rqO6ggMYThVKeHYRVao90/06WNK?= =?us-ascii?Q?9BEJd6ynOccPfWSOE95flSX/i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fRdUHqXIiNTHCd5dQypT7GcvgZsmEz6XSQ039EF209TYLiKBfGGUaFENX1zG9EHQ+05Q==; 5:+8r7rjU1DK5IAIe/aRbDP97WNoorZVBs0MBQtsjRlyOsK7yjbvE7PzMADWCETNFFKoC7/6yewDKOoWlkX0hFwqIWgnqOrK9CfiOULdSbJATFH6ArScZorYl3ql7xEOhKauXUl2KIJzVMI8utdSGl5oeZzTtYuSEoAmO0Ib9SUSn0e/uY2J6pOmKaoio1tl3J; 24:53gmktcBR+wrGtD4Vhq00baMIzH+O4SUekJqKxquTTds40XWWHNWm2HeCW+ljenLfD8/8ZuRWqzKaVo3XCIohAfP+5CJA/zzaVe9qBfYTRQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0906; 7:137nC6qGHYla3hmyH8zMS4+fktBNUxoYWxvdQTgjLRbZK0fPp5BHu4k3PBSHqEM/Z9WdCblrBPTGluekly7SFKVvSmSvfDWnDvOk0VXIwEcuTrM1JZGvguVNKs8yar6EOTI1QHwoO67N/CX0/RlNr2DU2OjghULCeN3W/8MvgYRcVrykyFuo91KtRp2n7BH5ooDCIPct4YeICfcWvcOswQn0wi9hFvZpfOu+LGp7uMvvzWXZT5Hw5j0oh5LUnAzQu/miPqTSoebrBZxaTLKmDj2j1mO/1RBpyAkfzE6xbClbd796d5z0wVUTKc71PPB82TKnl3wYmgea2f1lsYukKw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2017 11:21:33.4405 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0906 Subject: [dpdk-dev] [RFC PATCH 5/5] kni: support multiple userspace process working with kni module 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, 03 May 2017 11:21:36 -0000 in case of multiple application using the same KNI module, protect that one application will only clean it's own devices. Signed-off-by: Hemant Agrawal --- lib/librte_eal/linuxapp/kni/kni_dev.h | 1 + lib/librte_eal/linuxapp/kni/kni_misc.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h index 72385ab..c8c856d 100644 --- a/lib/librte_eal/linuxapp/kni/kni_dev.h +++ b/lib/librte_eal/linuxapp/kni/kni_dev.h @@ -61,6 +61,7 @@ struct kni_dev { uint32_t core_id; /* Core ID to bind */ char name[RTE_KNI_NAMESIZE]; /* Network device name */ struct task_struct *pthread; + void *usrctxt; /* User space process context*/ /* wait queue for req/resp */ wait_queue_head_t wq; diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 4f99a5e..84f8a99 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -234,6 +234,9 @@ struct kni_net { down_write(&knet->kni_list_lock); list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { + /* check for the matching user context */ + if (dev->usrctxt != inode) + continue; /* Stop kernel thread for multiple mode */ if (multiple_kthread_on && dev->pthread != NULL) { kthread_stop(dev->pthread); @@ -311,9 +314,10 @@ struct kni_net { } static int -kni_ioctl_create(struct net *net, uint32_t ioctl_num, +kni_ioctl_create(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param) { + struct net *net = current->nsproxy->net_ns; struct kni_net *knet = net_generic(net, kni_net_id); int ret; struct rte_kni_device_info dev_info; @@ -374,7 +378,8 @@ struct kni_net { dev_net_set(net_dev, net); kni = netdev_priv(net_dev); - + + kni->usrctxt = inode; kni->net_dev = net_dev; kni->group_id = dev_info.group_id; kni->core_id = dev_info.core_id; @@ -493,9 +498,10 @@ struct kni_net { } static int -kni_ioctl_release(struct net *net, uint32_t ioctl_num, +kni_ioctl_release(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param) { + struct net *net = current->nsproxy->net_ns; struct kni_net *knet = net_generic(net, kni_net_id); int ret = -EINVAL; struct kni_dev *dev, *n; @@ -516,6 +522,10 @@ struct kni_net { down_write(&knet->kni_list_lock); list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { + /* only the owner user process can remove it*/ + if (dev->usrctxt != inode) + continue; + if (strncmp(dev->name, dev_info.name, RTE_KNI_NAMESIZE) != 0) continue; @@ -540,7 +550,6 @@ struct kni_net { kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param) { int ret = -EINVAL; - struct net *net = current->nsproxy->net_ns; pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param); @@ -552,10 +561,10 @@ struct kni_net { /* For test only, not used */ break; case _IOC_NR(RTE_KNI_IOCTL_CREATE): - ret = kni_ioctl_create(net, ioctl_num, ioctl_param); + ret = kni_ioctl_create(inode, ioctl_num, ioctl_param); break; case _IOC_NR(RTE_KNI_IOCTL_RELEASE): - ret = kni_ioctl_release(net, ioctl_num, ioctl_param); + ret = kni_ioctl_release(inode, ioctl_num, ioctl_param); break; default: pr_debug("IOCTL default\n"); -- 1.9.1