From patchwork Mon May 8 07:56:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 13234201 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 09C2AC77B73 for ; Mon, 8 May 2023 07:58:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232624AbjEHH6A (ORCPT ); Mon, 8 May 2023 03:58:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbjEHH5z (ORCPT ); Mon, 8 May 2023 03:57:55 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A090A9EFE for ; Mon, 8 May 2023 00:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683532674; x=1715068674; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=riLZi2effh8u4Uro4E8PQpRTP+7UfnPIysrb7hhnVKA=; b=FtRk/3I7BDFFywEV0jW1JcPYd1B84b2J3BSRxA2Fajj6dROgzlYjJEZZ L6YYOdvzBZZcJPk3U0x91tw4IBc5ukpa7HUE5t5v5Yy5SxzgjIfTT7Z+l 0Vu8eerG4RgjdqpeuNyMV6MXfEvpKkq5GlkkUq/dRN8cGgnfSj/6LAmnt QWBtD7xUB3oA88qNv5GNmfDDLxA/O72n9GkmQ3D0UnyoveC8b7M1kN9hR I2/3OZ1gKJpP93E/2V9d8VPgfBXictfrRO1gQMiZHze/aFK2gso2XYtRI 03+ReMd68wivhwdGOadB4vm+kXqBR8ac6wPxQRtOb9/9EC8eb99IHdzez Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="415143094" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="415143094" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 00:57:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="763297473" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="763297473" Received: from unknown (HELO intel-71.bj.intel.com) ([10.238.154.71]) by fmsmga008.fm.intel.com with ESMTP; 08 May 2023 00:57:52 -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 Cc: Zhu Yanjun , Rain River Subject: [PATCH v6.4-rc1 v5 3/8] RDMA/nldev: Add dellink function pointer Date: Mon, 8 May 2023 15:56:31 +0800 Message-Id: <20230508075636.352138-4-yanjun.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230508075636.352138-1-yanjun.zhu@intel.com> References: <20230508075636.352138-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..97a62685ed5b 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) { + 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);