mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values
@ 2015-10-11 20:55 Ben Cartwright-Cox
  2015-10-11 22:10 ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: Ben Cartwright-Cox @ 2015-10-11 20:55 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, ben+patches

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


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

end of thread, other threads:[~2015-10-11 23:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-11 20:55 [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values Ben Cartwright-Cox
2015-10-11 22:10 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®