Skip to content

Commit c084080

Browse files
buytenhdavem330
authored andcommitted
dsa: set ->iflink on slave interfaces to the ifindex of the parent
..so that we can parse the DSA topology from 'ip link' output: 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 4: lan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue 5: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue 6: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue 7: lan4@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue Signed-off-by: Lennert Buytenhek <buytenh@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent aec464b commit c084080

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

net/dsa/slave.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
4848

4949

5050
/* slave device handling ****************************************************/
51+
static int dsa_slave_init(struct net_device *dev)
52+
{
53+
struct dsa_slave_priv *p = netdev_priv(dev);
54+
struct net_device *master = p->parent->master_netdev;
55+
56+
dev->iflink = master->ifindex;
57+
58+
return 0;
59+
}
60+
5161
static int dsa_slave_open(struct net_device *dev)
5262
{
5363
struct dsa_slave_priv *p = netdev_priv(dev);
@@ -288,6 +298,7 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = {
288298

289299
#ifdef CONFIG_NET_DSA_TAG_DSA
290300
static const struct net_device_ops dsa_netdev_ops = {
301+
.ndo_init = dsa_slave_init,
291302
.ndo_open = dsa_slave_open,
292303
.ndo_stop = dsa_slave_close,
293304
.ndo_start_xmit = dsa_xmit,
@@ -300,6 +311,7 @@ static const struct net_device_ops dsa_netdev_ops = {
300311
#endif
301312
#ifdef CONFIG_NET_DSA_TAG_EDSA
302313
static const struct net_device_ops edsa_netdev_ops = {
314+
.ndo_init = dsa_slave_init,
303315
.ndo_open = dsa_slave_open,
304316
.ndo_stop = dsa_slave_close,
305317
.ndo_start_xmit = edsa_xmit,
@@ -312,6 +324,7 @@ static const struct net_device_ops edsa_netdev_ops = {
312324
#endif
313325
#ifdef CONFIG_NET_DSA_TAG_TRAILER
314326
static const struct net_device_ops trailer_netdev_ops = {
327+
.ndo_init = dsa_slave_init,
315328
.ndo_open = dsa_slave_open,
316329
.ndo_stop = dsa_slave_close,
317330
.ndo_start_xmit = trailer_xmit,

0 commit comments

Comments
 (0)