Skip to content

Commit 0bae34f

Browse files
David Ahernpundiramit
authored andcommitted
UPSTREAM: net: l3mdev: Add master device lookup by index
Add helper to lookup l3mdev master index given a device index. [cherry-pick of upstream 1a8524794fc7c70f44ac28e3a6e8fd637bc41f14] Bug: 63589535 Change-Id: I3d0758a5d0eb03791726014c9c1e32e187391e6f Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4322708 commit 0bae34f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

include/net/l3mdev.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
5151
return ifindex;
5252
}
5353

54+
static 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+
5472
/* get index of an interface to use for FIB lookups. For devices
5573
* enslaved to an L3 master device FIB lookups are based on the
5674
* master index
@@ -170,6 +188,11 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
170188
return 0;
171189
}
172190

191+
static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
192+
{
193+
return 0;
194+
}
195+
173196
static inline int l3mdev_fib_oif_rcu(struct net_device *dev)
174197
{
175198
return dev ? dev->ifindex : 0;

0 commit comments

Comments
 (0)