Commit ac503ab4 authored by David Ahern's avatar David Ahern Committed by Kleber Sacilotto de Souza

net: l3mdev: Add master device lookup by index

BugLink: http://bugs.launchpad.net/bugs/1744078

Add helper to lookup l3mdev master index given a device index.
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
(cherry picked from commit 1a852479)
Signed-off-by: default avatarJoseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 77afd2e4
...@@ -51,6 +51,24 @@ static inline int l3mdev_master_ifindex(struct net_device *dev) ...@@ -51,6 +51,24 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
return ifindex; 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 /* get index of an interface to use for FIB lookups. For devices
* enslaved to an L3 master device FIB lookups are based on the * enslaved to an L3 master device FIB lookups are based on the
* master index * master index
...@@ -170,6 +188,11 @@ static inline int l3mdev_master_ifindex(struct net_device *dev) ...@@ -170,6 +188,11 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
return 0; 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) static inline int l3mdev_fib_oif_rcu(struct net_device *dev)
{ {
return dev ? dev->ifindex : 0; return dev ? dev->ifindex : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment