From patchwork Mon Jul 18 19:23:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shiraz Saleem X-Patchwork-Id: 9235137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D11F600CB for ; Mon, 18 Jul 2016 19:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D79A205A4 for ; Mon, 18 Jul 2016 19:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51BD920649; Mon, 18 Jul 2016 19:26:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2AEF205A4 for ; Mon, 18 Jul 2016 19:26:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752009AbcGRT0A (ORCPT ); Mon, 18 Jul 2016 15:26:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:49800 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751789AbcGRT0A (ORCPT ); Mon, 18 Jul 2016 15:26:00 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 18 Jul 2016 12:25:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,385,1464678000"; d="scan'208";a="1019273634" Received: from ssaleem-mobl4.amr.corp.intel.com ([10.122.33.134]) by orsmga002.jf.intel.com with ESMTP; 18 Jul 2016 12:25:43 -0700 From: Shiraz Saleem To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, swise@opengridcomputing.com, e1000-rdma@lists.sourceforge.net, netdev@vger.kernel.org, Mustafa Ismail , Shiraz Saleem Subject: [PATCH V2] Add flow control to the portmapper Date: Mon, 18 Jul 2016 14:23:30 -0500 Message-Id: <1468869810-64420-1-git-send-email-shiraz.saleem@intel.com> X-Mailer: git-send-email 2.8.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mustafa Ismail During connection establishment with a large number of connections, it is possible that the connection requests might fail. Adding flow control prevents this failure. Change ibnl unicast to use netlink messaging with blocking to enable flow control. Signed-off-by: Faisal Latif Signed-off-by: Mustafa Ismail Signed-off-by: Shiraz Saleem --- V2: update commit message with justification for flow control. CC'ing linux-netdev mailing list. drivers/infiniband/core/netlink.c | 4 ++-- include/net/netlink.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c index 9b8c20c..6b09580 100644 --- a/drivers/infiniband/core/netlink.c +++ b/drivers/infiniband/core/netlink.c @@ -229,7 +229,7 @@ static void ibnl_rcv(struct sk_buff *skb) int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh, __u32 pid) { - return nlmsg_unicast(nls, skb, pid); + return nlmsg_unicast_block(nls, skb, pid); } EXPORT_SYMBOL(ibnl_unicast); @@ -251,7 +251,7 @@ int __init ibnl_init(void) pr_warn("Failed to create netlink socket\n"); return -ENOMEM; } - + nls->sk_sndtimeo = 10 * HZ; return 0; } diff --git a/include/net/netlink.h b/include/net/netlink.h index 254a0fc..5434279 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -598,6 +598,23 @@ static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 portid } /** + * nlmsg_unicast_block - unicast a netlink message with blocking + * @sk: netlink socket to spread message to + * @skb: netlink message as socket buffer + * @portid: netlink portid of the destination socket + */ +static inline int nlmsg_unicast_block(struct sock *sk, struct sk_buff *skb, u32 portid) +{ + int err; + + err = netlink_unicast(sk, skb, portid, 0); + if (err > 0) + err = 0; + + return err; +} + +/** * nlmsg_for_each_msg - iterate over a stream of messages * @pos: loop counter, set to current message * @head: head of message stream