All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roopa Prabhu <roopa@cumulusnetworks.com>
To: vadim4j@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] ip link: Show devices by link type
Date: Wed, 03 Dec 2014 06:40:10 -0800	[thread overview]
Message-ID: <547F20CA.4060501@cumulusnetworks.com> (raw)
In-Reply-To: <20141203011305.GA5945@angus-think.lan>

On 12/2/14, 5:13 PM, vadim4j@gmail.com wrote:
> On Tue, Dec 02, 2014 at 04:55:44PM -0800, Roopa Prabhu wrote:
>>>   	int master;
>>> +	char *link_kind;
>> The name can be just "kind", given all the others dont use the link prefix
>>>   } filter;
> OK
>
>>> +	if (filter.link_kind && tb[IFLA_LINKINFO]) {
>>> +		char *link_kind = parse_link_kind(tb[IFLA_LINKINFO]);
>>> +		if (strcmp(link_kind, filter.link_kind)) {
>>> +			return -1;
>>> +		}
>> you can skip the braces
>>> +	} else if (filter.link_kind)
>> you have if (filter.link_kind) twice, you can use a single if without the
>> else.
>>> +		return -1;
>>> +
> I need to skip interfaces which has not IFLA_LINKINFO attribute,
> w/o "else if(...)" I get bridges with normal ether devices:
>      
>      bash# ip link show type bridge
>
>      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
>          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>      2: enp0s25: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
>          link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
>      5: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default
>          link/ether 6e:02:f9:17:7f:10 brd ff:ff:ff:ff:ff:ff
>
> but expected result should be only bridges.

I was just saying, it could be:

if (filter.link_kind) {
     if (tb[IFLA_LINKINFO]) {
         char *kind = parse_link_kind(tb[IFLA_LINKINFO]);
         if (strcmp(kind, filter.kind))
             return -1;
     } else {
       return -1;
     }
}

  parent reply	other threads:[~2014-12-03 14:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-30 17:58 [PATCH iproute2] ip link: Show devices by link type Vadim Kochan
2014-12-02 22:01 ` Vadim Kochan
2014-12-03  0:55 ` Roopa Prabhu
2014-12-03  1:13   ` vadim4j
2014-12-03 10:59     ` Vadim Kochan
2014-12-03 14:40     ` Roopa Prabhu [this message]
2014-12-03 14:47       ` Vadim Kochan
2014-12-03 15:08         ` Vadim Kochan

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=547F20CA.4060501@cumulusnetworks.com \
    --to=roopa@cumulusnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=vadim4j@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.