summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-12-16 13:20:43 -0800
committerDavid S. Miller <davem@davemloft.net>2015-12-18 14:43:38 -0500
commit1a8524794fc7c70f44ac28e3a6e8fd637bc41f14 (patch)
treeb22904fd2471f40ae28b8a35e539f3ef8b70c0c9 /include/net
parentcc9da6cc4f56e05cc9e591459fe0192727ff58b3 (diff)
downloadop-kernel-dev-1a8524794fc7c70f44ac28e3a6e8fd637bc41f14.zip
op-kernel-dev-1a8524794fc7c70f44ac28e3a6e8fd637bc41f14.tar.gz
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>
Diffstat (limited to 'include/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 774d85b..786226f 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)
return ifindex;
}
+static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
+{
+ struct net_device *dev;
+ int rc = 0;
+
+ if (likely(ifindex)) {
+ rcu_read_lock();
+
+ dev = dev_get_by_index_rcu(net, ifindex);
+ if (dev)
+ rc = l3mdev_master_ifindex_rcu(dev);
+
+ rcu_read_unlock();
+ }
+
+ return rc;
+}
+
/* get index of an interface to use for FIB lookups. For devices
* enslaved to an L3 master device FIB lookups are based on the
* master index
@@ -167,6 +185,11 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
return 0;
}
+static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
+{
+ return 0;
+}
+
static inline int l3mdev_fib_oif_rcu(struct net_device *dev)
{
return dev ? dev->ifindex : 0;
OpenPOWER on IntegriCloud