netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv4: fix redirect handling for TCP packets
@ 2013-05-27  7:47 Michal Kubecek
  2013-05-28  6:23 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Kubecek @ 2013-05-27  7:47 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy

Unlike ipv4_redirect() and ipv4_sk_redirect(), ip_do_redirect()
doesn't call __build_flow_key() directly but via
ip_rt_build_flow_key() wrapper. This leads to __build_flow_key()
getting pointer to IPv4 header of the ICMP redirect packet
rather than pointer to the embedded IPv4 header of the packet
initiating the redirect.

As a result, handling of ICMP redirects initiated by TCP packets
is broken. Issue was introduced by commit 4895c771c (v3.6-rc1).

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 net/ipv4/route.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 550781a..d35bbf0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -737,10 +737,15 @@ static void ip_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_buf
 {
 	struct rtable *rt;
 	struct flowi4 fl4;
+	const struct iphdr *iph = (const struct iphdr *) skb->data;
+	int oif = skb->dev->ifindex;
+	u8 tos = RT_TOS(iph->tos);
+	u8 prot = iph->protocol;
+	u32 mark = skb->mark;
 
 	rt = (struct rtable *) dst;
 
-	ip_rt_build_flow_key(&fl4, sk, skb);
+	__build_flow_key(&fl4, sk, iph, oif, tos, prot, mark, 0);
 	__ip_do_redirect(rt, skb, &fl4, true);
 }
 
-- 
1.8.1.4

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

* Re: [PATCH net] ipv4: fix redirect handling for TCP packets
  2013-05-27  7:47 [PATCH net] ipv4: fix redirect handling for TCP packets Michal Kubecek
@ 2013-05-28  6:23 ` David Miller
  2013-05-28  6:26   ` [PATCH net v2] " Michal Kubecek
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2013-05-28  6:23 UTC (permalink / raw)
  To: mkubecek; +Cc: netdev, kuznet, jmorris, yoshfuji, kaber

From: Michal Kubecek <mkubecek@suse.cz>
Date: Mon, 27 May 2013 09:47:56 +0200

> Issue was introduced by commit 4895c771c (v3.6-rc1).

This string in parenthesis is not from the commit that introduced the
problem, it's from some random release tag after the commit.

You should always reference changes like this:

	$SHA1ID ("Header line of the $SHA1ID commits message.")

Please fix this up and resubmit, thanks.

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

* [PATCH net v2] ipv4: fix redirect handling for TCP packets
  2013-05-28  6:23 ` David Miller
@ 2013-05-28  6:26   ` Michal Kubecek
  2013-05-28  6:40     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Kubecek @ 2013-05-28  6:26 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy

Unlike ipv4_redirect() and ipv4_sk_redirect(), ip_do_redirect()
doesn't call __build_flow_key() directly but via
ip_rt_build_flow_key() wrapper. This leads to __build_flow_key()
getting pointer to IPv4 header of the ICMP redirect packet
rather than pointer to the embedded IPv4 header of the packet
initiating the redirect.

As a result, handling of ICMP redirects initiated by TCP packets
is broken. Issue was introduced by

	4895c771c ("ipv4: Add FIB nexthop exceptions.")

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 net/ipv4/route.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 550781a..d35bbf0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -737,10 +737,15 @@ static void ip_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_buf
 {
 	struct rtable *rt;
 	struct flowi4 fl4;
+	const struct iphdr *iph = (const struct iphdr *) skb->data;
+	int oif = skb->dev->ifindex;
+	u8 tos = RT_TOS(iph->tos);
+	u8 prot = iph->protocol;
+	u32 mark = skb->mark;
 
 	rt = (struct rtable *) dst;
 
-	ip_rt_build_flow_key(&fl4, sk, skb);
+	__build_flow_key(&fl4, sk, iph, oif, tos, prot, mark, 0);
 	__ip_do_redirect(rt, skb, &fl4, true);
 }
 
-- 
1.8.1.4

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

* Re: [PATCH net v2] ipv4: fix redirect handling for TCP packets
  2013-05-28  6:26   ` [PATCH net v2] " Michal Kubecek
@ 2013-05-28  6:40     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2013-05-28  6:40 UTC (permalink / raw)
  To: mkubecek; +Cc: netdev, kuznet, jmorris, yoshfuji, kaber

From: Michal Kubecek <mkubecek@suse.cz>
Date: Tue, 28 May 2013 08:26:49 +0200

> Unlike ipv4_redirect() and ipv4_sk_redirect(), ip_do_redirect()
> doesn't call __build_flow_key() directly but via
> ip_rt_build_flow_key() wrapper. This leads to __build_flow_key()
> getting pointer to IPv4 header of the ICMP redirect packet
> rather than pointer to the embedded IPv4 header of the packet
> initiating the redirect.
> 
> As a result, handling of ICMP redirects initiated by TCP packets
> is broken. Issue was introduced by
> 
> 	4895c771c ("ipv4: Add FIB nexthop exceptions.")
> 
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

Applied, thanks!

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

end of thread, other threads:[~2013-05-28  6:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-27  7:47 [PATCH net] ipv4: fix redirect handling for TCP packets Michal Kubecek
2013-05-28  6:23 ` David Miller
2013-05-28  6:26   ` [PATCH net v2] " Michal Kubecek
2013-05-28  6:40     ` 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).