netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iproute2: initialize the ll_map only once
@ 2010-12-10 14:59 Octavian Purdila
  2010-12-10 19:38 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Octavian Purdila @ 2010-12-10 14:59 UTC (permalink / raw)
  To: netdev; +Cc: Lucian Adrian Grijincu, Vlad Dogaru, Octavian Purdila

Avoid initializing the LL map (which involves a costly RTNL dump)
multiple times. This can happen when running in batch mode.

Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
---
 lib/ll_map.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/lib/ll_map.c b/lib/ll_map.c
index 9831322..9c6144a 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -266,6 +266,11 @@ unsigned ll_name_to_index(const char *name)
 
 int ll_init_map(struct rtnl_handle *rth)
 {
+	static int initialized;
+
+	if (initialized)
+		return 0;
+
 	if (rtnl_wilddump_request(rth, AF_UNSPEC, RTM_GETLINK) < 0) {
 		perror("Cannot send dump request");
 		exit(1);
@@ -275,5 +280,8 @@ int ll_init_map(struct rtnl_handle *rth)
 		fprintf(stderr, "Dump terminated\n");
 		exit(1);
 	}
+
+	initialized = 1;
+
 	return 0;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-17 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-10 14:59 [PATCH] iproute2: initialize the ll_map only once Octavian Purdila
2010-12-10 19:38 ` Stephen Hemminger
2010-12-17 13:06   ` Denys Fedoryshchenko

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).