public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: David Ahern <dsa@cumulusnetworks•com>
To: Florian Westphal <fw@strlen•de>
Cc: netdev@vger•kernel.org, eric.dumazet@gmail•com
Subject: Re: [PATCH] net: Updates to netif_index_is_vrf
Date: Sun, 16 Aug 2015 07:34:12 -0600	[thread overview]
Message-ID: <55D09154.9030206@cumulusnetworks.com> (raw)
In-Reply-To: <20150816003926.GA31357@breakpoint.cc>

On 8/15/15 6:39 PM, Florian Westphal wrote:
> David Ahern <dsa@cumulusnetworks•com> wrote:
>> As Eric noted netif_index_is_vrf is not called with rcu_read_lock held,
>> so use dev_get_by_index instead of dev_get_by_index_rcu.
>>
>> If VRF is not enabled or oif is 0 skip the device lookup.
>>
>> Signed-off-by: David Ahern <dsa@cumulusnetworks•com>
>
> Why not
>
>>   static inline bool netif_index_is_vrf(struct net *net, int ifindex)
>>   {
>> -	struct net_device *dev = dev_get_by_index_rcu(net, ifindex);
>>   	bool rc = false;
>>
>> -	if (dev)
>> -		rc = netif_is_vrf(dev);
>> +#if IS_ENABLED(CONFIG_NET_VRF)
>> +	struct net_device *dev;
>> +
>> +	if (ifindex == 0)
>> +		return false;
>
> 	rcu_read_lock();
>
> 	dev = dev_get_by_index_rcu(net, ifindex);
> 	if (dev)
> 		rc = netif_is_vrf(dev);
>
> 	rcu_read_unlock();
>
>> +#endif
>>   	return rc;
>
> instead?

sure. That saves the inc and dec on the refcnt. will respin.

David

      reply	other threads:[~2015-08-16 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-16  0:09 [PATCH] net: Updates to netif_index_is_vrf David Ahern
2015-08-16  0:39 ` Florian Westphal
2015-08-16 13:34   ` David Ahern [this message]

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=55D09154.9030206@cumulusnetworks.com \
    --to=dsa@cumulusnetworks$(echo .)com \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=fw@strlen$(echo .)de \
    --cc=netdev@vger$(echo .)kernel.org \
    /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