]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iproute2: initialize the ll_map only once
authorOctavian Purdila <opurdila@ixiacom.com>
Fri, 10 Dec 2010 14:59:50 +0000 (16:59 +0200)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Fri, 10 Dec 2010 19:37:57 +0000 (11:37 -0800)
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

index afd5e357cc26239b37cd85267d287c728b390da4..b8a34830d067cf0bdb5150fbc4368b13259907bc 100644 (file)
@@ -185,6 +185,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);
@@ -194,5 +199,8 @@ int ll_init_map(struct rtnl_handle *rth)
                fprintf(stderr, "Dump terminated\n");
                exit(1);
        }
+
+       initialized = 1;
+
        return 0;
 }