diff mbox

[2/2] iproute2: use named constants instead of number literals to fill rtnl_rttable_hash

Message ID 1394187697-1147-2-git-send-email-yamato@redhat.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Masatake YAMATO March 7, 2014, 10:21 a.m. UTC
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 lib/rt_names.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

Comments

Stephen Hemminger March 10, 2014, 8:23 p.m. UTC | #1
On Fri,  7 Mar 2014 19:21:37 +0900
Masatake YAMATO <yamato@redhat.com> wrote:

> Signed-off-by: Masatake YAMATO <yamato@redhat.com>

Both applied
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/rt_names.c b/lib/rt_names.c
index b005a64..911e4d2 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -314,21 +314,27 @@  int rtnl_rtrealm_a2n(__u32 *id, const char *arg)
 }
 
 
-static struct rtnl_hash_entry dflt_table_entry  = { .id = 253, .name = "default" };
-static struct rtnl_hash_entry main_table_entry  = { .id = 254, .name = "main" };
-static struct rtnl_hash_entry local_table_entry = { .id = 255, .name = "local" };
+static struct rtnl_hash_entry dflt_table_entry  = { .name = "default" };
+static struct rtnl_hash_entry main_table_entry  = { .name = "main" };
+static struct rtnl_hash_entry local_table_entry = { .name = "local" };
 
 static struct rtnl_hash_entry * rtnl_rttable_hash[256] = {
-	[253] = &dflt_table_entry,
-	[254] = &main_table_entry,
-	[255] = &local_table_entry,
+	[RT_TABLE_DEFAULT] = &dflt_table_entry,
+	[RT_TABLE_MAIN]    = &main_table_entry,
+	[RT_TABLE_LOCAL]   = &local_table_entry,
 };
 
 static int rtnl_rttable_init;
 
 static void rtnl_rttable_initialize(void)
 {
+	int i;
+
 	rtnl_rttable_init = 1;
+	for (i = 0; i < 256; i++) {
+		if (rtnl_rttable_hash[i])
+			rtnl_rttable_hash[i]->id = i;
+	}
 	rtnl_hash_initialize(CONFDIR "/rt_tables",
 			     rtnl_rttable_hash, 256);
 }