RDMA/nldev: Add dellink function pointer

Add a dellink function pointer to rdma_link_ops to
allow drivers to clean up resources created during
newlink.

Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Link: https://patch.msgid.link/20260313023058.13020-2-yanjun.zhu@linux.dev
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Zhu Yanjun 2026-03-12 19:30:55 -07:00 committed by Leon Romanovsky
parent 5aa437c93d
commit a60e3f3d6f
2 changed files with 14 additions and 0 deletions

View File

@ -1839,6 +1839,18 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,
return -EINVAL;
}
/*
* This path is triggered by the 'rdma link delete' administrative command.
* For Soft-RoCE (RXE), we ensure that transport sockets are closed here.
* Note: iWARP driver does not implement .dellink, so this logic is
* implicitly scoped to the driver supporting dynamic link deletion like RXE.
*/
if (device->link_ops && device->link_ops->dellink) {
err = device->link_ops->dellink(device);
if (err)
return err;
}
ib_unregister_device_and_put(device);
return 0;
}

View File

@ -5,6 +5,7 @@
#include <linux/netlink.h>
#include <uapi/rdma/rdma_netlink.h>
#include <rdma/ib_verbs.h>
struct ib_device;
@ -126,6 +127,7 @@ struct rdma_link_ops {
struct list_head list;
const char *type;
int (*newlink)(const char *ibdev_name, struct net_device *ndev);
int (*dellink)(struct ib_device *dev);
};
void rdma_link_register(struct rdma_link_ops *ops);