Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp881177imm; Sat, 8 Sep 2018 10:45:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaEhwY9E5J/TrWIKMpXMjkAxgIo9lLvOzO2uifKORdG+SkjAM2kat0vVBfVd2bLIbXnuDK7 X-Received: by 2002:a65:6102:: with SMTP id z2-v6mr14501195pgu.46.1536428749491; Sat, 08 Sep 2018 10:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536428749; cv=none; d=google.com; s=arc-20160816; b=SPvAWDEPJc0Afp3ouU38ad/LJ8QlowEy8Mw7/pqBkwE1Ie1AHWp5LcITB0/Z/eo51n iHnxt/BGVqLHA3eoMyAoDif5PW1wz3Z6zzw58Vh7M+qtz6xQpLMwPdrUHAb8fDNbVM3G 8jwshJNNRrpAMIqZX79RGcBwqzH6LiBh1YE2E+dSCo6B+fADDZ3SlUqPzMKLzSp3Ym8h oI8MMPw3O/7XXCT1djVPpJKZJT+oP5h5YIZAbFsqW90XCdDWjwx20o4I9d0KBKOXTBzf sbr00MD+D/n+eZDmT2ob2deE4D1mzxQ0b1HYzXndjqsbh5FF0v6R+4HSuMdmY06ABU3T ig8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=A+2gXfU2scg1uYgLrqDaR72TXvKgyRgebXD7Vt0DpEo=; b=fcVFL21RK9uwsTk5Bw+IEWVcbLJ+cXRyBrwzLzDgmhpH8eFWVUj/VuYTPNFGe93+Ta 39LN7APesFMuaHEfwOTQmdW7JIJQn3VGWKodbqG/VOrt2SA9JxZ0CVy2DPKjDKJndksU PiWiyDZL1Wl9sXBDPWgeDdgAlraTv7kYW+F2+KNKdiZTX0y0tD+ebgBRCkDUKif7ticD zGivSJuW8XJAVCBpMw03/1+4JNsxgdSJwudBozv/x2NlXZBuBrJGzri1COzqoznRmwEH 9A4dcdSW72ml1KBt3kC61xCgi/d1F4GKOdKbW0OSIw5ZTmoQlzX+3Efwd+GvGrdmLyAE 5XhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JsFG8G5R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s25-v6si11706882pgd.539.2018.09.08.10.45.18; Sat, 08 Sep 2018 10:45:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JsFG8G5R; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727639AbeIHW3y (ORCPT + 99 others); Sat, 8 Sep 2018 18:29:54 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:40410 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbeIHW3y (ORCPT ); Sat, 8 Sep 2018 18:29:54 -0400 Received: by mail-io1-f67.google.com with SMTP id l14-v6so3914068iob.7; Sat, 08 Sep 2018 10:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=A+2gXfU2scg1uYgLrqDaR72TXvKgyRgebXD7Vt0DpEo=; b=JsFG8G5R39C8jBRmiO8lOWDBYdFtwunjDHtRB032HTSAu1XLuMnEBK4MNJWHbnKZNu 28r89FeNdulLnrTRngZjhA5p2zlI8282p7BxWcFOqBpsBYoKSnLFt9QgHOLeX4DE5HAh 8uRbilWVvrCxcubS4NOnSpm/K6WJugyATpPULV9wAuGd9kxs/Go4ryzBVLjXFk3mL2gP HylpUanychOzYeLPewSYDT+asxtHi775N2KSP2YGPjbOYOY0F1qBqDJVdSngozqXR5cd E7JkCe1BviTyloGLl+1mAcBunz1N/ckkM64AF5eaUIqN4WDIXtKkDNHXf+c8RvzgGWGb FGMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=A+2gXfU2scg1uYgLrqDaR72TXvKgyRgebXD7Vt0DpEo=; b=f/q9rPQq9DitYeiIyh1ovOBSZBGgnx29foCB9lomWuffLcUaguiKazH36j8CMOWhIN 6Uf1LvBksOOe4VykjSbBlS3rUCnE2315ap4jmJxQwJmatvJTVv1tgO8a3o7uD6jsWol2 CqUDoMBZG9ErT7CSWcv14bmXbgt2J53FSiKxgA7PDWKbcpWo/25hj88TVqs1n6GUvTSA DYJTzE68u72J/TLoDnchIQ7+jTch+ztM1R/EsBbb08KsBPFKKsUXv+cSNZI7gv66s7xx wa/lPe2FaTpFL6g/m7Lx7LJvIufPwdnfhwBMpDhA6qjRdWPT6j+PrSU2WZ2qYvLDoyNB g1gg== X-Gm-Message-State: APzg51AoIn0XhzTB9q7Uw651KzZZc22Wg9Wm7Tbk6NSZhTrvgC2y4pQu HEnaiQdxexWQ6eti/t8YbQWjxCy+WvFt9wwfBms= X-Received: by 2002:a6b:c694:: with SMTP id w142-v6mr10150895iof.142.1536428600818; Sat, 08 Sep 2018 10:43:20 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:7315:0:0:0:0:0 with HTTP; Sat, 8 Sep 2018 10:42:40 -0700 (PDT) In-Reply-To: <1536425898-12059-1-git-send-email-laoar.shao@gmail.com> References: <1536425898-12059-1-git-send-email-laoar.shao@gmail.com> From: Yafang Shao Date: Sun, 9 Sep 2018 01:42:40 +0800 Message-ID: Subject: Re: [PATCH net-next] tcp: show number of network segments in some SNMP counters To: Eric Dumazet , David Miller Cc: netdev , LKML , Yafang Shao Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 9, 2018 at 12:58 AM, Yafang Shao wrote: > It is better to show the number of network segments in bellow SNMP > counters, because that could be more useful for the user. > For example, the user could easily figure out how mant packets are > dropped and how many packets are queued in the out-of-oder queue. > > - LINUX_MIB_TCPRCVQDROP > - LINUX_MIB_TCPZEROWINDOWDROP > - LINUX_MIB_TCPBACKLOGDROP > - LINUX_MIB_TCPMINTTLDROP > - LINUX_MIB_TCPOFODROP > - LINUX_MIB_TCPOFOQUEUE > > Signed-off-by: Yafang Shao > --- > net/ipv4/tcp_input.c | 18 ++++++++++++------ > net/ipv4/tcp_ipv4.c | 9 ++++++--- > net/ipv6/tcp_ipv6.c | 6 ++++-- > 3 files changed, 22 insertions(+), 11 deletions(-) > > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index 62508a2..90f449b 100644 > --- a/net/ipv4/tcp_input.c > +++ b/net/ipv4/tcp_input.c > @@ -4496,7 +4496,8 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) > tcp_ecn_check_ce(sk, skb); > > if (unlikely(tcp_try_rmem_schedule(sk, skb, skb->truesize))) { > - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP); > + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPOFODROP, > + tcp_skb_pcount(skb)); > tcp_drop(sk, skb); > return; > } > @@ -4505,7 +4506,8 @@ static void tcp_data_queue_ofo(struct sock *sk, struct sk_buff *skb) > tp->pred_flags = 0; > inet_csk_schedule_ack(sk); > > - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPOFOQUEUE); > + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPOFOQUEUE, > + tcp_skb_pcount(skb)); > seq = TCP_SKB_CB(skb)->seq; > end_seq = TCP_SKB_CB(skb)->end_seq; > SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n", > @@ -4666,7 +4668,8 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size) > skb->len = size; > > if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { > - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); > + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP, > + tcp_skb_pcount(skb)); > goto err_free; > } > > @@ -4725,7 +4728,8 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) > */ > if (TCP_SKB_CB(skb)->seq == tp->rcv_nxt) { > if (tcp_receive_window(tp) == 0) { > - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPZEROWINDOWDROP); > + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPZEROWINDOWDROP, > + tcp_skb_pcount(skb)); > goto out_of_window; > } > > @@ -4734,7 +4738,8 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) > if (skb_queue_len(&sk->sk_receive_queue) == 0) > sk_forced_mem_schedule(sk, skb->truesize); > else if (tcp_try_rmem_schedule(sk, skb, skb->truesize)) { > - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP); > + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPRCVQDROP, > + tcp_skb_pcount(skb)); > goto drop; > } > > @@ -4796,7 +4801,8 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) > * remembering D-SACK for its head made in previous line. > */ > if (!tcp_receive_window(tp)) { > - NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPZEROWINDOWDROP); > + NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPZEROWINDOWDROP, > + tcp_skb_pcount(skb)); > goto out_of_window; > } > goto queue_and_out; > diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c > index 09547ef..f2fe14b 100644 > --- a/net/ipv4/tcp_ipv4.c > +++ b/net/ipv4/tcp_ipv4.c > @@ -475,7 +475,8 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info) > goto out; > > if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) { > - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); > + __NET_ADD_STATS(net, LINUX_MIB_TCPMINTTLDROP, > + tcp_skb_pcount(skb)); > goto out; > } > > @@ -1633,7 +1634,8 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) > > if (unlikely(sk_add_backlog(sk, skb, limit))) { > bh_unlock_sock(sk); > - __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP); > + __NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP, > + tcp_skb_pcount(skb)); > return true; > } > return false; > @@ -1790,7 +1792,8 @@ int tcp_v4_rcv(struct sk_buff *skb) > } > } > if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) { > - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); > + __NET_ADD_STATS(net, LINUX_MIB_TCPMINTTLDROP, > + tcp_skb_pcount(skb)); > goto discard_and_relse; > } > > diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c > index 03e6b7a..97dfc16 100644 > --- a/net/ipv6/tcp_ipv6.c > +++ b/net/ipv6/tcp_ipv6.c > @@ -391,7 +391,8 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, > goto out; > > if (ipv6_hdr(skb)->hop_limit < inet6_sk(sk)->min_hopcount) { > - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); > + __NET_ADD_STATS(net, LINUX_MIB_TCPMINTTLDROP, > + tcp_skb_pcount(skb)); > goto out; > } > > @@ -1523,7 +1524,8 @@ static int tcp_v6_rcv(struct sk_buff *skb) > } > } > if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) { > - __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP); > + __NET_ADD_STATS(net, LINUX_MIB_TCPMINTTLDROP, > + tcp_skb_pcount(skb)); > goto discard_and_relse; > } > > -- > 1.8.3.1 > Seems it is not proper to use tcp_skb_pcount(skb). Will send V2. Sorry about the noise. Thanks Yafang