aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-12-16 16:20:43 -0500
committerDavid S. Miller <davem@davemloft.net>2015-12-18 14:43:38 -0500
commit1a8524794fc7c70f44ac28e3a6e8fd637bc41f14 (patch)
treeb22904fd2471f40ae28b8a35e539f3ef8b70c0c9
parentcc9da6cc4f56e05cc9e591459fe0192727ff58b3 (diff)
net: l3mdev: Add master device lookup by index
Add helper to lookup l3mdev master index given a device index. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/l3mdev.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h
index 774d85b2d5d9..786226f8e77b 100644
--- a/include/net/l3mdev.h
+++ b/include/net/l3mdev.h
@@ -51,6 +51,24 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
51 return ifindex; 51 return ifindex;
52} 52}
53 53
54static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
55{
56 struct net_device *dev;
57 int rc = 0;
58
59 if (likely(ifindex)) {
60 rcu_read_lock();
61
62 dev = dev_get_by_index_rcu(net, ifindex);
63 if (dev)
64 rc = l3mdev_master_ifindex_rcu(dev);
65
66 rcu_read_unlock();
67 }
68
69 return rc;
70}
71
54/* get index of an interface to use for FIB lookups. For devices 72/* get index of an interface to use for FIB lookups. For devices
55 * enslaved to an L3 master device FIB lookups are based on the 73 * enslaved to an L3 master device FIB lookups are based on the
56 * master index 74 * master index
@@ -167,6 +185,11 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
167 return 0; 185 return 0;
168} 186}
169 187
188static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
189{
190 return 0;
191}
192
170static inline int l3mdev_fib_oif_rcu(struct net_device *dev) 193static inline int l3mdev_fib_oif_rcu(struct net_device *dev)
171{ 194{
172 return dev ? dev->ifindex : 0; 195 return dev ? dev->ifindex : 0;