diff options
author | Erez Shitrit <erezsh@mellanox.com> | 2015-04-16 09:34:34 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-17 15:21:04 -0400 |
commit | 2c1539597419df6dfeb8ed774d60198b5830b8f7 (patch) | |
tree | b1fbfaae7d2c5d16a30f1aad582618efa7492218 | |
parent | 1d20a16062e771b6e26b843c0cde3b17c1146e00 (diff) |
IB/ipoib: Fix ndo_get_iflink
Currently, iflink of the parent interface was always accessed, even
when interface didn't have a parent and hence we crashed there.
Handle the interface types properly: for a child interface, return
the ifindex of the parent, for parent interface, return its ifindex.
For child devices, make sure to set the parent pointer prior to
invoking register_netdevice(), this allows the new ndo to be called
by the stack immediately after the child device is registered.
Fixes: 5aa7add8f14b ('infiniband/ipoib: implement ndo_get_iflink')
Reported-by: Honggang Li <honli@redhat.com>
Signed-off-by: Erez Shitrit <erezsh@mellanox.com>
Signed-off-by: Honggang Li <honli@redhat.com>
Reviewed-By: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>+
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 5 | ||||
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_vlan.c | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 657b89b1d291..915ad04a827e 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -846,6 +846,11 @@ static int ipoib_get_iflink(const struct net_device *dev) | |||
846 | { | 846 | { |
847 | struct ipoib_dev_priv *priv = netdev_priv(dev); | 847 | struct ipoib_dev_priv *priv = netdev_priv(dev); |
848 | 848 | ||
849 | /* parent interface */ | ||
850 | if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) | ||
851 | return dev->ifindex; | ||
852 | |||
853 | /* child/vlan interface */ | ||
849 | return priv->parent->ifindex; | 854 | return priv->parent->ifindex; |
850 | } | 855 | } |
851 | 856 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c index 4dd1313056a4..fca1a882de27 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c | |||
@@ -58,6 +58,7 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, | |||
58 | /* MTU will be reset when mcast join happens */ | 58 | /* MTU will be reset when mcast join happens */ |
59 | priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu); | 59 | priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu); |
60 | priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; | 60 | priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; |
61 | priv->parent = ppriv->dev; | ||
61 | set_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags); | 62 | set_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags); |
62 | 63 | ||
63 | result = ipoib_set_dev_features(priv, ppriv->ca); | 64 | result = ipoib_set_dev_features(priv, ppriv->ca); |
@@ -84,8 +85,6 @@ int __ipoib_vlan_add(struct ipoib_dev_priv *ppriv, struct ipoib_dev_priv *priv, | |||
84 | goto register_failed; | 85 | goto register_failed; |
85 | } | 86 | } |
86 | 87 | ||
87 | priv->parent = ppriv->dev; | ||
88 | |||
89 | ipoib_create_debug_files(priv->dev); | 88 | ipoib_create_debug_files(priv->dev); |
90 | 89 | ||
91 | /* RTNL childs don't need proprietary sysfs entries */ | 90 | /* RTNL childs don't need proprietary sysfs entries */ |