netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: gre: don't pull skb if dealing with icmp message
@ 2014-01-19  8:35 Duan Jiong
  2014-01-19 21:08 ` Pravin Shelar
  2014-01-22  0:49 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Duan Jiong @ 2014-01-19  8:35 UTC (permalink / raw)
  To: David Miller; +Cc: Daniel Borkmann, netdev


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(). Unfortunately, the ipgre_err still needs
the skb->data points the ip header following the icmp layer,
and those ip addresses in ip header will be used to look up
tunnel by ip_tunnel_lookup().

Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
---
 net/ipv4/gre_demux.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 5893e99..35bfba4 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -116,7 +116,7 @@ static __sum16 check_checksum(struct sk_buff *skb)
 }
 
 static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-			    bool *csum_err)
+			    bool *csum_err, bool in_err)
 {
 	unsigned int ip_hlen = ip_hdrlen(skb);
 	const struct gre_base_hdr *greh;
@@ -160,6 +160,9 @@ static int parse_gre_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	} else
 		tpi->seq = 0;
 
+	if (in_err)
+		return 0;
+
 	/* WCCP version 1 and 2 protocol decoding.
 	 * - Change protocol to IP
 	 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
@@ -182,7 +185,7 @@ static int gre_cisco_rcv(struct sk_buff *skb)
 	int i;
 	bool csum_err = false;
 
-	if (parse_gre_header(skb, &tpi, &csum_err) < 0)
+	if (parse_gre_header(skb, &tpi, &csum_err, false) < 0)
 		goto drop;
 
 	rcu_read_lock();
@@ -229,7 +232,7 @@ static void gre_cisco_err(struct sk_buff *skb, u32 info)
 	bool csum_err = false;
 	int i;
 
-	if (parse_gre_header(skb, &tpi, &csum_err)) {
+	if (parse_gre_header(skb, &tpi, &csum_err, true)) {
 		if (!csum_err)		/* ignore csum errors. */
 			return;
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: gre: don't pull skb if dealing with icmp message
  2014-01-19  8:35 [PATCH] net: gre: don't pull skb if dealing with icmp message Duan Jiong
@ 2014-01-19 21:08 ` Pravin Shelar
  2014-01-20  1:37   ` Duan Jiong
  2014-01-22  0:49 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Pravin Shelar @ 2014-01-19 21:08 UTC (permalink / raw)
  To: Duan Jiong; +Cc: David Miller, Daniel Borkmann, netdev

On Sun, Jan 19, 2014 at 12:35 AM, 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(). Unfortunately, the ipgre_err still needs
> the skb->data points the ip header following the icmp layer,
> and those ip addresses in ip header will be used to look up
> tunnel by ip_tunnel_lookup().
>
This looks like bug.
Can you use ip_hdr() rather than skb->data in ipgre_err().
Same is done in ipgre_rcv().

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: gre: don't pull skb if dealing with icmp message
  2014-01-19 21:08 ` Pravin Shelar
@ 2014-01-20  1:37   ` Duan Jiong
  2014-01-21 18:27     ` Pravin Shelar
  0 siblings, 1 reply; 5+ messages in thread
From: Duan Jiong @ 2014-01-20  1:37 UTC (permalink / raw)
  To: Pravin Shelar; +Cc: David Miller, Daniel Borkmann, netdev

于 2014年01月20日 05:08, Pravin Shelar 写道:
> On Sun, Jan 19, 2014 at 12:35 AM, 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(). Unfortunately, the ipgre_err still needs
>> the skb->data points the ip header following the icmp layer,
>> and those ip addresses in ip header will be used to look up
>> tunnel by ip_tunnel_lookup().
>>
> This looks like bug.
> Can you use ip_hdr() rather than skb->data in ipgre_err().
> Same is done in ipgre_rcv().

That's maybe not a good idea. The ip_hdr() will the return the outmost
ip header, but we need inner ip header following the icmp layer.

Thanks,
  Duan

> --
> 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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: gre: don't pull skb if dealing with icmp message
  2014-01-20  1:37   ` Duan Jiong
@ 2014-01-21 18:27     ` Pravin Shelar
  0 siblings, 0 replies; 5+ messages in thread
From: Pravin Shelar @ 2014-01-21 18:27 UTC (permalink / raw)
  To: Duan Jiong; +Cc: David Miller, Daniel Borkmann, netdev

On Sun, Jan 19, 2014 at 5:37 PM, Duan Jiong <duanj.fnst@cn.fujitsu.com> wrote:
> 于 2014年01月20日 05:08, Pravin Shelar 写道:
>> On Sun, Jan 19, 2014 at 12:35 AM, 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(). Unfortunately, the ipgre_err still needs
>>> the skb->data points the ip header following the icmp layer,
>>> and those ip addresses in ip header will be used to look up
>>> tunnel by ip_tunnel_lookup().
>>>
>> This looks like bug.
>> Can you use ip_hdr() rather than skb->data in ipgre_err().
>> Same is done in ipgre_rcv().
>
> That's maybe not a good idea. The ip_hdr() will the return the outmost
> ip header, but we need inner ip header following the icmp layer.
>
Why do you want to use inner ip header?
If you want to really look at original packet header, you can
calculate it from outer iph header rather than changing fast path
parse_gre_header() function.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: gre: don't pull skb if dealing with icmp message
  2014-01-19  8:35 [PATCH] net: gre: don't pull skb if dealing with icmp message Duan Jiong
  2014-01-19 21:08 ` Pravin Shelar
@ 2014-01-22  0:49 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-01-22  0:49 UTC (permalink / raw)
  To: duanj.fnst; +Cc: dborkman, netdev

From: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Date: Sun, 19 Jan 2014 16:35:22 +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(). Unfortunately, the ipgre_err still needs
> the skb->data points the ip header following the icmp layer,
> and those ip addresses in ip header will be used to look up
> tunnel by ip_tunnel_lookup().
> 
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>

Conditional pulling of headers based upon caller context leads to
impossible to maintain code.

Please find another way to fix this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-22  0:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-19  8:35 [PATCH] net: gre: don't pull skb if dealing with icmp message Duan Jiong
2014-01-19 21:08 ` Pravin Shelar
2014-01-20  1:37   ` Duan Jiong
2014-01-21 18:27     ` Pravin Shelar
2014-01-22  0:49 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).