aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 17:15:08 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 17:15:08 +0200
commit8403b01217d4dfc86e8603715eeb52f9993e09b7 (patch)
treec25cf1aac0b3d8fdf9dfa4d70328ca7f9425a98d /networking
parentd1eea8db92e963e3c482d96b10da2ec0f9c95770 (diff)
downloadbusybox-w32-8403b01217d4dfc86e8603715eeb52f9993e09b7.tar.gz
busybox-w32-8403b01217d4dfc86e8603715eeb52f9993e09b7.tar.bz2
busybox-w32-8403b01217d4dfc86e8603715eeb52f9993e09b7.zip
iproute: more string reuse
text data bss dec hex filename 936892 932 17676 955500 e946c busybox_old 936843 932 17676 955451 e943b busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/libiproute/rt_names.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c
index ca0bb5d4d..51f2e9bdb 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -28,8 +28,11 @@ typedef struct rtnl_tab_t {
28static void rtnl_tab_initialize(const char *file, const char **tab) 28static void rtnl_tab_initialize(const char *file, const char **tab)
29{ 29{
30 char *token[2]; 30 char *token[2];
31 parser_t *parser = config_open2(file, fopen_for_read); 31 char fullname[sizeof(CONFDIR"/rt_dsfield") + 8];
32 parser_t *parser;
32 33
34 sprintf(fullname, CONFDIR"/rt_%s", file);
35 parser = config_open2(fullname, fopen_for_read);
33 while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) { 36 while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
34 unsigned id = bb_strtou(token[0], NULL, 0); 37 unsigned id = bb_strtou(token[0], NULL, 0);
35 if (id > RT_TABLE_MAX) { 38 if (id > RT_TABLE_MAX) {
@@ -94,7 +97,7 @@ static void rtnl_rtprot_initialize(void)
94 return; 97 return;
95 rtnl_rtprot_tab = xzalloc(sizeof(*rtnl_rtprot_tab)); 98 rtnl_rtprot_tab = xzalloc(sizeof(*rtnl_rtprot_tab));
96 memcpy(rtnl_rtprot_tab->tab, init_tab, sizeof(init_tab)); 99 memcpy(rtnl_rtprot_tab->tab, init_tab, sizeof(init_tab));
97 rtnl_tab_initialize(CONFDIR "/rt_protos", rtnl_rtprot_tab->tab); 100 rtnl_tab_initialize("protos", rtnl_rtprot_tab->tab);
98} 101}
99 102
100#if 0 /* UNUSED */ 103#if 0 /* UNUSED */
@@ -131,7 +134,7 @@ static void rtnl_rtscope_initialize(void)
131 rtnl_rtscope_tab->tab[254] = "host"; 134 rtnl_rtscope_tab->tab[254] = "host";
132 rtnl_rtscope_tab->tab[253] = "link"; 135 rtnl_rtscope_tab->tab[253] = "link";
133 rtnl_rtscope_tab->tab[200] = "site"; 136 rtnl_rtscope_tab->tab[200] = "site";
134 rtnl_tab_initialize(CONFDIR "/rt_scopes", rtnl_rtscope_tab->tab); 137 rtnl_tab_initialize("scopes", rtnl_rtscope_tab->tab);
135} 138}
136 139
137const char* FAST_FUNC rtnl_rtscope_n2a(int id) 140const char* FAST_FUNC rtnl_rtscope_n2a(int id)
@@ -161,7 +164,7 @@ static void rtnl_rtrealm_initialize(void)
161 if (rtnl_rtrealm_tab) return; 164 if (rtnl_rtrealm_tab) return;
162 rtnl_rtrealm_tab = xzalloc(sizeof(*rtnl_rtrealm_tab)); 165 rtnl_rtrealm_tab = xzalloc(sizeof(*rtnl_rtrealm_tab));
163 rtnl_rtrealm_tab->tab[0] = "unknown"; 166 rtnl_rtrealm_tab->tab[0] = "unknown";
164 rtnl_tab_initialize(CONFDIR "/rt_realms", rtnl_rtrealm_tab->tab); 167 rtnl_tab_initialize("realms", rtnl_rtrealm_tab->tab);
165} 168}
166 169
167int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg) 170int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg)
@@ -193,7 +196,7 @@ static void rtnl_rtdsfield_initialize(void)
193 if (rtnl_rtdsfield_tab) return; 196 if (rtnl_rtdsfield_tab) return;
194 rtnl_rtdsfield_tab = xzalloc(sizeof(*rtnl_rtdsfield_tab)); 197 rtnl_rtdsfield_tab = xzalloc(sizeof(*rtnl_rtdsfield_tab));
195 rtnl_rtdsfield_tab->tab[0] = "0"; 198 rtnl_rtdsfield_tab->tab[0] = "0";
196 rtnl_tab_initialize(CONFDIR "/rt_dsfield", rtnl_rtdsfield_tab->tab); 199 rtnl_tab_initialize("dsfield", rtnl_rtdsfield_tab->tab);
197} 200}
198 201
199const char* FAST_FUNC rtnl_dsfield_n2a(int id) 202const char* FAST_FUNC rtnl_dsfield_n2a(int id)
@@ -229,7 +232,7 @@ static void rtnl_rttable_initialize(void)
229 rtnl_rttable_tab->tab[255] = "local"; 232 rtnl_rttable_tab->tab[255] = "local";
230 rtnl_rttable_tab->tab[254] = "main"; 233 rtnl_rttable_tab->tab[254] = "main";
231 rtnl_rttable_tab->tab[253] = "default"; 234 rtnl_rttable_tab->tab[253] = "default";
232 rtnl_tab_initialize(CONFDIR "/rt_tables", rtnl_rttable_tab->tab); 235 rtnl_tab_initialize("tables", rtnl_rttable_tab->tab);
233} 236}
234 237
235const char* FAST_FUNC rtnl_rttable_n2a(int id) 238const char* FAST_FUNC rtnl_rttable_n2a(int id)