From: Ben Cartwright-Cox <ben@benjojo.co.uk>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
ben+patches@benjojo.co.uk
Subject: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values
Date: Sun, 11 Oct 2015 20:55:28 +0000 [thread overview]
Message-ID: <20151011205528.GA4322@benjojo.co.uk> (raw)
Sending ICMP packets with raw sockets ends up in the SNMP counters
logging the type as the first byte of the IPv4 header rather than
the ICMP header (in nearly all cases this is seen as "OutType69".
This is fixed by adding the IP Header Length to the casting into
a icmphdr struct.
Signed-off-by: Ben Cartwright-Cox <ben@benjojo.co.uk>
---
net/ipv4/raw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 561cd4b..1ad8bae 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -409,7 +409,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
}
if (iph->protocol == IPPROTO_ICMP)
icmp_out_count(net, ((struct icmphdr *)
- skb_transport_header(skb))->type);
+ skb_transport_header(skb) + iphlen)->type);
err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb,
NULL, rt->dst.dev, dst_output_sk);
--
1.9.1
next reply other threads:[~2015-10-11 21:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-11 20:55 Ben Cartwright-Cox [this message]
2015-10-11 22:10 ` [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values Eric Dumazet
2015-10-11 22:17 ` Ben Cox
2015-10-11 22:43 ` Eric Dumazet
2015-10-11 22:44 ` Eric Dumazet
2015-10-11 23:09 ` Eric Dumazet
2015-10-11 23:14 ` Ben Cox
2015-10-11 23:37 ` 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=20151011205528.GA4322@benjojo.co.uk \
--to=ben@benjojo.co.uk \
--cc=ben+patches@benjojo.co.uk \
--cc=davem@davemloft.net \
--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).