]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Add TC_LIB_DIR environment variable.
authorStephen Hemminger <shemminger@linux-foundation.org>
Wed, 20 Jun 2007 22:27:22 +0000 (15:27 -0700)
committerStephen Hemminger <shemminger@linux-foundation.org>
Wed, 20 Jun 2007 22:31:40 +0000 (15:31 -0700)
Don't hardcode /usr/lib/tc as a path

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
tc/q_netem.c
tc/tc.c
tc/tc_util.c
tc/tc_util.h

index 67a2ff3218af566cac51dc20389d96d16d241f46..f08b9c19a25f849ed28620fc63594c3646d402e3 100644 (file)
@@ -60,7 +60,7 @@ static int get_distribution(const char *type, __s16 *data)
        char *line = NULL;
        char name[128];
 
-       snprintf(name, sizeof(name), "/usr/lib/tc/%s.dist", type);
+       snprintf(name, sizeof(name), "%s/%s.dist", get_tc_lib(), type);
        if ((f = fopen(name, "r")) == NULL) {
                fprintf(stderr, "No distribution data for %s (%s: %s)\n",
                        type, name, strerror(errno));
diff --git a/tc/tc.c b/tc/tc.c
index 6672e189f75e48c30ee7ed10a8a220768a9414e7..f23ba04ebd2a366c2f148bddf75d0f298246e40e 100644 (file)
--- a/tc/tc.c
+++ b/tc/tc.c
@@ -99,7 +99,7 @@ struct qdisc_util *get_qdisc_kind(const char *str)
                if (strcmp(q->id, str) == 0)
                        return q;
 
-       snprintf(buf, sizeof(buf), "/usr/lib/tc/q_%s.so", str);
+       snprintf(buf, sizeof(buf), "%s/q_%s.so", get_tc_lib(), str);
        dlh = dlopen(buf, RTLD_LAZY);
        if (!dlh) {
                /* look in current binary, only open once */
@@ -145,7 +145,7 @@ struct filter_util *get_filter_kind(const char *str)
                if (strcmp(q->id, str) == 0)
                        return q;
 
-       snprintf(buf, sizeof(buf), "/usr/lib/tc/f_%s.so", str);
+       snprintf(buf, sizeof(buf), "%s/f_%s.so", get_tc_lib(), str);
        dlh = dlopen(buf, RTLD_LAZY);
        if (dlh == NULL) {
                dlh = BODY;
index a7e42572db19d44a81ab10d9176ff85cced1d846..cdbae4217092f0c2e948ef08e2611b2800647ca9 100644 (file)
 #include "utils.h"
 #include "tc_util.h"
 
+const char *get_tc_lib(void)
+{
+       const char *lib_dir;
+
+       lib_dir = getenv("TC_LIB_DIR");
+       if (!lib_dir)
+               lib_dir = "/usr/lib/tc";
+
+       return lib_dir;
+}
+
 int get_qdisc_handle(__u32 *h, const char *str)
 {
        __u32 maj;
index eade72d21dc2e30d31f43f67608e21ae87a75981..120d6cebaa93fcc478077af058bb637dc6b32799 100644 (file)
@@ -38,6 +38,8 @@ struct action_util
        int     (*print_xstats)(struct action_util *au, FILE *f, struct rtattr *xstats);
 };
 
+extern const char *get_tc_lib(void);
+
 extern struct qdisc_util *get_qdisc_kind(const char *str);
 extern struct filter_util *get_filter_kind(const char *str);