From patchwork Wed Mar 21 13:37:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: GhantaKrishnamurthy MohanKrishna X-Patchwork-Id: 888867 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="NU6d9c2Z"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 405rqG3w9Bz9s19 for ; Thu, 22 Mar 2018 00:53:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752355AbeCUNxM (ORCPT ); Wed, 21 Mar 2018 09:53:12 -0400 Received: from sesbmg23.ericsson.net ([193.180.251.37]:64621 "EHLO sesbmg23.ericsson.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752338AbeCUNxJ (ORCPT ); Wed, 21 Mar 2018 09:53:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1521639472; h=From:Sender:Reply-To:Subject:Date:Message-ID:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Sj5QPANCnpMpAj8tYze+Yympbp+1Jc1x3RAWlQOard0=; b=NU6d9c2ZaWaUB+jTosWyJ9maNr1gQrHhINrxUmhm7/DX+/Xv+OwzHN1FNBj2Whnm OHpZ4th1mBAGW4rFpVKpWI1fnuuNHcgHvhNAmrocvLc87kD3VnuMgpZA/80KYQC5 kO2FjqqTo0+hXdYOYBjjTN1MJCUGibyycHgPRp2q+Ls=; X-AuditID: c1b4fb25-681ff70000006222-37-5ab26030d6e1 Received: from ESESSHC011.ericsson.se (Unknown_Domain [153.88.183.51]) by sesbmg23.ericsson.net (Symantec Mail Security) with SMTP id DF.3C.25122.03062BA5; Wed, 21 Mar 2018 14:37:52 +0100 (CET) Received: from daly.lab.linux.ericsson.se (10.35.28.123) by ESESSHC011.ericsson.se (153.88.183.51) with Microsoft SMTP Server (TLS) id 14.3.382.0; Wed, 21 Mar 2018 14:37:51 +0100 From: GhantaKrishnamurthy MohanKrishna To: , , , , , , CC: Parthasarathy Bhuvaragan Subject: [net-next 3/3] tipc: step sk->sk_drops when rcv buffer is full Date: Wed, 21 Mar 2018 14:37:45 +0100 Message-ID: <1521639465-3169-4-git-send-email-mohan.krishna.ghanta.krishnamurthy@ericsson.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1521639465-3169-1-git-send-email-mohan.krishna.ghanta.krishnamurthy@ericsson.com> References: <1521639465-3169-1-git-send-email-mohan.krishna.ghanta.krishnamurthy@ericsson.com> MIME-Version: 1.0 X-Originating-IP: [10.35.28.123] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsUyM2K7sa5BwqYogw23JC3mnG9hsVi06DCT xbEFYhbr70xjtNhyPsvi8fXrzA5sHltW3mTyeN9zhclj56y77B67F3xm8vi8Sc5j/ZatTAFs UVw2Kak5mWWpRfp2CVwZCx/MYSmYLFrx9eUq1gbGc4JdjJwcEgImEi1ztzKB2EIChxkl7rxm gbC3MUosa5ECsdkEoiR2HNjI3sXIxSEicI9RouPCXEaQBLOAo8Ts++fAmoUFPCQ+bj7NBmKz CKhKLHh+kh3E5hWIkzjx7y4LxDI5ifPHfzKD2JwC8RJ9l7sZIZbFSXQ37WSGqBeUODnzCQvE fAmJgy9eAMU5gGpsJO6td4EYoyDxYdYytgmMArOQdMxC0rGAkWkVo2hxanFSbrqRsV5qUWZy cXF+nl5easkmRmAYH9zyW3UH4+U3jocYBTgYlXh4Qz03RQmxJpYVV+YeYpTgYFYS4d32eWOU EG9KYmVValF+fFFpTmrxIUZpDhYlcd45wu1RQgLpiSWp2ampBalFMFkmDk6pBkaZBUlqztMk //2zaVMz7DLwFj9g52yv8Jmd8eykCFO1fuayR09eFLX6Jr8uu1dv5hR4+2102feEY5Nv3r06 U3R+xZ2gb/M2CP7Znsv/bPfx7sna397wF/pw8r8TNmCZ1Pdonfnr1Vrbhe+pq07mi/31d8L0 Ux8fifw8maqUUr05fe5LjmSHp7OVWIozEg21mIuKEwHNQ6svXwIAAA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently when tipc is unable to queue a received message on a socket, the message is rejected back to the sender with error TIPC_ERR_OVERLOAD. However, the application on this socket has no knowledge about these discards. In this commit, we try to step the sk_drops counter when tipc is unable to queue a received message. Export sk_drops using tipc socket diagnostics. Acked-by: Jon Maloy Acked-by: Ying Xue Signed-off-by: GhantaKrishnamurthy MohanKrishna Signed-off-by: Parthasarathy Bhuvaragan --- include/uapi/linux/tipc_netlink.h | 1 + net/tipc/socket.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h index d7cec0480d70..d896ded51bcb 100644 --- a/include/uapi/linux/tipc_netlink.h +++ b/include/uapi/linux/tipc_netlink.h @@ -251,6 +251,7 @@ enum { TIPC_NLA_SOCK_STAT_SENDQ, /* u32 */ TIPC_NLA_SOCK_STAT_LINK_CONG, /* flag */ TIPC_NLA_SOCK_STAT_CONN_CONG, /* flag */ + TIPC_NLA_SOCK_STAT_DROP, /* u32 */ __TIPC_NLA_SOCK_STAT_MAX, TIPC_NLA_SOCK_STAT_MAX = __TIPC_NLA_SOCK_STAT_MAX - 1 diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 31fdd13d444e..a084c78408fb 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -2122,8 +2122,10 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb, (!sk_conn && msg_connected(hdr)) || (!grp && msg_in_group(hdr))) err = TIPC_ERR_NO_PORT; - else if (sk_rmem_alloc_get(sk) + skb->truesize >= limit) + else if (sk_rmem_alloc_get(sk) + skb->truesize >= limit) { + atomic_inc(&sk->sk_drops); err = TIPC_ERR_OVERLOAD; + } if (unlikely(err)) { tipc_skb_reject(net, err, skb, xmitq); @@ -2202,6 +2204,7 @@ static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk, /* Overload => reject message back to sender */ onode = tipc_own_addr(sock_net(sk)); + atomic_inc(&sk->sk_drops); if (tipc_msg_reverse(onode, &skb, TIPC_ERR_OVERLOAD)) __skb_queue_tail(xmitq, skb); break; @@ -3287,7 +3290,9 @@ int tipc_sk_fill_sock_diag(struct sk_buff *skb, struct tipc_sock *tsk, if (nla_put_u32(skb, TIPC_NLA_SOCK_STAT_RCVQ, skb_queue_len(&sk->sk_receive_queue)) || nla_put_u32(skb, TIPC_NLA_SOCK_STAT_SENDQ, - skb_queue_len(&sk->sk_write_queue))) + skb_queue_len(&sk->sk_write_queue)) || + nla_put_u32(skb, TIPC_NLA_SOCK_STAT_DROP, + atomic_read(&sk->sk_drops))) goto stat_msg_cancel; if (tsk->cong_link_cnt &&