From patchwork Thu Jun 4 12:26:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wan, Kaike" X-Patchwork-Id: 6546271 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 340E9C0020 for ; Thu, 4 Jun 2015 12:27:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 645FC20748 for ; Thu, 4 Jun 2015 12:27:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FF362074B for ; Thu, 4 Jun 2015 12:27:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753273AbbFDM1R (ORCPT ); Thu, 4 Jun 2015 08:27:17 -0400 Received: from mga03.intel.com ([134.134.136.65]:9349 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753393AbbFDM1Q (ORCPT ); Thu, 4 Jun 2015 08:27:16 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 04 Jun 2015 05:27:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,552,1427785200"; d="scan'208";a="705250989" Received: from sedona.ch.intel.com ([143.182.228.65]) by orsmga001.jf.intel.com with ESMTP; 04 Jun 2015 05:27:15 -0700 Received: from phlsvlogin01.ph.intel.com (phlsvlogin01.ph.intel.com [10.228.195.36]) by sedona.ch.intel.com (8.13.6/8.14.3/Standard MailSET/Hub) with ESMTP id t54CREoi025863; Thu, 4 Jun 2015 05:27:14 -0700 Received: from phlsvlogin01.ph.intel.com (localhost [127.0.0.1]) by phlsvlogin01.ph.intel.com with ESMTP id t54CRDvJ013591; Thu, 4 Jun 2015 08:27:13 -0400 Received: (from kaikewan@localhost) by phlsvlogin01.ph.intel.com with id t54CRDLh013587; Thu, 4 Jun 2015 08:27:13 -0400 X-Authentication-Warning: phlsvlogin01.ph.intel.com: kaikewan set sender to kaike.wan@intel.com using -f From: kaike.wan@intel.com To: linux-rdma@vger.kernel.org Cc: Kaike Wan , John Fleck , Ira Weiny Subject: [PATCH v3 2/4] IB/core: Check the presence of netlink multicast group listeners Date: Thu, 4 Jun 2015 08:26:47 -0400 Message-Id: <1433420809-13529-3-git-send-email-kaike.wan@intel.com> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1433420809-13529-1-git-send-email-kaike.wan@intel.com> References: <1433420809-13529-1-git-send-email-kaike.wan@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kaike Wan This patch adds a function to check if listeners for a netlink multicast group are present. Signed-off-by: Kaike Wan Signed-off-by: John Fleck Signed-off-by: Ira Weiny Reviewed-by: Sean Hefty --- drivers/infiniband/core/netlink.c | 8 ++++++++ include/rdma/rdma_netlink.h | 7 +++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c index 23dd5a5..e0fc913 100644 --- a/drivers/infiniband/core/netlink.c +++ b/drivers/infiniband/core/netlink.c @@ -49,6 +49,14 @@ static DEFINE_MUTEX(ibnl_mutex); static struct sock *nls; static LIST_HEAD(client_list); +int ibnl_chk_listeners(unsigned int group) +{ + if (netlink_has_listeners(nls, group) == 0) + return -1; + return 0; +} +EXPORT_SYMBOL(ibnl_chk_listeners); + int ibnl_add_client(int index, int nops, const struct ibnl_client_cbs cb_table[]) { diff --git a/include/rdma/rdma_netlink.h b/include/rdma/rdma_netlink.h index 0790882..5852661 100644 --- a/include/rdma/rdma_netlink.h +++ b/include/rdma/rdma_netlink.h @@ -77,4 +77,11 @@ int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh, int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh, unsigned int group, gfp_t flags); +/** + * Check if there are any listeners to the netlink group + * @group: the netlink group ID + * Returns 0 on success or a negative for no listeners. + */ +int ibnl_chk_listeners(unsigned int group); + #endif /* _RDMA_NETLINK_H */