Skip to content

Commit 86e76db

Browse files
Kamalheibgregkh
authored andcommitted
RDMA/ipoib: Set rtnl_link_ops for ipoib interfaces
[ Upstream commit 5ce2dce ] Report the "ipoib pkey", "mode" and "umcast" netlink attributes for every IPoiB interface type, not just children created with 'ip link add'. After setting the rtnl_link_ops for the parent interface, implement the dellink() callback to block users from trying to remove it. Fixes: 862096a ("IB/ipoib: Add more rtnl_link_ops callbacks") Link: https://lore.kernel.org/r/20201004132948.26669-1-kamalheib1@gmail.com Signed-off-by: Kamal Heib <kamalheib1@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 77445d8 commit 86e76db

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/infiniband/ulp/ipoib/ipoib_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,6 +2480,8 @@ static struct net_device *ipoib_add_port(const char *format,
24802480
/* call event handler to ensure pkey in sync */
24812481
queue_work(ipoib_workqueue, &priv->flush_heavy);
24822482

2483+
ndev->rtnl_link_ops = ipoib_get_link_ops();
2484+
24832485
result = register_netdev(ndev);
24842486
if (result) {
24852487
pr_warn("%s: couldn't register ipoib port %d; error %d\n",

drivers/infiniband/ulp/ipoib/ipoib_netlink.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,
144144
return 0;
145145
}
146146

147+
static void ipoib_del_child_link(struct net_device *dev, struct list_head *head)
148+
{
149+
struct ipoib_dev_priv *priv = ipoib_priv(dev);
150+
151+
if (!priv->parent)
152+
return;
153+
154+
unregister_netdevice_queue(dev, head);
155+
}
156+
147157
static size_t ipoib_get_size(const struct net_device *dev)
148158
{
149159
return nla_total_size(2) + /* IFLA_IPOIB_PKEY */
@@ -158,6 +168,7 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = {
158168
.priv_size = sizeof(struct ipoib_dev_priv),
159169
.setup = ipoib_setup_common,
160170
.newlink = ipoib_new_child_link,
171+
.dellink = ipoib_del_child_link,
161172
.changelink = ipoib_changelink,
162173
.get_size = ipoib_get_size,
163174
.fill_info = ipoib_fill_info,

drivers/infiniband/ulp/ipoib/ipoib_vlan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
195195
}
196196
priv = ipoib_priv(ndev);
197197

198+
ndev->rtnl_link_ops = ipoib_get_link_ops();
199+
198200
result = __ipoib_vlan_add(ppriv, priv, pkey, IPOIB_LEGACY_CHILD);
199201

200202
if (result && ndev->reg_state == NETREG_UNINITIALIZED)

0 commit comments

Comments
 (0)