From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Dichtel Subject: Re: [PATCH iproute2 v2 1/2] ip: display netns name instead of nsid Date: Wed, 6 Jun 2018 09:11:27 +0200 Message-ID: <5b376a25-8549-b477-4212-3d935590aa7a@6wind.com> References: <20180604141215.0669f05f@xeon-e3> <20180605130831.8175-1-nicolas.dichtel@6wind.com> <20180605130831.8175-2-nicolas.dichtel@6wind.com> <20180605095224.1921fee5@xeon-e3> Reply-To: nicolas.dichtel@6wind.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org To: Stephen Hemminger Return-path: Received: from mail-wm0-f65.google.com ([74.125.82.65]:35726 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932113AbeFFHLb (ORCPT ); Wed, 6 Jun 2018 03:11:31 -0400 Received: by mail-wm0-f65.google.com with SMTP id j15-v6so9841909wme.0 for ; Wed, 06 Jun 2018 00:11:30 -0700 (PDT) In-Reply-To: <20180605095224.1921fee5@xeon-e3> Content-Language: fr Sender: netdev-owner@vger.kernel.org List-ID: Le 05/06/2018 à 18:52, Stephen Hemminger a écrit : > On Tue, 5 Jun 2018 15:08:30 +0200 > Nicolas Dichtel wrote: > >> >> +char *get_name_from_nsid(int nsid) >> +{ >> + struct nsid_cache *c; >> + >> + netns_nsid_socket_init(); >> + netns_map_init(); >> + >> + c = netns_map_get_by_nsid(nsid); >> + if (c) >> + return c->name; >> + >> + return NULL; >> +} >> + > > This is better, but now there is a different problem. > When doing multiple interfaces, won't the initialization code be called twice? > No, the init function is propected: void netns_nsid_socket_init(void) { if (rtnsh.fd > -1 || !ipnetns_have_nsid()) return; ... void netns_map_init(void) { ... if (initialized || !ipnetns_have_nsid()) return; ...