netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: netdev@vger.kernel.org
Cc: yamato@redhat.com
Subject: [PATCH 2/2] iproute2: use named constants instead of number literals to fill rtnl_rttable_hash
Date: Fri,  7 Mar 2014 19:21:37 +0900	[thread overview]
Message-ID: <1394187697-1147-2-git-send-email-yamato@redhat.com> (raw)
In-Reply-To: <1394187697-1147-1-git-send-email-yamato@redhat.com>

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
 lib/rt_names.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

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);
 }
-- 
1.8.5.3

  reply	other threads:[~2014-03-07 10:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 10:21 [PATCH 1/2] iproute2: use named constants instead of number literals to fill rtnl_rtscope_tab Masatake YAMATO
2014-03-07 10:21 ` Masatake YAMATO [this message]
2014-03-10 20:23   ` [PATCH 2/2] iproute2: use named constants instead of number literals to fill rtnl_rttable_hash Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394187697-1147-2-git-send-email-yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).