diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2011-04-07 17:04:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-07 17:04:08 -0400 |
commit | 1b86a58f9d7ce4fe2377687f378fbfb53bdc9b6c (patch) | |
tree | e931b86166c2a644470e3754e2d3139f97834951 /net/ipv4/route.c | |
parent | 9b57e1a79e2142df8412ab223c90ba6f47c6b3a3 (diff) |
ipv4: Fix "Set rt->rt_iif more sanely on output routes."
Commit 1018b5c01636c7c6bda31a719bda34fc631db29a ("Set rt->rt_iif more
sanely on output routes.") breaks rt_is_{output,input}_route.
This became the cause to return "IP_PKTINFO's ->ipi_ifindex == 0".
To fix it, this does:
1) Add "int rt_route_iif;" to struct rtable
2) For input routes, always set rt_route_iif to same value as rt_iif
3) For output routes, always set rt_route_iif to zero. Set rt_iif
as it is done currently.
4) Change rt_is_{output,input}_route() to test rt_route_iif
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 4b0c81180804..1628be530314 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1891,6 +1891,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
1891 | #ifdef CONFIG_IP_ROUTE_CLASSID | 1891 | #ifdef CONFIG_IP_ROUTE_CLASSID |
1892 | rth->dst.tclassid = itag; | 1892 | rth->dst.tclassid = itag; |
1893 | #endif | 1893 | #endif |
1894 | rth->rt_route_iif = dev->ifindex; | ||
1894 | rth->rt_iif = dev->ifindex; | 1895 | rth->rt_iif = dev->ifindex; |
1895 | rth->dst.dev = init_net.loopback_dev; | 1896 | rth->dst.dev = init_net.loopback_dev; |
1896 | dev_hold(rth->dst.dev); | 1897 | dev_hold(rth->dst.dev); |
@@ -2026,6 +2027,7 @@ static int __mkroute_input(struct sk_buff *skb, | |||
2026 | rth->rt_key_src = saddr; | 2027 | rth->rt_key_src = saddr; |
2027 | rth->rt_src = saddr; | 2028 | rth->rt_src = saddr; |
2028 | rth->rt_gateway = daddr; | 2029 | rth->rt_gateway = daddr; |
2030 | rth->rt_route_iif = in_dev->dev->ifindex; | ||
2029 | rth->rt_iif = in_dev->dev->ifindex; | 2031 | rth->rt_iif = in_dev->dev->ifindex; |
2030 | rth->dst.dev = (out_dev)->dev; | 2032 | rth->dst.dev = (out_dev)->dev; |
2031 | dev_hold(rth->dst.dev); | 2033 | dev_hold(rth->dst.dev); |
@@ -2202,6 +2204,7 @@ local_input: | |||
2202 | #ifdef CONFIG_IP_ROUTE_CLASSID | 2204 | #ifdef CONFIG_IP_ROUTE_CLASSID |
2203 | rth->dst.tclassid = itag; | 2205 | rth->dst.tclassid = itag; |
2204 | #endif | 2206 | #endif |
2207 | rth->rt_route_iif = dev->ifindex; | ||
2205 | rth->rt_iif = dev->ifindex; | 2208 | rth->rt_iif = dev->ifindex; |
2206 | rth->dst.dev = net->loopback_dev; | 2209 | rth->dst.dev = net->loopback_dev; |
2207 | dev_hold(rth->dst.dev); | 2210 | dev_hold(rth->dst.dev); |
@@ -2401,7 +2404,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2401 | rth->rt_mark = oldflp4->flowi4_mark; | 2404 | rth->rt_mark = oldflp4->flowi4_mark; |
2402 | rth->rt_dst = fl4->daddr; | 2405 | rth->rt_dst = fl4->daddr; |
2403 | rth->rt_src = fl4->saddr; | 2406 | rth->rt_src = fl4->saddr; |
2404 | rth->rt_iif = 0; | 2407 | rth->rt_route_iif = 0; |
2408 | rth->rt_iif = oldflp4->flowi4_oif ? : dev_out->ifindex; | ||
2405 | /* get references to the devices that are to be hold by the routing | 2409 | /* get references to the devices that are to be hold by the routing |
2406 | cache entry */ | 2410 | cache entry */ |
2407 | rth->dst.dev = dev_out; | 2411 | rth->dst.dev = dev_out; |
@@ -2716,6 +2720,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or | |||
2716 | rt->rt_key_dst = ort->rt_key_dst; | 2720 | rt->rt_key_dst = ort->rt_key_dst; |
2717 | rt->rt_key_src = ort->rt_key_src; | 2721 | rt->rt_key_src = ort->rt_key_src; |
2718 | rt->rt_tos = ort->rt_tos; | 2722 | rt->rt_tos = ort->rt_tos; |
2723 | rt->rt_route_iif = ort->rt_route_iif; | ||
2719 | rt->rt_iif = ort->rt_iif; | 2724 | rt->rt_iif = ort->rt_iif; |
2720 | rt->rt_oif = ort->rt_oif; | 2725 | rt->rt_oif = ort->rt_oif; |
2721 | rt->rt_mark = ort->rt_mark; | 2726 | rt->rt_mark = ort->rt_mark; |
@@ -2725,7 +2730,6 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or | |||
2725 | rt->rt_type = ort->rt_type; | 2730 | rt->rt_type = ort->rt_type; |
2726 | rt->rt_dst = ort->rt_dst; | 2731 | rt->rt_dst = ort->rt_dst; |
2727 | rt->rt_src = ort->rt_src; | 2732 | rt->rt_src = ort->rt_src; |
2728 | rt->rt_iif = ort->rt_iif; | ||
2729 | rt->rt_gateway = ort->rt_gateway; | 2733 | rt->rt_gateway = ort->rt_gateway; |
2730 | rt->rt_spec_dst = ort->rt_spec_dst; | 2734 | rt->rt_spec_dst = ort->rt_spec_dst; |
2731 | rt->peer = ort->peer; | 2735 | rt->peer = ort->peer; |