summaryrefslogtreecommitdiff
path: root/drivers/net/mlx4/mlx4.c
diff options
context:
space:
mode:
authorAdrien Mazarguil <adrien.mazarguil@6wind.com>2018-02-02 17:46:18 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2018-02-06 14:35:07 +0100
commitf6242d0655cdc9a97d9a7dbe3880d20eb471570e (patch)
treecb9afa2d30fbb840f4ca9d1ce34d1f466dc86768 /drivers/net/mlx4/mlx4.c
parent6d5df2eaf667e2e65a34e135ea0e33a055fe9cd0 (diff)
downloaddpdk-f6242d0655cdc9a97d9a7dbe3880d20eb471570e.zip
dpdk-f6242d0655cdc9a97d9a7dbe3880d20eb471570e.tar.gz
dpdk-f6242d0655cdc9a97d9a7dbe3880d20eb471570e.tar.xz
net/mlx: make rdma-core glue path configurable
Since rdma-core glue libraries are intrinsically tied to their respective PMDs and used as internal plug-ins, their presence in the default search path among other system libraries for the dynamic linker is not necessarily desired. This commit enables their installation and subsequent look-up at run time in RTE_EAL_PMD_PATH if configured to a nonempty string. This path can also be overridden by environment variables MLX[45]_GLUE_PATH. Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Diffstat (limited to 'drivers/net/mlx4/mlx4.c')
-rw-r--r--drivers/net/mlx4/mlx4.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index a76fc59..ee93daf 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -713,11 +713,52 @@ static struct rte_pci_driver mlx4_driver = {
static int
mlx4_glue_init(void)
{
+ const char *path[] = {
+ /*
+ * A basic security check is necessary before trusting
+ * MLX4_GLUE_PATH, which may override RTE_EAL_PMD_PATH.
+ */
+ (geteuid() == getuid() && getegid() == getgid() ?
+ getenv("MLX4_GLUE_PATH") : NULL),
+ RTE_EAL_PMD_PATH,
+ };
+ unsigned int i = 0;
void *handle = NULL;
void **sym;
const char *dlmsg;
- handle = dlopen(MLX4_GLUE, RTLD_LAZY);
+ while (!handle && i != RTE_DIM(path)) {
+ const char *end;
+ size_t len;
+ int ret;
+
+ if (!path[i]) {
+ ++i;
+ continue;
+ }
+ end = strpbrk(path[i], ":;");
+ if (!end)
+ end = path[i] + strlen(path[i]);
+ len = end - path[i];
+ ret = 0;
+ do {
+ char name[ret + 1];
+
+ ret = snprintf(name, sizeof(name), "%.*s%s" MLX4_GLUE,
+ (int)len, path[i],
+ (!len || *(end - 1) == '/') ? "" : "/");
+ if (ret == -1)
+ break;
+ if (sizeof(name) != (size_t)ret + 1)
+ continue;
+ DEBUG("looking for rdma-core glue as \"%s\"", name);
+ handle = dlopen(name, RTLD_LAZY);
+ break;
+ } while (1);
+ path[i] = end + 1;
+ if (!*end)
+ ++i;
+ }
if (!handle) {
rte_errno = EINVAL;
dlmsg = dlerror();