Skip to contentSkip to conversation

net: gre: use icmp_hdr() to get inner ip header

PATCH In review Duan Jiong 3 participants 3 messages Jan 28, 2014

Subsystems (3)
lore
Share & tools
lore

Duan Jiong

author
#0 lore raw

PATCH v2 1/1 net: gre: use icmp_hdr() to get inner ip header

When dealing with icmp messages, the skb->data points the ip header that triggered the sending of the icmp message.

In gre_cisco_err(), the parse_gre_header() is called, and the iptunnel_pull_header() is called to pull the skb at the end of the parse_gre_header(), so the skb->data doesn't point the inner ip header.

Unfortunately, the ipgre_err still needs those ip addresses in inner ip header to look up tunnel by ip_tunnel_lookup().

So just use icmp_hdr() to get inner ip header instead of skb->data.

---

v2: use icmp_hdr() instead of conditional pulling of headers

 net/ipv4/ip_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/ip_gre.c +1 -1
index e7a92fd..ec4f762 100644
@@ -178,7 +178,7 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
 	else
 		itn = net_generic(net, ipgre_net_id);
 
-	iph = (const struct iphdr *)skb->data;
+	iph = (const struct iphdr *)(icmp_hdr(skb) + 1);
 	t = ip_tunnel_lookup(itn, skb->dev->ifindex, tpi->flags,
 			     iph->daddr, iph->saddr, tpi->key);
 
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw

From: Duan Jiong <[email protected]>
Date: Tue, 28 Jan 2014 11:49:43 +0800

Quoted 9 lines

When dealing with icmp messages, the skb->data points the ip header that triggered the sending of the icmp message.

In gre_cisco_err(), the parse_gre_header() is called, and the iptunnel_pull_header() is called to pull the skb at the end of the parse_gre_header(), so the skb->data doesn't point the inner ip header.

Quoted 6 lines

Unfortunately, the ipgre_err still needs those ip addresses in inner ip header to look up tunnel by ip_tunnel_lookup().

So just use icmp_hdr() to get inner ip header instead of skb->data.

Applied and queued up for -stable, thanks.

#2 lore raw
In reply to Duan Jiong
Quoted 27 lines · Duan Jiong

When dealing with icmp messages, the skb->data points the ip header that triggered the sending of the icmp message.

In gre_cisco_err(), the parse_gre_header() is called, and the iptunnel_pull_header() is called to pull the skb at the end of the parse_gre_header(), so the skb->data doesn't point the inner ip header.

Unfortunately, the ipgre_err still needs those ip addresses in inner ip header to look up tunnel by ip_tunnel_lookup().

So just use icmp_hdr() to get inner ip header instead of skb->data.

---

v2: use icmp_hdr() instead of conditional pulling of headers

 net/ipv4/ip_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/ip_gre.c +0 -0
index e7a92fd..ec4f762 100644

net/ipv4/ip_gre.c static int ipgre_err(struct sk_buff *skb, u32 info, · line 184

Quoted 8 lines
net/ipv4/ip_gre.c +1 -1
@@ -178,7 +178,7 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
        else
                itn = net_generic(net, ipgre_net_id);
 
-       iph = (const struct iphdr *)skb->data;
+       iph = (const struct iphdr *)(icmp_hdr(skb) + 1);
        t = ip_tunnel_lookup(itn, skb->dev->ifindex, tpi->flags,
                             iph->daddr, iph->saddr, tpi->key);
 

Don't we need to pull inner ip header first?

Quoted 6 lines

--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html