Skip to contentSkip to conversation

net: Fix GRE RX to use skb_transport_header for GRE header offset

PATCH Applied Tom Herbert 3 participants 4 messages Sep 8, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: Fix GRE RX to use skb_transport_header for GRE header offset

GRE assumes that the GRE header is at skb_network_header + ip_hrdlen(skb). It is more general to use skb_transport_header and this allows the possbility of inserting additional header between IP and GRE (which is what we will done in Generic UDP Encapsulation for GRE).

---
 net/ipv4/gre_demux.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/ipv4/gre_demux.c +2 -3
index 7e0756d..4a7b5b2 100644
@@ -98,7 +98,6 @@ EXPORT_SYMBOL_GPL(gre_build_header);
 static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 			    bool *csum_err)
 {
-	unsigned int ip_hlen = ip_hdrlen(skb);
 	const struct gre_base_hdr *greh;
 	__be32 *options;
 	int hdr_len;
@@ -106,7 +105,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	if (unlikely(!pskb_may_pull(skb, sizeof(struct gre_base_hdr))))
 		return -EINVAL;
 
-	greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
+	greh = (struct gre_base_hdr *)skb_transport_header(skb);
 	if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
 		return -EINVAL;
 
@@ -116,7 +115,7 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	if (!pskb_may_pull(skb, hdr_len))
 		return -EINVAL;
 
-	greh = (struct gre_base_hdr *)(skb_network_header(skb) + ip_hlen);
+	greh = (struct gre_base_hdr *)skb_transport_header(skb);
 	tpi->proto = greh->protocol;
 
 	options = (__be32 *)(greh + 1);
Signature · 1 line
2.1.0.rc2.206.gedb03e5
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Tom Herbert

GRE assumes that the GRE header is at skb_network_header + ip_hrdlen(skb). It is more general to use skb_transport_header and this allows the possbility of inserting additional header between IP and GRE (which is what we will done in Generic UDP Encapsulation for GRE).

---
 net/ipv4/gre_demux.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

I am always confused why you do not include prior Acked-by when you repost same patch.

This forces me to add it again.

Note this should be a net-next patch, right ?

#2 lore raw
Quoted 7 lines · Eric Dumazet
Quoted 6 lines · Tom Herbert

GRE assumes that the GRE header is at skb_network_header + ip_hrdlen(skb). It is more general to use skb_transport_header and this allows the possbility of inserting additional header between IP and GRE (which is what we will done in Generic UDP Encapsulation for GRE).

Quoted 8 lines
Quoted 4 lines
---
 net/ipv4/gre_demux.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

I am always confused why you do not include prior Acked-by when you repost same patch.

Sorry, I'll do that next time.

Quoted 4 lines

This forces me to add it again.

Note this should be a net-next patch, right ?

Yes.

Quoted 3 lines
maintainer Applied
#3 lore raw
In reply to Tom Herbert

From: Tom Herbert <[email protected]>
Date: Mon, 8 Sep 2014 08:29:12 -0700

Quoted 7 lines

GRE assumes that the GRE header is at skb_network_header + ip_hrdlen(skb). It is more general to use skb_transport_header and this allows the possbility of inserting additional header between IP and GRE (which is what we will done in Generic UDP Encapsulation for GRE).

Applied, thanks Tom.