Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Erez Shitrit and committed by
David S. Miller
2c153959 1d20a160

+6 -2
+5
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 846 846 { 847 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 854 return priv->parent->ifindex; 850 855 } 851 856
+1 -2
drivers/infiniband/ulp/ipoib/ipoib_vlan.c
··· 58 58 /* MTU will be reset when mcast join happens */ 59 59 priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu); 60 60 priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu; 61 + priv->parent = ppriv->dev; 61 62 set_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags); 62 63 63 64 result = ipoib_set_dev_features(priv, ppriv->ca); ··· 84 83 ipoib_warn(priv, "failed to initialize; error %i", result); 85 84 goto register_failed; 86 85 } 87 - 88 - priv->parent = ppriv->dev; 89 86 90 87 ipoib_create_debug_files(priv->dev); 91 88