From patchwork Fri Mar 7 10:21:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masatake YAMATO X-Patchwork-Id: 327872 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4F41F2C0344 for ; Fri, 7 Mar 2014 21:22:19 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752761AbaCGKWO (ORCPT ); Fri, 7 Mar 2014 05:22:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13313 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753178AbaCGKWN (ORCPT ); Fri, 7 Mar 2014 05:22:13 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s27AMA5Q010550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Mar 2014 05:22:10 -0500 Received: from localhost.localdomain.com (dhcp-193-237.nrt.redhat.com [10.64.193.237]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s27ALpqO019801; Fri, 7 Mar 2014 05:22:09 -0500 From: Masatake YAMATO 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 Message-Id: <1394187697-1147-2-git-send-email-yamato@redhat.com> In-Reply-To: <1394187697-1147-1-git-send-email-yamato@redhat.com> References: <1394187697-1147-1-git-send-email-yamato@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Masatake YAMATO --- 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); }