aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-08-16 07:49:20 -0600
committerDavid S. Miller <davem@davemloft.net>2015-08-17 15:55:15 -0700
commit2f52bdcf6ba1bd81597b1505a222430676548b3a (patch)
treedd5fc84765a9c327b4008d0e22530636f1002fff /include/linux
parentMerge branch 'mlx5e-next' (diff)
downloadlinux-dev-2f52bdcf6ba1bd81597b1505a222430676548b3a.tar.xz
linux-dev-2f52bdcf6ba1bd81597b1505a222430676548b3a.zip
net: Updates to netif_index_is_vrf
As Eric noted netif_index_is_vrf is not called with rcu_read_lock held, so wrap the dev_get_by_index_rcu in rcu_read_lock and unlock. If VRF is not enabled or oif is 0 skip the device lookup. In both cases index cannot be the VRF master. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/netdevice.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d131755516ca..8a530f930754 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3822,12 +3822,22 @@ static inline bool netif_is_vrf(const struct net_device *dev)
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 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;
}