From patchwork Tue Feb 14 06:06:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 13139443 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 88047C6379F for ; Tue, 14 Feb 2023 06:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231502AbjBNGIa (ORCPT ); Tue, 14 Feb 2023 01:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbjBNGIX (ORCPT ); Tue, 14 Feb 2023 01:08:23 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D1AE1C59F for ; Mon, 13 Feb 2023 22:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676354900; x=1707890900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0t1ydhSB782iLDTAH+aHXq+2Ez9iyH6tJamludfqzPU=; b=mfyTKOv3md32DtFtBjEPtqP9TRzKI5xiOqf19OdzEr9bKfgV2kh/VKkC xAFANeR+oSgLzgV7PFj5kPJ53ocOe8kh0Jy12Y1tcd+SnYMRi5qHQPOL4 1oJBM2RxOhClVQtmJg2yd0jA5wEtZM8AhnBk5ZKbvJ+NZc9vxow+xP8Sk A0dMiROStjAVkrZhGvt5WACRUUzCyorDrUKtedFJDLEgwI/1gdC4aeu36 wTaPO3VSYgB/zx/+L/hNSwvv+IUPTheiyAtUwxFLIN4KiCQcfErzcgWSt eoqbcbTxHHNngutVidIlsF34Hl5qz7i2IKySoY480BvrmOBBPX6ulq7rz w==; X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="332400565" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="332400565" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 22:08:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10620"; a="618924809" X-IronPort-AV: E=Sophos;i="5.97,294,1669104000"; d="scan'208";a="618924809" Received: from unknown (HELO intel-71.bj.intel.com) ([10.238.154.71]) by orsmga003.jf.intel.com with ESMTP; 13 Feb 2023 22:08:04 -0800 From: Zhu Yanjun To: jgg@ziepe.ca, leon@kernel.org, zyjzyj2000@gmail.com, linux-rdma@vger.kernel.org, parav@nvidia.com, yanjun.zhu@intel.com Cc: Zhu Yanjun Subject: [PATCHv3 3/8] RDMA/nldev: Add dellink function pointer Date: Tue, 14 Feb 2023 14:06:29 +0800 Message-Id: <20230214060634.427162-4-yanjun.zhu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230214060634.427162-1-yanjun.zhu@intel.com> References: <20230214060634.427162-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. 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);