From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50043.outbound.protection.outlook.com [40.107.5.43]) by dpdk.org (Postfix) with ESMTP id C58142F4F for ; Sun, 6 May 2018 08:06:38 +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; bh=TXoRbdtJZ7jNTBmQ5QYd0/quPPMGaOqeGk57omOgKFo=; b=nX7OBFPpvnSxmlGqDCwlPUMZluyXPMTpX46rok5Tie3EABG2WyfUtno+4CWzu23sBkBoKEdvFA5ZW6RdKNkO+9EkXxVvBMBcKuROQggWkGugicnAktlWkezLr7jovsJNyX+L1FmfUEpEru+rBWJNoVFl3WPeGgwXQMnGU8dwV8E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (141.226.120.58) by AM6PR05MB4422.eurprd05.prod.outlook.com (2603:10a6:209:43::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.735.16; Sun, 6 May 2018 06:06:36 +0000 From: Shahaf Shuler To: bluca@debian.org Cc: stable@dpdk.org, nelio.laranjeiro@6wind.com, yskoh@mellanox.com, adrien.mazarguil@6wind.com Date: Sun, 6 May 2018 09:05:34 +0300 Message-Id: X-Mailer: git-send-email 2.12.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [141.226.120.58] X-ClientProxiedBy: LO2P265CA0008.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:62::20) To AM6PR05MB4422.eurprd05.prod.outlook.com (2603:10a6:209:43::15) 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:AM6PR05MB4422; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 3:2CL8M5Ibd9NJXlfVh8t/p+fvw1CAmmQd6MT0KLQkZYgqIWHgPF2GmEH27cnwrw5jzBpAAIC1XEg9YhIKptslH9wdNzp0DDtl8Z1xuqCqjoWFIrr+w/E8AOEFgaZjVMCD+ioKsQ1qjiD62Brya+K6uclC5roREyjm8FaYtGjHpZdC5tj1i8zH3N0ohYnekTSqQ4ua4nWMPeD6x19MbJkorOAoociJXLne85xtDru3/zaHYAiwq9W1d2+wn0Uh6+mx; 25:IhLkIx+FFFsp26JqRbpIgzA8/GhICyQkwHHkkxMhTjgWtqa8ModFsWTPycOxzaOY5IK3N94kwjFGmlCglKtI6+7wx7k2PrXdf8bU3AFHGVbq+itmqhIaR5lyJwr4dvmZ5Nxj1XQYe8rokk3Vv5XeMgX4mXLRyASvzpqKVM0Wjqsd+nPcgF28oXKTBsLKTYpV6wy+Ma0KggFA5uJi3joNqJ5iavALlG9wh7aHQPvyju5OnuzezZoMVdVmFOIlwX7XThw9C10kAAK2AIbrwjladQdGckev4U9mW1IK4Bkjmo/MEWzDOAK63DB32fMnjLFsXa3XK2alZC0Xd2ul1pqH5A==; 31:Gt3EPT6AhT/2Wxu4a1ezYNcA2gDVSEG5TZXMe4IYXJUix89ODpaRlUg57sOUWU5MH8wOt1sbg3snOQG3E4tGe+fGNdrrHeF3uLU6QN+7YY1ees6uCniIlAOf32Kh/5/V1Sy41V/8qj4o5WT2gAXEQNl+9PLw4e97pw86MebuV4dBm45FWK7UcIX3A46tuFM4Yjx6rz1PHMR5RJvwxx0RGsEinF5H8wLkgfWaNVeEWFQ= X-MS-TrafficTypeDiagnostic: AM6PR05MB4422: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 20:630JjJwODr4+NfrggDHNPnynVqdYAouNTtSTkJ+jOYkK8FsynUfYQUJiY/07WmjmfgkMqm5qnXdKkM1uuDiYfRZgYCEI7IxOlbl9OvgLFCFUFXAjLvy8/TqJastPiPE4m6M3nKKnOjAEHLcQmoYwvhOjjPk3iPEgIKdvJV7GE8nXjVaoyQw+4uPUXvFBvpMJcBZFYwMbaMDIRrvWVqNtCo9gxBnfr04ZaWRFgFcXvyPjd+0fNpDzzMAC7KS/1CcB6TRHbDZUNIRW35vYCNjDKA30755dtytwJYu5BQySFEbRHr4/mfwAisDnZlftV9ItOV7ZCwAwgOn5MXs3I6ltz3mE9lhHOI+1TruSxLTagH8dmMJn5XZQO/0sPc7HFwqfYZkRqYDTWYzkx2uvE4/Hb1sOg2Xc/q3XAg6WAljtsrztpB6CCE6BLCh3P1M0Nyk3lvECOOd93oGKO5iLwivdkr6jH8nbHxYDE+55che2lUZ83RSkxxJqmx+kwjoyRmtR; 4:bZOprlRdh69PUesfe/OgFUAT1M2ybblTQVgEHp6xyeOWr0tiETcE/SX9Knq/loop8HIRkDTsQRy7sf7Px+QoBOlCwICzTk/mYDhGRRY6b80qWKp+sl03FoAHaHsnwLZODSrM6yuZefFJa8wxn3VoGdg8ygDsHy66SoqcbafZkDHm/vAuBYpapaYSgwgQl+jbktLlU+B5p4CLY4+u3HChDzot2uyPFxlOn2CW9cJmcFznuAibGU3mjJDVsobcbPGwC9TK4s9R63ybd3n+wXlO+OWhNbrdJOu4ObaBU5Wut4yYzZ1leobVM+GFNt51wAlz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(6041310)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:AM6PR05MB4422; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4422; X-Forefront-PRVS: 06640999CA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39380400002)(396003)(346002)(39860400002)(189003)(199004)(105586002)(8676002)(16586007)(8936002)(316002)(2351001)(53936002)(86362001)(2361001)(6116002)(3846002)(106356001)(118296001)(66066001)(36756003)(47776003)(81156014)(55016002)(2906002)(50226002)(4326008)(68736007)(305945005)(7736002)(81166006)(50466002)(25786009)(486006)(5660300001)(476003)(2616005)(48376002)(69596002)(16526019)(26005)(59450400001)(386003)(97736004)(956004)(186003)(478600001)(7696005)(52116002)(6916009)(21086003)(51416003)(446003)(11346002)(76176011); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4422; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM6PR05MB4422; 23:lT5/d4P/Hec+41/vXsUMybJSR/2yvrprEcuLjD5JB?= =?us-ascii?Q?rEeBKG3inOwtzm4j77fBdiIQ1O6JxlHtoYMo5zC1/BA4y7hr7b93Y6Rhg33G?= =?us-ascii?Q?cnS9GkY880KeWfemXGkQz+M4mpR8EVmfSqC8i5VciHauAMVJmTHAZnIFn9WX?= =?us-ascii?Q?1pLicfFOv29yLdgkdLAsoHeedS7/Hnk9lZ91j9Spc5BMlKiHW67xP61CSiOY?= =?us-ascii?Q?tNS6nKcbrRlqLvok4zOKnNYOAtuHStSrijpeffQWUakGFRDvIrII99Hf1sQ0?= =?us-ascii?Q?yxZOxzf6hRb0f9EFCqo5QsfQja7nirvitG/IKIpf5QxzaRccv1eH8KfD525f?= =?us-ascii?Q?xopx3IVmPC1YyjeqFshXaLtdpaUxGiP2Nru032InW5JKB0zqA929tqsePlJa?= =?us-ascii?Q?JuT3/xAbLaPi3wVRflYaZMdc9DIrZYAb/7eKGG0fpiL5DISB9EcIuOyF1BZm?= =?us-ascii?Q?/iVjocB0cgF4NM0/FjE1EA1Q9DE57PG62u5ZR38FJooUl6L1oPeniDr4L6gY?= =?us-ascii?Q?Se+8YLhT8boUpbW3EKXvlbzZamREBZszsGbAWuqKwWa5LNdeKA5imUzKFTuS?= =?us-ascii?Q?SENRs/au9c7qRpeeiGSS6hPS3yDMG4hrK01oePL26tIwkNHfyN+AlCrT2Rs8?= =?us-ascii?Q?Gv5mEZSc5kced1tpuuL/XD+PTyBc5+Xh0n3E+QqmDEpMD2RTIeWTroaZmjjF?= =?us-ascii?Q?yiYc5QgYFafpoH+EOiGSr2wxdd0TKk1+7ohIEyDe5CCsg61909YXoXhxi4O5?= =?us-ascii?Q?xGsRh/pSYivoPo1CGijXoWJnhuUzfiicNC2PhRqMnlyMGLUebfMw1yYBksvY?= =?us-ascii?Q?rPeaFsDlBF/Gzrvo6cgg9oSbE/IQj/Qnba235XlFHbs606I4j81YmBbsk3wD?= =?us-ascii?Q?BfcXia1eB4FPQr/8BP80Bu4yHbYpQBltM0/d+mhDt91gaTJAyZ4DhrK0FISV?= =?us-ascii?Q?QpoNMcRCmMeHFklhxqny6nmRyyTLcdy5NcnbXW6/btRt2WHEy5pqvAdrbq9N?= =?us-ascii?Q?JwLMDCBaYm7G6LWvWey560rIdOCcRKQJNuEoLnLgwYsVH05HBYdKBu3eDIh4?= =?us-ascii?Q?2EPMWdkZnWyBYM5Mgx1UadY50tczc4e9OliogSEUf+tDUtJvRzgEt+5S3YpW?= =?us-ascii?Q?K2Erp21fcgSyaBASqpkk6LJ0+muhNLQAsh5JqYLbyHrlt6VJU0zZvMWZgX7w?= =?us-ascii?Q?Wmhh1frobjYWanlJN8QzGrsZ+gm9BC7IdYnPRFoQhOG4S0J5KtrskO1171Ux?= =?us-ascii?Q?fDQPPEfXFMOT4weLhJ22DT9TJrmo1ZELP6hgq5r?= X-Microsoft-Antispam-Message-Info: p6Oy9EkMyf0rW96IPYCtwXMaMdEX6XhriPq/lJzrP0cnmmvVO2YdKGVlMIFx47+Kcnwpqz6ZEgTPmRNNnlMCUzrtCkRmQzvT4LiLePK+R73Ch0IDF+9ZHhK31J7HKUFSE9WcIrafw6ODSTnAxQ3iikIv69gj+oLMpZt68ioR7EkALWO9SiCXKKGc6pnKhP44 X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 6:cmTatpn1GfXMRsGzDTXgbNO2VJ3lwDoiuBZXlHUzTQVG6TIwcs182uz88mI344mdWhTVNzQo7l0A/hGV/CkaZgPEolHMvDc2I3COg2i37qzhHrMGWn4BjYD5gun4DiXeEJKBulnbH3wWyDiZwEFqnXic6IasumcCqNufX2VED5dDL/fbSM//MKZehmB1FEKZ2MjREsa3lEAQG6pMiPBGdJ6dqoBdwObgF7AOv/u038BioT3kIeo4kIWv52JrpA9VVGTx64gbRjvkuM4+tRnf+Pf6QqIKNrkyrL9R+GGdanOWrW9mwzCCRq08JsjAhDPfzTwDTGEg/JnBRkGRNb+aP0UQzu9g/qtFOFmxcXnyrzKafd4SDj24s8C5EZodqUYLMcBDHx8XhNyLxVQfS0Et/GL/Iq9WgQnjUm2ov+SCCXKVHKgn67iH5G4N14lDtsjzpGulPcXEfxRVYnjAb4zqhg==; 5:NBZtSg2SdosU/xigOC0KvGTcjkQlkQaN8JzH4JUgTC2llLUTs/KrB/yA27bsgGjDb2aO+1LekqucmXYq0XYb4sqavmPJ7DvSb1+hSDpdm2DJ7JUmz9hAndrrfG1Zd7spAEKs97puHKMnuWUbuZWjEwUMKxatVDj2Cw1lyt07Gjc=; 24:Vf+TkQNBrulhYoldRx7+YTmMF5iUZl4nJF3csrovL2qB0v9XJTZA4kqzl0fa0a71ZajtpEjShyH2/YsDbh1CrVXgYt0TzGvF1zes7zndfuY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4422; 7:5EgHvfOAICjOilIBH0JPYXjv5U37xhwQKoVo90am3jGGHYlNjvV8ivYNuTnJ6Rb9HAN/PkMsJZKhqjnnNTuIicAGy7jsemVAmwMfOPJ6T9eAuWRcltDnoGgmw2AmeIlGP1rcOmN3svfZsOiUSeN0e1bbVrAlZTyp0rtTbdob48s2aWyGnf5o2MSIxCwtqN+8G+xPXddN6VI064tHS6qSQMz/+K/XJmz2JsWuUugmKwg+cXSYBWW4DSX8/zQYU19v X-MS-Office365-Filtering-Correlation-Id: f00451de-70a7-4f7b-8115-08d5b317871c X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2018 06:06:36.9892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f00451de-70a7-4f7b-8115-08d5b317871c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4422 Subject: [dpdk-stable] [PATCH 05/33] net/mlx: fix rdma-core glue path with EAL plugins 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: Sun, 06 May 2018 06:06:39 -0000 From: Adrien Mazarguil [ upstream commit 08c028d08c42c1a4cd26aff1ed9c6438ddfd1206 ] Glue object files are looked up in RTE_EAL_PMD_PATH by default when set and should be installed in this directory. During startup, EAL attempts to load them automatically like other plug-ins found there. While normally harmless, dlopen() fails when rdma-core is not installed, EAL interprets this as a fatal error and terminates the application. This patch requests glue objects to be installed in a different directory to prevent their automatic loading by EAL since they are PMD helpers, not actual DPDK plug-ins. Fixes: f6242d0655cd ("net/mlx: make rdma-core glue path configurable") Cc: stable@dpdk.org Reported-by: Timothy Redaelli Signed-off-by: Adrien Mazarguil Tested-by: Timothy Redaelli --- doc/guides/nics/mlx4.rst | 7 +++--- doc/guides/nics/mlx5.rst | 7 +++--- drivers/net/mlx4/mlx4.c | 50 ++++++++++++++++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5.c | 50 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 106 insertions(+), 8 deletions(-) diff --git a/doc/guides/nics/mlx4.rst b/doc/guides/nics/mlx4.rst index 98b9716672..afeff276eb 100644 --- a/doc/guides/nics/mlx4.rst +++ b/doc/guides/nics/mlx4.rst @@ -98,9 +98,10 @@ These options can be modified in the ``.config`` file. missing with ``ldd(1)``. It works by moving these dependencies to a purpose-built rdma-core "glue" - plug-in, which must either be installed in ``CONFIG_RTE_EAL_PMD_PATH`` if - set, or in a standard location for the dynamic linker (e.g. ``/lib``) if - left to the default empty string (``""``). + plug-in which must either be installed in a directory whose name is based + on ``CONFIG_RTE_EAL_PMD_PATH`` suffixed with ``-glue`` if set, or in a + standard location for the dynamic linker (e.g. ``/lib``) if left to the + default empty string (``""``). This option has no performance impact. diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 0e6e525c91..46d26e4c8a 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -171,9 +171,10 @@ These options can be modified in the ``.config`` file. missing with ``ldd(1)``. It works by moving these dependencies to a purpose-built rdma-core "glue" - plug-in, which must either be installed in ``CONFIG_RTE_EAL_PMD_PATH`` if - set, or in a standard location for the dynamic linker (e.g. ``/lib``) if - left to the default empty string (``""``). + plug-in which must either be installed in a directory whose name is based + on ``CONFIG_RTE_EAL_PMD_PATH`` suffixed with ``-glue`` if set, or in a + standard location for the dynamic linker (e.g. ``/lib``) if left to the + default empty string (``""``). This option has no performance impact. diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index ee93dafe66..fb8a8b8484 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -708,11 +708,53 @@ static struct rte_pci_driver mlx4_driver = { #ifdef RTE_LIBRTE_MLX4_DLOPEN_DEPS /** + * Suffix RTE_EAL_PMD_PATH with "-glue". + * + * This function performs a sanity check on RTE_EAL_PMD_PATH before + * suffixing its last component. + * + * @param buf[out] + * Output buffer, should be large enough otherwise NULL is returned. + * @param size + * Size of @p out. + * + * @return + * Pointer to @p buf or @p NULL in case suffix cannot be appended. + */ +static char * +mlx4_glue_path(char *buf, size_t size) +{ + static const char *const bad[] = { "/", ".", "..", NULL }; + const char *path = RTE_EAL_PMD_PATH; + size_t len = strlen(path); + size_t off; + int i; + + while (len && path[len - 1] == '/') + --len; + for (off = len; off && path[off - 1] != '/'; --off) + ; + for (i = 0; bad[i]; ++i) + if (!strncmp(path + off, bad[i], (int)(len - off))) + goto error; + i = snprintf(buf, size, "%.*s-glue", (int)len, path); + if (i == -1 || (size_t)i >= size) + goto error; + return buf; +error: + ERROR("unable to append \"-glue\" to last component of" + " RTE_EAL_PMD_PATH (\"" RTE_EAL_PMD_PATH "\")," + " please re-configure DPDK"); + return NULL; +} + +/** * Initialization routine for run-time dependency on rdma-core. */ static int mlx4_glue_init(void) { + char glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof("-glue")]; const char *path[] = { /* * A basic security check is necessary before trusting @@ -720,7 +762,13 @@ mlx4_glue_init(void) */ (geteuid() == getuid() && getegid() == getgid() ? getenv("MLX4_GLUE_PATH") : NULL), - RTE_EAL_PMD_PATH, + /* + * When RTE_EAL_PMD_PATH is set, use its glue-suffixed + * variant, otherwise let dlopen() look up libraries on its + * own. + */ + (*RTE_EAL_PMD_PATH ? + mlx4_glue_path(glue_path, sizeof(glue_path)) : ""), }; unsigned int i = 0; void *handle = NULL; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 61cb93101a..0ca16d11d7 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1043,11 +1043,53 @@ static struct rte_pci_driver mlx5_driver = { #ifdef RTE_LIBRTE_MLX5_DLOPEN_DEPS /** + * Suffix RTE_EAL_PMD_PATH with "-glue". + * + * This function performs a sanity check on RTE_EAL_PMD_PATH before + * suffixing its last component. + * + * @param buf[out] + * Output buffer, should be large enough otherwise NULL is returned. + * @param size + * Size of @p out. + * + * @return + * Pointer to @p buf or @p NULL in case suffix cannot be appended. + */ +static char * +mlx5_glue_path(char *buf, size_t size) +{ + static const char *const bad[] = { "/", ".", "..", NULL }; + const char *path = RTE_EAL_PMD_PATH; + size_t len = strlen(path); + size_t off; + int i; + + while (len && path[len - 1] == '/') + --len; + for (off = len; off && path[off - 1] != '/'; --off) + ; + for (i = 0; bad[i]; ++i) + if (!strncmp(path + off, bad[i], (int)(len - off))) + goto error; + i = snprintf(buf, size, "%.*s-glue", (int)len, path); + if (i == -1 || (size_t)i >= size) + goto error; + return buf; +error: + ERROR("unable to append \"-glue\" to last component of" + " RTE_EAL_PMD_PATH (\"" RTE_EAL_PMD_PATH "\")," + " please re-configure DPDK"); + return NULL; +} + +/** * Initialization routine for run-time dependency on rdma-core. */ static int mlx5_glue_init(void) { + char glue_path[sizeof(RTE_EAL_PMD_PATH) - 1 + sizeof("-glue")]; const char *path[] = { /* * A basic security check is necessary before trusting @@ -1055,7 +1097,13 @@ mlx5_glue_init(void) */ (geteuid() == getuid() && getegid() == getgid() ? getenv("MLX5_GLUE_PATH") : NULL), - RTE_EAL_PMD_PATH, + /* + * When RTE_EAL_PMD_PATH is set, use its glue-suffixed + * variant, otherwise let dlopen() look up libraries on its + * own. + */ + (*RTE_EAL_PMD_PATH ? + mlx5_glue_path(glue_path, sizeof(glue_path)) : ""), }; unsigned int i = 0; void *handle = NULL; -- 2.12.0