Commit a6df1ae9383697c4eb1365176002f154982325ad

Authored by Eric Dumazet
Committed by David S. Miller
1 parent 141e369de6

tcp: add OFO snmp counters

Add three SNMP TCP counters, to better track TCP behavior
at global stage (netstat -s), when packets are received
Out Of Order (OFO)

TCPOFOQueue : Number of packets queued in OFO queue

TCPOFODrop  : Number of packets meant to be queued in OFO
              but dropped because socket rcvbuf limit hit.

TCPOFOMerge : Number of packets in OFO that were merged with
              other packets.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 3 changed files with 12 additions and 3 deletions Side-by-side Diff

include/linux/snmp.h
... ... @@ -233,7 +233,10 @@
233 233 LINUX_MIB_TCPREQQFULLDOCOOKIES, /* TCPReqQFullDoCookies */
234 234 LINUX_MIB_TCPREQQFULLDROP, /* TCPReqQFullDrop */
235 235 LINUX_MIB_TCPRETRANSFAIL, /* TCPRetransFail */
236   - LINUX_MIB_TCPRCVCOALESCE, /* TCPRcvCoalesce */
  236 + LINUX_MIB_TCPRCVCOALESCE, /* TCPRcvCoalesce */
  237 + LINUX_MIB_TCPOFOQUEUE, /* TCPOFOQueue */
  238 + LINUX_MIB_TCPOFODROP, /* TCPOFODrop */
  239 + LINUX_MIB_TCPOFOMERGE, /* TCPOFOMerge */
237 240 __LINUX_MIB_MAX
238 241 };
239 242  
... ... @@ -258,6 +258,9 @@
258 258 SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP),
259 259 SNMP_MIB_ITEM("TCPRetransFail", LINUX_MIB_TCPRETRANSFAIL),
260 260 SNMP_MIB_ITEM("TCPRcvCoalesce", LINUX_MIB_TCPRCVCOALESCE),
  261 + SNMP_MIB_ITEM("TCPOFOQueue", LINUX_MIB_TCPOFOQUEUE),
  262 + SNMP_MIB_ITEM("TCPOFODrop", LINUX_MIB_TCPOFODROP),
  263 + SNMP_MIB_ITEM("TCPOFOMerge", LINUX_MIB_TCPOFOMERGE),
261 264 SNMP_MIB_SENTINEL
262 265 };
263 266  
net/ipv4/tcp_input.c
... ... @@ -4397,8 +4397,8 @@
4397 4397  
4398 4398 TCP_ECN_check_ce(tp, skb);
4399 4399  
4400   - if (tcp_try_rmem_schedule(sk, skb->truesize)) {
4401   - /* TODO: should increment a counter */
  4400 + if (unlikely(tcp_try_rmem_schedule(sk, skb->truesize))) {
  4401 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFODROP);
4402 4402 __kfree_skb(skb);
4403 4403 return;
4404 4404 }
... ... @@ -4407,6 +4407,7 @@
4407 4407 tp->pred_flags = 0;
4408 4408 inet_csk_schedule_ack(sk);
4409 4409  
  4410 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFOQUEUE);
4410 4411 SOCK_DEBUG(sk, "out of order segment: rcv_next %X seq %X - %X\n",
4411 4412 tp->rcv_nxt, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq);
4412 4413  
... ... @@ -4460,6 +4461,7 @@
4460 4461 if (skb1 && before(seq, TCP_SKB_CB(skb1)->end_seq)) {
4461 4462 if (!after(end_seq, TCP_SKB_CB(skb1)->end_seq)) {
4462 4463 /* All the bits are present. Drop. */
  4464 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFOMERGE);
4463 4465 __kfree_skb(skb);
4464 4466 skb = NULL;
4465 4467 tcp_dsack_set(sk, seq, end_seq);
... ... @@ -4498,6 +4500,7 @@
4498 4500 __skb_unlink(skb1, &tp->out_of_order_queue);
4499 4501 tcp_dsack_extend(sk, TCP_SKB_CB(skb1)->seq,
4500 4502 TCP_SKB_CB(skb1)->end_seq);
  4503 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPOFOMERGE);
4501 4504 __kfree_skb(skb1);
4502 4505 }
4503 4506