netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Updates to netif_index_is_vrf
@ 2015-08-16  0:09 David Ahern
  2015-08-16  0:39 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2015-08-16  0:09 UTC (permalink / raw)
  To: netdev; +Cc: eric.dumazet, David Ahern

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>
---
 include/linux/netdevice.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f7a6ef2fae3a..dca36a618781 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3819,12 +3819,20 @@ 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 (dev)
-		rc = netif_is_vrf(dev);
+#if IS_ENABLED(CONFIG_NET_VRF)
+	struct net_device *dev;
+
+	if (ifindex == 0)
+		return false;
 
+	dev = dev_get_by_index(net, ifindex);
+	if (dev) {
+		rc = netif_is_vrf(dev);
+		dev_put(dev);
+	}
+#endif
 	return rc;
 }
 
-- 
2.3.2 (Apple Git-55)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-16 13:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).