public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: "Yanjun.Zhu" <yanjun.zhu@linux.dev>
To: David Ahern <dsahern@kernel.org>,
	Leon Romanovsky <leon@kernel.org>,
	Zhu Yanjun <yanjun.zhu@linux.dev>
Cc: jgg@ziepe.ca, zyjzyj2000@gmail.com, shuah@kernel.org,
	linux-rdma@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v5 1/4] RDMA/nldev: Add dellink function pointer
Date: Thu, 12 Mar 2026 11:04:41 -0700	[thread overview]
Message-ID: <7f157000-d1a9-4284-afef-12107d6ce40e@linux.dev> (raw)
In-Reply-To: <434a9a8c-f369-435a-b8bf-d9ae85558c8e@linux.dev>


On 3/11/26 10:09 PM, Zhu Yanjun wrote:
>
> 在 2026/3/11 20:59, Zhu Yanjun 写道:
>>
>> 在 2026/3/11 19:04, David Ahern 写道:
>>> On 3/11/26 4:01 PM, Yanjun.Zhu wrote:
>>>
>>>> Got it. The commit log explains how the netdev_notifier mechanism is
>>> netdev notifiers are the NETDEV_UNREGISTER and friends. This dellink
>>> handler is not related to that; this is an IB stack thing when the rxe
>>> link is removed.
>>>
>>>> used to clean up the related resources.
>>>>
>>>> In the source code, additional comments have been added to explain how
>>>> the dellink operation for rxe is triggered. For iWARP, this change
>>>> should not make any difference because iWARP does not implement the
>>>> dellink function.
>>>>
>>>> The commit is shown below. Please take a look and share your comments.
>>>> If you agree, I will send out the latest commits out very soon.
>>>>
>>>>  From c05038dcdf69c5985837736a8926ba76d9f3e8e4 Mon Sep 17 00:00:00 
>>>> 2001
>>>> From: Zhu Yanjun <yanjun.zhu@linux.dev>
>>>> Date: Fri, 23 Sep 2022 16:52:45 +0000
>>>> Subject: [PATCH 1/1] RDMA/nldev: Add dellink function pointer
>>>>
>>>> The newlink function pointer was previously added to support
>>>> dynamic RDMA link creation. In the RXE driver, this path creates
>>>> a transport socket listening on port 4791. Consequently, a dellink
>>>> function pointer is required to ensure these sockets are properly
>>>> closed when a user administratively removes a link via rdma link
>>>> delete <dev>.
>>>>
>>>> Furthermore, RXE does not rely solely on this nldev path for resource
>>>> management. It also monitors the underlying net_device state via a
>>>> registered netdev_notifier. The rxe_net_event callback serves as a
>>>> fallback mechanism to ensure that transport sockets are forcibly 
>>>> closed
>>>> and all resources are released even if dellink is not explicitly 
>>>> called
>>>> (e.g., if the parent NIC interface is removed or the driver is 
>>>> forcefully
>>>> unloaded).
>>> IMHO, this explanation belongs in the patch that implements dellink 
>>> for rxe.
>>>
>>> This patch adds the handler to allow link implementations to cleanup 
>>> any
>>> resources created by newklink as needed.
>> Thanks for the feedback. I agree that the detailed explanation of 
>> RXE's resource management (like sockets and notifiers) is more 
>> appropriate for the subsequent patch that implements the RXE dellink 
>> handler.
>>
>> I will update the commit message for this patch to focus solely on 
>> the addition of the dellink infrastructure in the RDMA core, and move 
>> the RXE-specific details to the next patch in the series.
>
> Hi,
>
> I would like to use the following as the commit log. It seems simple 
> and direct.
>
> "
>
> Add a dellink function pointer to rdma_link_ops to allow drivers to 
> clean up resources created during newlink.
> "

Hi,

The final commit is as below. I will send the latest commit out very soon.

 From 8fda79a3b0c3f6df6ba0fc70040ce09e4028a2a3 Mon Sep 17 00:00:00 2001

From: Zhu Yanjun <yanjun.zhu@linux.dev>
Date: Fri, 23 Sep 2022 16:52:45 +0000
Subject: [PATCH 1/1] 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>
---
  drivers/infiniband/core/nldev.c | 12 ++++++++++++
  include/rdma/rdma_netlink.h     |  2 ++
  2 files changed, 14 insertions(+)

diff --git a/drivers/infiniband/core/nldev.c 
b/drivers/infiniband/core/nldev.c
index 2220a2dfab24..dbf2eea078e9 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -1824,6 +1824,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;
  }
diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h
index 326deaf56d5d..2fd1358ea57d 100644
--- a/include/rdma/rdma_netlink.h
+++ b/include/rdma/rdma_netlink.h
@@ -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);
-- 
2.53.0


Zhu Yanjun


>
> Thanks,
>
> Zhu Yanjun
>
>
>>
>> Zhu Yanjun
>>
>>>

  reply	other threads:[~2026-03-12 18:04 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10  2:05 [PATCH v5 0/4] RDMA/rxe: Add the support that rxe can work in net namespace Zhu Yanjun
2026-03-10  2:05 ` [PATCH v5 1/4] RDMA/nldev: Add dellink function pointer Zhu Yanjun
2026-03-10 15:47   ` David Ahern
2026-03-10 19:01   ` Leon Romanovsky
2026-03-11  1:58     ` Yanjun.Zhu
2026-03-11  8:54       ` Leon Romanovsky
2026-03-11 22:01         ` Yanjun.Zhu
2026-03-11 22:09           ` Yanjun.Zhu
2026-03-12  2:04           ` David Ahern
2026-03-12  3:59             ` Zhu Yanjun
2026-03-12  5:09               ` Zhu Yanjun
2026-03-12 18:04                 ` Yanjun.Zhu [this message]
2026-03-10  2:05 ` [PATCH v5 2/4] RDMA/rxe: Add net namespace support for IPv4/IPv6 sockets Zhu Yanjun
2026-03-10 15:48   ` David Ahern
2026-03-10  2:05 ` [PATCH v5 3/4] RDMA/rxe: Support RDMA link creation and destruction per net namespace Zhu Yanjun
2026-03-10 15:48   ` David Ahern
2026-03-10 18:57   ` Leon Romanovsky
2026-03-10 20:32     ` Yanjun.Zhu
2026-03-11  8:45       ` Leon Romanovsky
2026-03-11 19:08         ` Yanjun.Zhu
2026-03-10  2:05 ` [PATCH v5 4/4] RDMA/rxe: Add testcase for net namespace rxe Zhu Yanjun
2026-03-10 15:49   ` David Ahern
2026-03-10 18:53   ` Leon Romanovsky
2026-03-10 21:01     ` Yanjun.Zhu
2026-03-11  8:51       ` Leon Romanovsky
2026-03-11 22:51         ` Yanjun.Zhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f157000-d1a9-4284-afef-12107d6ce40e@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=dsahern@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=zyjzyj2000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox