netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [ PATCH 2.6.17-rc6 1/1]  udp.c:  counting InDatagrams which are never delivered
@ 2006-06-06 18:25 Gerrit Renker
  2006-06-12  4:29 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Gerrit Renker @ 2006-06-06 18:25 UTC (permalink / raw)
  To: netdev; +Cc: kaber, jmorris

This problem involves MIB counter inaccuracies triggered by 
failed UDP checksums.

Problem: ip_local_deliver_finish calls udp_rcv, which calls
         udp_queue_rcv_skb. 
         Unless the sk_filter is set, the checksum of the incoming
         UDP datagram is not verified. If there are no other problems
         InDatagrams (UDP_MIB_INDATAGRAMS) is then incremented.
         Now, if udp_recvmsg is called as a handler for incoming
         UDP datagrams, the checksum is verified for the first time
         (unless sk_filter was set) and if the checksum fails, the
         `goto csum_copy_err' leads to forcibly removing the datagram
         _and_ incrementing InErrors (UDP_MIB_INERRORS). 

Issue:   When problem occurs in the manner described, the datagram
         is counted twice: once as InDatagram and once as InErrors.
         RFC 2013 defines InDatagrams as counter for delivered datagrams;
         these datagrams are counted but never delivered.

How to reproduce: Send UDP datagrams with checksums enabled, use middlebox
         which corrupts part of the traffic (e.g. bit errors / NetEm) and
         use /proc/net/snmp to watch the counters. The sum of InErrors,
         NoPorts and InDatagrams exceeds the real number of sent datagrams 
         by the number of datagrams which were counted twice and forcibly
         removed by udp_recvmsg.
Non-occurrence: The problem does not occur if the sender disabled 
         UDP checksums (zero field; allowed for IPv4, but not for IPv6), 
         since then the checksum code returns success.

Fix:   Move the `UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS)' statement from 
       udp_queue_rcv_skb to udp_recvmsg. Now InDatagrams only counts those
       datagrams which were really delivered (as per RFC 2013). 

Please CC: any correspondence to gerrit@erg.abdn.ac.uk  

Signed-off-by: <gerrit@erg.abdn.ac.uk>

---

diff -Nurp  a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c	2006-06-06 17:01:26.000000000 +0100
+++ b/net/ipv4/udp.c	2006-06-06 23:39:45.000000000 +0100
@@ -823,6 +823,7 @@ try_again:
 		goto out_free;
 
 	sock_recv_timestamp(msg, sk, skb);
+	UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS);
 
 	/* Copy the address. */
 	if (sin)
@@ -1032,7 +1033,6 @@ static int udp_queue_rcv_skb(struct sock
 		kfree_skb(skb);
 		return -1;
 	}
-	UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS);
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-06-12  7:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-06 18:25 [ PATCH 2.6.17-rc6 1/1] udp.c: counting InDatagrams which are never delivered Gerrit Renker
2006-06-12  4:29 ` David Miller
2006-06-12  6:02   ` Gerrit Renker
2006-06-12  6:13     ` David Miller
2006-06-12  7:22       ` Gerrit Renker
2006-06-12  6:18   ` Herbert Xu
2006-06-12  6:49     ` David Miller
2006-06-12  7:43       ` Herbert Xu

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).