iproute2: initialize the ll_map only once
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>
diff --git a/lib/ll_map.c b/lib/ll_map.c
index afd5e35..b8a3483 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -185,6 +185,11 @@
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 @@
fprintf(stderr, "Dump terminated\n");
exit(1);
}
+
+ initialized = 1;
+
return 0;
}