public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind•com>
To: Vadim Kochan <vadim4j@gmail•com>
Cc: shemminger@vyatta•com, netdev@vger•kernel.org
Subject: Re: [PATCH iproute2-next 2/2] netns: allow to dump and monitor nsid
Date: Fri, 10 Apr 2015 16:03:35 +0200	[thread overview]
Message-ID: <5527D837.9030506@6wind.com> (raw)
In-Reply-To: <20150409083601.GA1085@angus-think.wlc.globallogic.com>

Le 09/04/2015 10:36, Vadim Kochan a écrit :
> On Thu, Apr 09, 2015 at 10:30:14AM +0200, Nicolas Dichtel wrote:
[snip]
>> +	dir = opendir(NETNS_RUN_DIR);
>> +	if (!dir)
>> +		return;
>> +
>> +	while ((entry = readdir(dir)) != NULL) {
>> +		if (strcmp(entry->d_name, ".") == 0)
>> +			continue;
>> +		if (strcmp(entry->d_name, "..") == 0)
>> +			continue;
>> +		nsid = get_netnsid_from_name(entry->d_name);
>> +
>> +		if (nsid >= 0)
>> +			netns_map_add(nsid, entry->d_name);
>> +	}
>
> May be lib/namespace.c -> netns_foreach will be useful here  ?
I'm not fully convinced, because to use netns_foreach I need to have
another intermediate function.

[snip]
>> +	dir = opendir(NETNS_RUN_DIR);
>> +	if (!dir)
>> +		return -ENOENT;
>> +
>> +	while ((entry = readdir(dir)) != NULL) {
>> +		if (strcmp(entry->d_name, ".") == 0)
>> +			continue;
>> +		if (strcmp(entry->d_name, "..") == 0)
>> +			continue;
>> +		id = get_netnsid_from_name(entry->d_name);
>> +
>> +		if (nsid == id) {
>> +			strcpy(name, entry->d_name);
>> +			closedir(dir);
>> +			return 0;
>> +		}
>> +	}
>
> And may be here too ?
Same here. And this implies to also define a new structure to pass 'name' and
'nsid' to this new intermediate function. This will make the code more complex
to read.


Regards,
Nicolas

  reply	other threads:[~2015-04-10 14:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09  8:30 [PATCH iproute2-next 1/2] include: update linux/rtnetlink.h Nicolas Dichtel
2015-04-09  8:30 ` [PATCH iproute2-next 2/2] netns: allow to dump and monitor nsid Nicolas Dichtel
2015-04-09  8:36   ` Vadim Kochan
2015-04-10 14:03     ` Nicolas Dichtel [this message]
2015-04-09  8:48   ` Vadim Kochan
2015-04-10 14:03     ` Nicolas Dichtel
2015-04-15 12:23   ` [PATCH v2 iproute2] " Nicolas Dichtel
2015-04-10 20:24 ` [PATCH iproute2-next 1/2] include: update linux/rtnetlink.h Stephen Hemminger
     [not found] ` <797e9129b12148228f163402c284dce6@HQ1WP-EXMB12.corp.brocade.com>
2015-04-20 17:02   ` [PATCH iproute2-next 2/2] netns: allow to dump and monitor nsid Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5527D837.9030506@6wind.com \
    --to=nicolas.dichtel@6wind$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shemminger@vyatta$(echo .)com \
    --cc=vadim4j@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox