Skip to contentSkip to conversation

ipv4: Fix wrong order of ip_rt_get_source() and update iph->daddr.

PATCH Superseded Li Wei 3 participants 6 messages Feb 10, 2012

Subsystems (3)
lore
Share & tools
lore

Li Wei

author
#0 lore raw

PATCH 1/1 ipv4: Fix wrong order of ip_rt_get_source() and update iph->daddr.

Need to update iph->daddr before ip_rt_get_source(), otherwise we may get a wrong src.

---
 net/ipv4/ip_options.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/ip_options.c +1 -1
index 1e60f76..42dd1a9 100644
@@ -573,8 +573,8 @@ void ip_forward_options(struct sk_buff *skb)
 		}
 		if (srrptr + 3 <= srrspace) {
 			opt->is_changed = 1;
-			ip_rt_get_source(&optptr[srrptr-1], skb, rt);
 			ip_hdr(skb)->daddr = opt->nexthop;
+			ip_rt_get_source(&optptr[srrptr-1], skb, rt);
 			optptr[2] = srrptr+4;
 		} else if (net_ratelimit())
 			printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n");
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Li Wei

Need to update iph->daddr before ip_rt_get_source(), otherwise we may get a wrong src.

It would be nice that patch submitters try to pinpoint bug origin in changelog, to ease patch review and stable submissions.

Is it coming from ac8a48106be49c422575ddc7531b776f8eb49610 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.) added in 3.2, or is it something needing a backport in some other way in old kernels ?

Thanks !

author
#2 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 3 lines · Li Wei

Need to update iph->daddr before ip_rt_get_source(), otherwise we may get a wrong src.

It would be nice that patch submitters try to pinpoint bug origin in changelog, to ease patch review and stable submissions.

Is it coming from ac8a48106be49c422575ddc7531b776f8eb49610 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.) added in 3.2, or is it something needing a backport in some other way in old kernels ?

As you said, it is coming from ac8a48106be49c422575ddc7531b776f8eb49610 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.).

I'll modify the changelog and post a v2.

Thanks!

Quoted 6 lines

Thanks !

author
#3 lore raw
In reply to Eric Dumazet
Quoted 5 lines · Eric Dumazet
Quoted 3 lines · Li Wei

Need to update iph->daddr before ip_rt_get_source(), otherwise we may get a wrong src.

Quoted 7 lines

It would be nice that patch submitters try to pinpoint bug origin in changelog, to ease patch review and stable submissions.

Is it coming from ac8a48106be49c422575ddc7531b776f8eb49610 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.) added in 3.2, or is it something needing a backport in some other way in old kernels ?

As you said, it is coming from ac8a48106be49c422575ddc7531b776f8eb49610 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.).

I'll modify the changelog and post a v2.

Thanks!

Quoted 5 lines

Thanks !

author
#4 lore raw

PATCH v2 1/1 ipv4: Fix wrong order of ip_rt_get_source() and update iph->daddr.

In reply to Li Wei

This patch fix a bug which introduced by commit ac8a4810 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.).In that patch, we saved the nexthop of SRR in ip_option->nexthop and update iph->daddr until we get to ip_forward_options(), but we need to update it before ip_rt_get_source(), otherwise we may get a wrong src.

---
 net/ipv4/ip_options.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/ip_options.c +1 -1
index 1e60f76..42dd1a9 100644
@@ -573,8 +573,8 @@ void ip_forward_options(struct sk_buff *skb)
 		}
 		if (srrptr + 3 <= srrspace) {
 			opt->is_changed = 1;
-			ip_rt_get_source(&optptr[srrptr-1], skb, rt);
 			ip_hdr(skb)->daddr = opt->nexthop;
+			ip_rt_get_source(&optptr[srrptr-1], skb, rt);
 			optptr[2] = srrptr+4;
 		} else if (net_ratelimit())
 			printk(KERN_CRIT "ip_forward(): Argh! Destination lost!\n");

-- 1.7.1

maintainer Applied
#5 lore raw

From: Li Wei <[email protected]>
Date: Fri, 10 Feb 2012 15:15:25 +0800

Quoted 7 lines

This patch fix a bug which introduced by commit ac8a4810 (ipv4: Save nexthop address of LSRR/SSRR option to IPCB.).In that patch, we saved the nexthop of SRR in ip_option->nexthop and update iph->daddr until we get to ip_forward_options(), but we need to update it before ip_rt_get_source(), otherwise we may get a wrong src.

Applied, thanks.