From patchwork Sat Jun 24 07:39:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 13291608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02DA3EB64DA for ; Sat, 24 Jun 2023 07:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231892AbjFXHk6 (ORCPT ); Sat, 24 Jun 2023 03:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjFXHkx (ORCPT ); Sat, 24 Jun 2023 03:40:53 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A952E7D for ; Sat, 24 Jun 2023 00:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687592452; x=1719128452; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=obVjwc5lP8xcdcZPzZP28eanBa02yUyPhBRhoMhPd4o=; b=fLecawOP3iZfaTyCX5UW6OkRGecAUA3KbdaSi53jcn6Xx9p5VvxEwWM8 ZUpbwNEFoMWqpdmvKfN3VYRKutaIiprBQ+pmA8g6aqRs9fFnKbvGKsSnr PPbkPrNoesT3iuIE8MdbrHdC6SflBdjIWVXvfU0xI8WmQShSyDPxc0aC5 Wts8TGw3IDBPRWqq8jX7KqbaxmacK6uSOHhZ7o62/RA6OY0aa1PftNcm5 IcKUf8wfC+jzraY4y4bgib4eD6EzfeVSq254LnNIBG4+06ueXSSUmpn24 ebq+V4Pr7JuESunNwA5yZsCclKqHNbkl3b4Xy6TWHzY65FMLAIq44fyBW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10750"; a="340517882" X-IronPort-AV: E=Sophos;i="6.01,154,1684825200"; d="scan'208";a="340517882" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2023 00:40:15 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10750"; a="750240685" X-IronPort-AV: E=Sophos;i="6.01,154,1684825200"; d="scan'208";a="750240685" Received: from unknown (HELO intel-71.bj.intel.com) ([10.238.154.71]) by orsmga001.jf.intel.com with ESMTP; 24 Jun 2023 00:40:13 -0700 From: Zhu Yanjun To: zyjzyj2000@gmail.com, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org, parav@nvidia.com, lehrer@gmail.com, rpearsonhpe@gmail.com Cc: Zhu Yanjun , Rain River Subject: [PATCH v7 3/8] RDMA/nldev: Add dellink function pointer Date: Sat, 24 Jun 2023 15:39:22 +0800 Message-Id: <20230624073927.707915-4-yanjun.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230624073927.707915-1-yanjun.zhu@intel.com> References: <20230624073927.707915-1-yanjun.zhu@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Zhu Yanjun The newlink function pointer is added. And the sock listening on port 4791 is added in the newlink function. So the dellink function is needed to remove the sock. Tested-by: Rain River Signed-off-by: Zhu Yanjun --- drivers/infiniband/core/nldev.c | 6 ++++++ include/rdma/rdma_netlink.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c index d5d3e4f0de77..60baf306043f 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -1758,6 +1758,12 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh, return -EINVAL; } + 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 c2a79aeee113..bf9df004061f 100644 --- a/include/rdma/rdma_netlink.h +++ b/include/rdma/rdma_netlink.h @@ -5,6 +5,7 @@ #include #include +#include enum { RDMA_NLDEV_ATTR_EMPTY_STRING = 1, @@ -114,6 +115,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);