Commit a60e3f3d authored by Zhu Yanjun's avatar Zhu Yanjun Committed by Leon Romanovsky
Browse files

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: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarZhu Yanjun <yanjun.zhu@linux.dev>
Link: https://patch.msgid.link/20260313023058.13020-2-yanjun.zhu@linux.dev


Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 5aa437c9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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);