aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph J. Thompson <cjsthompson@gmail.com>2015-10-08 17:06:06 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 17:06:06 +0200
commitd1eea8db92e963e3c482d96b10da2ec0f9c95770 (patch)
treed42a3c22b9b13c6d06a6e33eaa5b34d70c1ebb3b
parent413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6 (diff)
downloadbusybox-w32-d1eea8db92e963e3c482d96b10da2ec0f9c95770.tar.gz
busybox-w32-d1eea8db92e963e3c482d96b10da2ec0f9c95770.tar.bz2
busybox-w32-d1eea8db92e963e3c482d96b10da2ec0f9c95770.zip
iproute: don't hardcode the path to config files
Allows using an alternate path for config files. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Christoph J. Thompson <cjsthompson@gmail.com> Signed-off-by: Michael Bestas <mikeioannina@gmail.com>
-rw-r--r--networking/Config.src7
-rw-r--r--networking/libiproute/rt_names.c12
2 files changed, 14 insertions, 5 deletions
diff --git a/networking/Config.src b/networking/Config.src
index 76cbccf4a..43ccbf385 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -533,6 +533,13 @@ config FEATURE_IP_ROUTE
533 help 533 help
534 Add support for routing table management to "ip". 534 Add support for routing table management to "ip".
535 535
536config FEATURE_IP_ROUTE_DIR
537 string "ip route configuration directory"
538 default "/etc/iproute2"
539 depends on FEATURE_IP_ROUTE
540 help
541 Location of the "ip" applet routing configuration.
542
536config FEATURE_IP_TUNNEL 543config FEATURE_IP_TUNNEL
537 bool "ip tunnel" 544 bool "ip tunnel"
538 default y 545 default y
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c
index 8dea5ac52..ca0bb5d4d 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -10,6 +10,8 @@
10#include "libbb.h" 10#include "libbb.h"
11#include "rt_names.h" 11#include "rt_names.h"
12 12
13#define CONFDIR CONFIG_FEATURE_IP_ROUTE_DIR
14
13typedef struct rtnl_tab_t { 15typedef struct rtnl_tab_t {
14 const char *cached_str; 16 const char *cached_str;
15 unsigned cached_result; 17 unsigned cached_result;
@@ -92,7 +94,7 @@ static void rtnl_rtprot_initialize(void)
92 return; 94 return;
93 rtnl_rtprot_tab = xzalloc(sizeof(*rtnl_rtprot_tab)); 95 rtnl_rtprot_tab = xzalloc(sizeof(*rtnl_rtprot_tab));
94 memcpy(rtnl_rtprot_tab->tab, init_tab, sizeof(init_tab)); 96 memcpy(rtnl_rtprot_tab->tab, init_tab, sizeof(init_tab));
95 rtnl_tab_initialize("/etc/iproute2/rt_protos", rtnl_rtprot_tab->tab); 97 rtnl_tab_initialize(CONFDIR "/rt_protos", rtnl_rtprot_tab->tab);
96} 98}
97 99
98#if 0 /* UNUSED */ 100#if 0 /* UNUSED */
@@ -129,7 +131,7 @@ static void rtnl_rtscope_initialize(void)
129 rtnl_rtscope_tab->tab[254] = "host"; 131 rtnl_rtscope_tab->tab[254] = "host";
130 rtnl_rtscope_tab->tab[253] = "link"; 132 rtnl_rtscope_tab->tab[253] = "link";
131 rtnl_rtscope_tab->tab[200] = "site"; 133 rtnl_rtscope_tab->tab[200] = "site";
132 rtnl_tab_initialize("/etc/iproute2/rt_scopes", rtnl_rtscope_tab->tab); 134 rtnl_tab_initialize(CONFDIR "/rt_scopes", rtnl_rtscope_tab->tab);
133} 135}
134 136
135const char* FAST_FUNC rtnl_rtscope_n2a(int id) 137const char* FAST_FUNC rtnl_rtscope_n2a(int id)
@@ -159,7 +161,7 @@ static void rtnl_rtrealm_initialize(void)
159 if (rtnl_rtrealm_tab) return; 161 if (rtnl_rtrealm_tab) return;
160 rtnl_rtrealm_tab = xzalloc(sizeof(*rtnl_rtrealm_tab)); 162 rtnl_rtrealm_tab = xzalloc(sizeof(*rtnl_rtrealm_tab));
161 rtnl_rtrealm_tab->tab[0] = "unknown"; 163 rtnl_rtrealm_tab->tab[0] = "unknown";
162 rtnl_tab_initialize("/etc/iproute2/rt_realms", rtnl_rtrealm_tab->tab); 164 rtnl_tab_initialize(CONFDIR "/rt_realms", rtnl_rtrealm_tab->tab);
163} 165}
164 166
165int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg) 167int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg)
@@ -191,7 +193,7 @@ static void rtnl_rtdsfield_initialize(void)
191 if (rtnl_rtdsfield_tab) return; 193 if (rtnl_rtdsfield_tab) return;
192 rtnl_rtdsfield_tab = xzalloc(sizeof(*rtnl_rtdsfield_tab)); 194 rtnl_rtdsfield_tab = xzalloc(sizeof(*rtnl_rtdsfield_tab));
193 rtnl_rtdsfield_tab->tab[0] = "0"; 195 rtnl_rtdsfield_tab->tab[0] = "0";
194 rtnl_tab_initialize("/etc/iproute2/rt_dsfield", rtnl_rtdsfield_tab->tab); 196 rtnl_tab_initialize(CONFDIR "/rt_dsfield", rtnl_rtdsfield_tab->tab);
195} 197}
196 198
197const char* FAST_FUNC rtnl_dsfield_n2a(int id) 199const char* FAST_FUNC rtnl_dsfield_n2a(int id)
@@ -227,7 +229,7 @@ static void rtnl_rttable_initialize(void)
227 rtnl_rttable_tab->tab[255] = "local"; 229 rtnl_rttable_tab->tab[255] = "local";
228 rtnl_rttable_tab->tab[254] = "main"; 230 rtnl_rttable_tab->tab[254] = "main";
229 rtnl_rttable_tab->tab[253] = "default"; 231 rtnl_rttable_tab->tab[253] = "default";
230 rtnl_tab_initialize("/etc/iproute2/rt_tables", rtnl_rttable_tab->tab); 232 rtnl_tab_initialize(CONFDIR "/rt_tables", rtnl_rttable_tab->tab);
231} 233}
232 234
233const char* FAST_FUNC rtnl_rttable_n2a(int id) 235const char* FAST_FUNC rtnl_rttable_n2a(int id)