summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko2015-10-08 15:10:10 +0200
committerDenys Vlasenko2015-10-08 15:10:10 +0200
commit413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6 (patch)
tree4359864e34176a143629be3b906ea74a7272fce4 /networking
parent3d8d5e8ad4d2df71e0307c385b3784586b545cbc (diff)
downloadbusybox-413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6.zip
busybox-413feca279c21ef23a3b3d6f4ebc6c3d989bbdc6.tar.gz
ip: increased max ID for /etc/iproute2/rt_tables to 1023
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-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 375f145..8dea5ac 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -13,7 +13,14 @@
typedef struct rtnl_tab_t {
const char *cached_str;
unsigned cached_result;
- const char *tab[256];
+ /* upstream version switched to a hash table and removed
+ * id < 256 limit. For now bbox bumps this array size from 256
+ * to 1024. If you plan to change this to a hash table,
+ * consider merging several hash tables we have (for example,
+ * awk has resizable one!
+ */
+#define RT_TABLE_MAX 1023
+ const char *tab[RT_TABLE_MAX+1];
} rtnl_tab_t;
static 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)
while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
unsigned id = bb_strtou(token[0], NULL, 0);
- if (id > 256) {
+ if (id > RT_TABLE_MAX) {
bb_error_msg("database %s is corrupted at line %d",
file, parser->lineno);
break;
@@ -42,7 +49,7 @@ static int rtnl_a2n(rtnl_tab_t *tab, uint32_t *id, const char *arg, int base)
return 0;
}
- for (i = 0; i < 256; i++) {
+ for (i = 0; i <= RT_TABLE_MAX; i++) {
if (tab->tab[i]
&& strcmp(tab->tab[i], arg) == 0
) {
@@ -54,7 +61,7 @@ static int rtnl_a2n(rtnl_tab_t *tab, uint32_t *id, const char *arg, int base)
}
i = bb_strtou(arg, NULL, base);
- if (i > 255)
+ if (i > RT_TABLE_MAX)
return -1;
*id = i;
return 0;
@@ -91,7 +98,7 @@ static void rtnl_rtprot_initialize(void)
#if 0 /* UNUSED */
const char* FAST_FUNC rtnl_rtprot_n2a(int id)
{
- if (id < 0 || id >= 256) {
+ if (id < 0 || id > RT_TABLE_MAX) {
return itoa(id);
}
@@ -127,7 +134,7 @@ static void rtnl_rtscope_initialize(void)
const char* FAST_FUNC rtnl_rtscope_n2a(int id)
{
- if (id < 0 || id >= 256) {
+ if (id < 0 || id > RT_TABLE_MAX) {
return itoa(id);
}
@@ -164,7 +171,7 @@ int FAST_FUNC rtnl_rtrealm_a2n(uint32_t *id, char *arg)
#if ENABLE_FEATURE_IP_RULE
const char* FAST_FUNC rtnl_rtrealm_n2a(int id)
{
- if (id < 0 || id >= 256) {
+ if (id < 0 || id > RT_TABLE_MAX) {
return itoa(id);
}
@@ -189,7 +196,7 @@ static void rtnl_rtdsfield_initialize(void)
const char* FAST_FUNC rtnl_dsfield_n2a(int id)
{
- if (id < 0 || id >= 256) {
+ if (id < 0 || id > RT_TABLE_MAX) {
return itoa(id);
}
@@ -212,7 +219,9 @@ static rtnl_tab_t *rtnl_rttable_tab;
static void rtnl_rttable_initialize(void)
{
- if (rtnl_rtdsfield_tab) return;
+ if (rtnl_rttable_tab)
+ return;
+
rtnl_rttable_tab = xzalloc(sizeof(*rtnl_rttable_tab));
rtnl_rttable_tab->tab[0] = "unspec";
rtnl_rttable_tab->tab[255] = "local";
@@ -223,7 +232,7 @@ static void rtnl_rttable_initialize(void)
const char* FAST_FUNC rtnl_rttable_n2a(int id)
{
- if (id < 0 || id >= 256) {
+ if (id < 0 || id > RT_TABLE_MAX) {
return itoa(id);
}