gre: fix error handler
1) gre_parse_header() can be called from gre_err()
At this point transport header points to ICMP header, not the inner
header.
2) We can not really change transport header as ipgre_err() will later
assume transport header still points to ICMP header (using icmp_hdr())
3) pskb_may_pull() logic in gre_parse_header() really works
if we are interested at zone pointed by skb->data
4) As Jiri explained in commit b7f8fe251e
("gre: do not pull header in
ICMP error processing") we should not pull headers in error handler.
So this fix :
A) changes gre_parse_header() to use skb->data instead of
skb_transport_header()
B) Adds a nhs parameter to gre_parse_header() so that we can skip the
not pulled IP header from error path.
This offset is 0 for normal receive path.
C) remove obsolete IPV6 includes
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <tom@herbertland.com>
Cc: Maciej Żenczykowski <maze@google.com>
Cc: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
daddef76c3
commit
e582615ad3
@@ -49,12 +49,6 @@
|
||||
#include <net/gre.h>
|
||||
#include <net/dst_metadata.h>
|
||||
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
#include <net/ipv6.h>
|
||||
#include <net/ip6_fib.h>
|
||||
#include <net/ip6_route.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
Problems & solutions
|
||||
--------------------
|
||||
@@ -217,12 +211,14 @@ static void gre_err(struct sk_buff *skb, u32 info)
|
||||
* by themselves???
|
||||
*/
|
||||
|
||||
const struct iphdr *iph = (struct iphdr *)skb->data;
|
||||
const int type = icmp_hdr(skb)->type;
|
||||
const int code = icmp_hdr(skb)->code;
|
||||
struct tnl_ptk_info tpi;
|
||||
bool csum_err = false;
|
||||
|
||||
if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP)) < 0) {
|
||||
if (gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP),
|
||||
iph->ihl * 4) < 0) {
|
||||
if (!csum_err) /* ignore csum errors. */
|
||||
return;
|
||||
}
|
||||
@@ -338,7 +334,7 @@ static int gre_rcv(struct sk_buff *skb)
|
||||
}
|
||||
#endif
|
||||
|
||||
hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP));
|
||||
hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), 0);
|
||||
if (hdr_len < 0)
|
||||
goto drop;
|
||||
|
||||
|
Reference in New Issue
Block a user