mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-06 00:23:53 +00:00
Add TC_LIB_DIR environment variable.
Don't hardcode /usr/lib/tc as a path Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
This commit is contained in:
parent
30af998941
commit
aa27f88c84
@ -60,7 +60,7 @@ static int get_distribution(const char *type, __s16 *data)
|
|||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
char name[128];
|
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) {
|
if ((f = fopen(name, "r")) == NULL) {
|
||||||
fprintf(stderr, "No distribution data for %s (%s: %s)\n",
|
fprintf(stderr, "No distribution data for %s (%s: %s)\n",
|
||||||
type, name, strerror(errno));
|
type, name, strerror(errno));
|
||||||
|
4
tc/tc.c
4
tc/tc.c
@ -99,7 +99,7 @@ struct qdisc_util *get_qdisc_kind(const char *str)
|
|||||||
if (strcmp(q->id, str) == 0)
|
if (strcmp(q->id, str) == 0)
|
||||||
return q;
|
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);
|
dlh = dlopen(buf, RTLD_LAZY);
|
||||||
if (!dlh) {
|
if (!dlh) {
|
||||||
/* look in current binary, only open once */
|
/* 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)
|
if (strcmp(q->id, str) == 0)
|
||||||
return q;
|
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);
|
dlh = dlopen(buf, RTLD_LAZY);
|
||||||
if (dlh == NULL) {
|
if (dlh == NULL) {
|
||||||
dlh = BODY;
|
dlh = BODY;
|
||||||
|
11
tc/tc_util.c
11
tc/tc_util.c
@ -24,6 +24,17 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "tc_util.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)
|
int get_qdisc_handle(__u32 *h, const char *str)
|
||||||
{
|
{
|
||||||
__u32 maj;
|
__u32 maj;
|
||||||
|
@ -38,6 +38,8 @@ struct action_util
|
|||||||
int (*print_xstats)(struct action_util *au, FILE *f, struct rtattr *xstats);
|
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 qdisc_util *get_qdisc_kind(const char *str);
|
||||||
extern struct filter_util *get_filter_kind(const char *str);
|
extern struct filter_util *get_filter_kind(const char *str);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user