From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ben Cox <ben@benjojo.co.uk>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, ben+patches@benjojo.co.uk,
David L Stevens <dlstevens@us.ibm.com>
Subject: Re: [PATCH] icmp: Fixed bug in raw sockets causing incorrect ICMP SNMP counter values
Date: Sun, 11 Oct 2015 16:09:29 -0700 [thread overview]
Message-ID: <1444604969.27760.149.camel@edumazet-glaptop2.roam.corp.google.com> (raw)
In-Reply-To: <1444603443.27760.147.camel@edumazet-glaptop2.roam.corp.google.com>
On Sun, 2015-10-11 at 15:44 -0700, Eric Dumazet wrote:
> On Sun, 2015-10-11 at 15:43 -0700, Eric Dumazet wrote:
>
> > But your code reads 21th byte.
>
> BTW, nice catch !
Maybe the following one.
1) We properly set transport header
2) We use icmp_hdr() helper.
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 561cd4b8fc6e..ffe25cd1f0e0 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -406,11 +406,11 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
ip_select_ident(net, skb, NULL);
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
+ skb->transport_header += iphlen;
+ if (iph->protocol == IPPROTO_ICMP &&
+ length >= iphlen + sizeof(struct icmphdr))
+ icmp_out_count(net, icmp_hdr(skb)->type);
}
- if (iph->protocol == IPPROTO_ICMP)
- icmp_out_count(net, ((struct icmphdr *)
- skb_transport_header(skb))->type);
-
err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, sk, skb,
NULL, rt->dst.dev, dst_output_sk);
if (err > 0)
next prev parent reply other threads:[~2015-10-11 23:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-11 20:55 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 [this message]
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=1444604969.27760.149.camel@edumazet-glaptop2.roam.corp.google.com \
--to=eric.dumazet@gmail.com \
--cc=ben+patches@benjojo.co.uk \
--cc=ben@benjojo.co.uk \
--cc=davem@davemloft.net \
--cc=dlstevens@us.ibm.com \
--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
all inboxes | Powered by JetHome®