diff mbox

iproute2: initialize the ll_map only once

Message ID 1291993190-8838-1-git-send-email-opurdila@ixiacom.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Octavian Purdila Dec. 10, 2010, 2:59 p.m. UTC
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(-)

Comments

stephen hemminger Dec. 10, 2010, 7:38 p.m. UTC | #1
On Fri, 10 Dec 2010 16:59:50 +0200
Octavian Purdila <opurdila@ixiacom.com> wrote:

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

applied
Denys Fedoryshchenko Dec. 17, 2010, 1:06 p.m. UTC | #2
On Friday 10 December 2010 21:38:09 Stephen Hemminger wrote:
> On Fri, 10 Dec 2010 16:59:50 +0200
> 
> Octavian Purdila <opurdila@ixiacom.com> wrote:
> > 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>
> 
> applied
There is some longstanding bug related to current hashing system.
To "workaround" it i did my own "flush" command, to flush hashes, but with 
this patch it becomes more difficult to handle this situation.
Here is how to reproduce it:

ip -force -batch -
link add link eth0 name new0 type macvlan
link show dev new0
link delete dev new0 type macvlan
link add link eth0 name new0 type macvlan
link show dev new0

Last command will not show link, because index of old one is stored in hash.

I guess it is more bugreport for old problem, than problem with current patch.
Sure it is possible to flush hash on del/add operations, but additionally 
during batch run it is possible that interfaces can appear/disappear (NAS with 
thousands of ppp interfaces). Maybe still as an idea i can do patch with flag 
to dump rtnl before each command and additional "flush hash" command?

--
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/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;
 }