From: Wang Chen <wangchen@cn.fujitsu.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, gerrit@erg.abdn.ac.uk
Subject: [PATCH 1/2] [IPV4] SNMP: Decrement of UDP InDatagrams for bad checksum
Date: Fri, 16 Nov 2007 17:31:25 +0800 [thread overview]
Message-ID: <473D636D.7090304@cn.fujitsu.com> (raw)
Dave
If there is no socket filter, a bad checksum udp packet will be queued and
ready for user to read. At the same time the InDatagrams is increased.
So we need to decrement InDatagrams when recvmsg() or poll() notice the
bad checksum.
Seems Gerrit had fix it a year ago.(http://lkml.org/lkml/2006/8/28/218)
But it's not in kernel now. So I make the same patch for 2.6.24.rc2.
If this patch ok, I will make the same one for IPv6 UDP.
[PATCH 1/2] [IPV4] SNMP: Decrement of UDP InDatagrams for bad checksum
Decrement UDP InDatagrams for bad checksum UDP packet in ready queue.
Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
---
include/net/snmp.h | 2 ++
include/net/udp.h | 3 +++
net/ipv4/udp.c | 2 ++
3 files changed, 7 insertions(+)
diff -Nurp linux-2.6.24-rc2.org/include/net/snmp.h linux-2.6.24-rc2/include/net/snmp.h
--- linux-2.6.24-rc2.org/include/net/snmp.h 2007-11-09 16:37:08.000000000 +0800
+++ linux-2.6.24-rc2/include/net/snmp.h 2007-11-16 16:57:51.000000000 +0800
@@ -142,6 +142,8 @@ struct linux_mib {
(per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++)
#define SNMP_DEC_STATS(mib, field) \
(per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--)
+#define SNMP_DEC_STATS_BH(mib, field) \
+ (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]--)
#define SNMP_ADD_STATS_BH(mib, field, addend) \
(per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
#define SNMP_ADD_STATS_USER(mib, field, addend) \
diff -Nurp linux-2.6.24-rc2.org/include/net/udp.h linux-2.6.24-rc2/include/net/udp.h
--- linux-2.6.24-rc2.org/include/net/udp.h 2007-11-09 16:37:08.000000000 +0800
+++ linux-2.6.24-rc2/include/net/udp.h 2007-11-16 16:58:41.000000000 +0800
@@ -148,6 +148,9 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_st
#define UDP_INC_STATS_BH(field, is_udplite) do { \
if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
+#define UDP_DEC_STATS_BH(field, is_udplite) do { \
+ if (is_udplite) SNMP_DEC_STATS_BH(udplite_statistics, field); \
+ else SNMP_DEC_STATS_BH(udp_statistics, field); } while(0)
/* /proc */
struct udp_seq_afinfo {
diff -Nurp linux-2.6.24-rc2.org/net/ipv4/udp.c linux-2.6.24-rc2/net/ipv4/udp.c
--- linux-2.6.24-rc2.org/net/ipv4/udp.c 2007-11-09 16:37:57.000000000 +0800
+++ linux-2.6.24-rc2/net/ipv4/udp.c 2007-11-16 15:02:44.000000000 +0800
@@ -897,6 +897,7 @@ out:
csum_copy_err:
UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_udplite);
+ UDP_DEC_STATS_BH(UDP_MIB_INDATAGRAMS, is_udplite);
skb_kill_datagram(sk, skb, flags);
@@ -1416,6 +1417,7 @@ unsigned int udp_poll(struct file *file,
while ((skb = skb_peek(rcvq)) != NULL &&
udp_lib_checksum_complete(skb)) {
UDP_INC_STATS_BH(UDP_MIB_INERRORS, is_lite);
+ UDP_DEC_STATS_BH(UDP_MIB_INDATAGRAMS, is_lite);
__skb_unlink(skb, rcvq);
kfree_skb(skb);
}
next reply other threads:[~2007-11-16 9:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 9:31 Wang Chen [this message]
2007-11-16 10:59 ` [PATCH 1/2] [IPV4] SNMP: Decrement of UDP InDatagrams for bad checksum Gerrit Renker
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=473D636D.7090304@cn.fujitsu.com \
--to=wangchen@cn.fujitsu.com \
--cc=davem@davemloft.net \
--cc=gerrit@erg.abdn.ac.uk \
--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).