From: Sergey Ryazanov <ryazanov.s.a@gmail.com>
To: David Ahern <dsahern@gmail.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH iproute2-next] ip: add IP_LIB_DIR environment variable
Date: Sun, 22 Nov 2020 20:39:21 +0300 [thread overview]
Message-ID: <20201122173921.31473-1-ryazanov.s.a@gmail.com> (raw)
Do not hardcode /usr/lib/ip as a path and allow libraries path
configuration in run-time.
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
ip/ip.c | 15 +++++++++++++++
ip/ip_common.h | 2 ++
ip/iplink.c | 5 +----
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/ip/ip.c b/ip/ip.c
index 5e31957f..38600e51 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -25,6 +25,10 @@
#include "color.h"
#include "rt_names.h"
+#ifndef LIBDIR
+#define LIBDIR "/usr/lib"
+#endif
+
int preferred_family = AF_UNSPEC;
int human_readable;
int use_iec;
@@ -41,6 +45,17 @@ bool do_all;
struct rtnl_handle rth = { .fd = -1 };
+const char *get_ip_lib_dir(void)
+{
+ const char *lib_dir;
+
+ lib_dir = getenv("IP_LIB_DIR");
+ if (!lib_dir)
+ lib_dir = LIBDIR "/ip";
+
+ return lib_dir;
+}
+
static void usage(void) __attribute__((noreturn));
static void usage(void)
diff --git a/ip/ip_common.h b/ip/ip_common.h
index d604f755..227eddd3 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -27,6 +27,8 @@ struct link_filter {
int target_nsid;
};
+const char *get_ip_lib_dir(void);
+
int get_operstate(const char *name);
int print_linkinfo(struct nlmsghdr *n, void *arg);
int print_addrinfo(struct nlmsghdr *n, void *arg);
diff --git a/ip/iplink.c b/ip/iplink.c
index d6b766de..4250b2c3 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -34,9 +34,6 @@
#include "namespace.h"
#define IPLINK_IOCTL_COMPAT 1
-#ifndef LIBDIR
-#define LIBDIR "/usr/lib"
-#endif
#ifndef GSO_MAX_SIZE
#define GSO_MAX_SIZE 65536
@@ -157,7 +154,7 @@ struct link_util *get_link_kind(const char *id)
if (strcmp(l->id, id) == 0)
return l;
- snprintf(buf, sizeof(buf), LIBDIR "/ip/link_%s.so", id);
+ 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 */
--
2.26.2
next reply other threads:[~2020-11-22 17:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-22 17:39 Sergey Ryazanov [this message]
2020-11-30 17:25 ` [PATCH iproute2-next] ip: add IP_LIB_DIR environment variable David Ahern
2020-12-01 10:08 ` Sergey Ryazanov
2020-12-02 16:39 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201122173921.31473-1-ryazanov.s.a@gmail.com \
--to=ryazanov.s.a@gmail.com \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).