From: Yafang Shao <laoar.shao@gmail.com>
To: edumazet@google.com, davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH v2 net-next 2/2] tcp: fix the error count of tcpInSegs
Date: Sun, 9 Sep 2018 11:14:22 +0800 [thread overview]
Message-ID: <1536462862-11767-2-git-send-email-laoar.shao@gmail.com> (raw)
In-Reply-To: <1536462862-11767-1-git-send-email-laoar.shao@gmail.com>
In RFC1213, the tcpInSegs is the total number of segments received.
While currently it is the total number of SKBs received.
The number of SKBs may be not equal with the numer of segments because of
GRO.
So fix this error count.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
include/net/tcp.h | 2 ++
net/ipv4/tcp_ipv4.c | 3 ++-
net/ipv6/tcp_ipv6.c | 3 ++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 770917d..66578f4 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -310,6 +310,8 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift)
#define __TCP_INC_STATS(net, field) __SNMP_INC_STATS((net)->mib.tcp_statistics, field)
#define TCP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->mib.tcp_statistics, field)
#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
+#define __TCP_ADD_STATS(net, field, val) \
+ __SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
void tcp_tasklet_init(void);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 23d7cb5..2b98242 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1703,7 +1703,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
goto discard_it;
/* Count it even if it's bad */
- __TCP_INC_STATS(net, TCP_MIB_INSEGS);
+ __TCP_ADD_STATS(net, TCP_MIB_INSEGS,
+ max_t(u16, 1, skb_shinfo(skb)->gso_segs));
if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
goto discard_it;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index bbf7667..8d4ef46 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1441,7 +1441,8 @@ static int tcp_v6_rcv(struct sk_buff *skb)
/*
* Count it even if it's bad.
*/
- __TCP_INC_STATS(net, TCP_MIB_INSEGS);
+ __TCP_ADD_STATS(net, TCP_MIB_INSEGS,
+ max_t(u16, 1, skb_shinfo(skb)->gso_segs));
if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
goto discard_it;
--
1.8.3.1
next prev parent reply other threads:[~2018-09-09 3:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-09 3:14 [PATCH v2 net-next 1/2] tcp: show number of network segments in some SNMP counters Yafang Shao
2018-09-09 3:14 ` Yafang Shao [this message]
2018-09-09 18:32 ` [PATCH v2 net-next 2/2] tcp: fix the error count of tcpInSegs Eric Dumazet
2018-09-10 10:56 ` Yafang Shao
2018-09-09 18:27 ` [PATCH v2 net-next 1/2] tcp: show number of network segments in some SNMP counters Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1536462862-11767-2-git-send-email-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).