diff mbox

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

Message ID 52E728D7.70506@cn.fujitsu.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Duan Jiong Jan. 28, 2014, 3:49 a.m. UTC
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.

Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
---

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

 net/ipv4/ip_gre.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Jan. 28, 2014, 4:39 a.m. UTC | #1
From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Tue, 28 Jan 2014 11:49:43 +0800

> 
> 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.
> 
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>

Applied and queued up for -stable, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pravin B Shelar Jan. 28, 2014, 5:35 a.m. UTC | #2
On Mon, Jan 27, 2014 at 7:49 PM, Duan Jiong <duanj.fnst@cn.fujitsu.com> wrote:
>
> 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.
>
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
> ---
>
> v2: use icmp_hdr() instead of conditional pulling of headers
>
>  net/ipv4/ip_gre.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index e7a92fd..ec4f762 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -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?

> --
> 1.8.3.1
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index e7a92fd..ec4f762 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -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);