From 2ce43bae10979eb95b42432eec4c6589ee1676a1 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 24 Jun 2019 16:03:55 -0700 Subject: [PATCH] ip: Fix get_link_kind when linked statically --- ip/iplink.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index 95314af5..b3ee3eef 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -141,7 +141,6 @@ static int on_off(const char *msg, const char *realval) return -1; } -static void *BODY; /* cached dlopen(NULL) handle */ static struct link_util *linkutil_list; struct link_util *get_link_kind(const char *id) @@ -150,21 +149,102 @@ struct link_util *get_link_kind(const char *id) char buf[256]; struct link_util *l; + if (linkutil_list == NULL) { + // next) if (strcmp(l->id, id) == 0) return l; snprintf(buf, sizeof(buf), "%s/link_%s.so", get_ip_lib_dir(), id); dlh = dlopen(buf, RTLD_LAZY); - if (dlh == NULL) { - /* look in current binary, only open once */ - dlh = BODY; - if (dlh == NULL) { - dlh = BODY = dlopen(NULL, RTLD_LAZY); - if (dlh == NULL) - return NULL; - } - } + if (dlh == NULL) + return NULL; snprintf(buf, sizeof(buf), "%s_link_util", id); l = dlsym(dlh, buf); -- 2.44.0