From patchwork Fri Dec 10 14:59:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 75098 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 3B1ECB70AA for ; Sat, 11 Dec 2010 02:00:11 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755617Ab0LJPAD (ORCPT ); Fri, 10 Dec 2010 10:00:03 -0500 Received: from ixro-out-rtc.ixiacom.com ([92.87.192.98]:2409 "EHLO ixro-ex1.ixiacom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754899Ab0LJPAD (ORCPT ); Fri, 10 Dec 2010 10:00:03 -0500 Received: from ixro-opurdila.ixiacom.com ([10.205.9.176]) by ixro-ex1.ixiacom.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 10 Dec 2010 17:00:00 +0200 From: Octavian Purdila To: netdev@vger.kernel.org Cc: Lucian Adrian Grijincu , Vlad Dogaru , Octavian Purdila Subject: [PATCH] iproute2: initialize the ll_map only once Date: Fri, 10 Dec 2010 16:59:50 +0200 Message-Id: <1291993190-8838-1-git-send-email-opurdila@ixiacom.com> X-Mailer: git-send-email 1.7.1 X-OriginalArrivalTime: 10 Dec 2010 15:00:01.0008 (UTC) FILETIME=[EB3A2700:01CB987A] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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; }