aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 15:10:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-08 15:10:10 +0200
commit413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6 (patch)
tree4359864e34176a143629be3b906ea74a7272fce4
parent3d8d5e8ad4d2df71e0307c385b3784586b545cbc (diff)
downloadbusybox-w32-413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6.tar.gz
busybox-w32-413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6.tar.bz2
busybox-w32-413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6.zip
ip: increased max ID for /etc/iproute2/rt_tables to 1023
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/libiproute/rt_names.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c
index 375f14528..8dea5ac52 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -13,7 +13,14 @@
13typedef struct rtnl_tab_t { 13typedef struct rtnl_tab_t {
14 const char *cached_str; 14 const char *cached_str;
15 unsigned cached_result; 15 unsigned cached_result;
16 const char *tab[256]; 16 /* upstream version switched to a hash table and removed
17 * id < 256 limit. For now bbox bumps this array size from 256
18 * to 1024. If you plan to change this to a hash table,
19 * consider merging several hash tables we have (for example,
20 * awk has resizable one!
21 */
22#define RT_TABLE_MAX 1023
23 const char *tab[RT_TABLE_MAX+1];
17} rtnl_tab_t; 24} rtnl_tab_t;
18 25
19static void rtnl_tab_initialize(const char *file, const char **tab) 26static void rtnl_tab_initialize(const char *file, const char **tab)
@@ -23,7 +30,7 @@ static void rtnl_tab_initialize(const char *file, const char **tab)
23 30
24 while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) { 31 while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
25 unsigned id = bb_strtou(token[0], NULL, 0); 32 unsigned id = bb_strtou(token[0], NULL, 0);
26 if (id > 256) { 33 if (id > RT_TABLE_MAX) {
27 bb_error_msg("database %s is corrupted at line %d", 34 bb_error_msg("database %s is corrupted at line %d",
28 file, parser->lineno); 35 file, parser->lineno);
29 break; 36 break;
@@ -42,7 +49,7 @@ static int rtnl_a2n(rtnl_tab_t *tab, uint32_t *id, const char *arg, int base)
42 return 0; 49 return 0;
43 } 50 }
44 51
45 for (i = 0; i < 256; i++) { 52 for (i = 0; i <= RT_TABLE_MAX; i++) {
46 if (tab->tab[i] 53 if (tab->tab[i]
47 && strcmp(tab->tab[i], arg) == 0 54 && strcmp(tab->tab[i], arg) == 0
48 ) { 55 ) {
@@ -54,7 +61,7 @@ static int rtnl_a2n(rtnl_tab_t *tab, uint32_t *id, const char *arg, int base)
54 } 61 }
55 62
56 i = bb_strtou(arg, NULL, base); 63 i = bb_strtou(arg, NULL, base);
57 if (i > 255) 64 if (i > RT_TABLE_MAX)
58 return -1; 65 return -1;
59 *id = i; 66 *id = i;
60 return 0; 67 return 0;
@@ -91,7 +98,7 @@ static void rtnl_rtprot_initialize(void)
91#if 0 /* UNUSED */ 98#if 0 /* UNUSED */
92const char* FAST_FUNC rtnl_rtprot_n2a(int id) 99const char* FAST_FUNC rtnl_rtprot_n2a(int id)
93{ 100{
94 if (id < 0 || id >= 256) { 101 if (id < 0 || id > RT_TABLE_MAX) {
95 return itoa(id); 102 return itoa(id);
96 } 103 }
97 104
@@ -127,7 +134,7 @@ static void rtnl_rtscope_initialize(void)
127 134
128const char* FAST_FUNC rtnl_rtscope_n2a(int id) 135const char* FAST_FUNC rtnl_rtscope_n2a(int id)
129{ 136{
130 if (id < 0 || id >= 256) { 137 if (id < 0 || id > RT_TABLE_MAX) {
131 return itoa(id); 138 return itoa(id);
132 } 139 }
133 140
@@ -164,7 +171,7 @@ int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg)
164#if ENABLE_FEATURE_IP_RULE 171#if ENABLE_FEATURE_IP_RULE
165const char* FAST_FUNC rtnl_rtrealm_n2a(int id) 172const char* FAST_FUNC rtnl_rtrealm_n2a(int id)
166{ 173{
167 if (id < 0 || id >= 256) { 174 if (id < 0 || id > RT_TABLE_MAX) {
168 return itoa(id); 175 return itoa(id);
169 } 176 }
170 177
@@ -189,7 +196,7 @@ static void rtnl_rtdsfield_initialize(void)
189 196
190const char* FAST_FUNC rtnl_dsfield_n2a(int id) 197const char* FAST_FUNC rtnl_dsfield_n2a(int id)
191{ 198{
192 if (id < 0 || id >= 256) { 199 if (id < 0 || id > RT_TABLE_MAX) {
193 return itoa(id); 200 return itoa(id);
194 } 201 }
195 202
@@ -212,7 +219,9 @@ static rtnl_tab_t *rtnl_rttable_tab;
212 219
213static void rtnl_rttable_initialize(void) 220static void rtnl_rttable_initialize(void)
214{ 221{
215 if (rtnl_rtdsfield_tab) return; 222 if (rtnl_rttable_tab)
223 return;
224
216 rtnl_rttable_tab = xzalloc(sizeof(*rtnl_rttable_tab)); 225 rtnl_rttable_tab = xzalloc(sizeof(*rtnl_rttable_tab));
217 rtnl_rttable_tab->tab[0] = "unspec"; 226 rtnl_rttable_tab->tab[0] = "unspec";
218 rtnl_rttable_tab->tab[255] = "local"; 227 rtnl_rttable_tab->tab[255] = "local";
@@ -223,7 +232,7 @@ static void rtnl_rttable_initialize(void)
223 232
224const char* FAST_FUNC rtnl_rttable_n2a(int id) 233const char* FAST_FUNC rtnl_rttable_n2a(int id)
225{ 234{
226 if (id < 0 || id >= 256) { 235 if (id < 0 || id > RT_TABLE_MAX) {
227 return itoa(id); 236 return itoa(id);
228 } 237 }
229 238