diff options
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 870b5182ddd8..c1acf69858fd 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -821,7 +821,7 @@ static int has_noalias(const struct rtable *head, const struct rtable *rth) | |||
821 | } | 821 | } |
822 | 822 | ||
823 | /* | 823 | /* |
824 | * Pertubation of rt_genid by a small quantity [1..256] | 824 | * Perturbation of rt_genid by a small quantity [1..256] |
825 | * Using 8 bits of shuffling ensure we can call rt_cache_invalidate() | 825 | * Using 8 bits of shuffling ensure we can call rt_cache_invalidate() |
826 | * many times (2^24) without giving recent rt_genid. | 826 | * many times (2^24) without giving recent rt_genid. |
827 | * Jenkins hash is strong enough that litle changes of rt_genid are OK. | 827 | * Jenkins hash is strong enough that litle changes of rt_genid are OK. |
@@ -1191,7 +1191,7 @@ restart: | |||
1191 | #endif | 1191 | #endif |
1192 | /* | 1192 | /* |
1193 | * Since lookup is lockfree, we must make sure | 1193 | * Since lookup is lockfree, we must make sure |
1194 | * previous writes to rt are comitted to memory | 1194 | * previous writes to rt are committed to memory |
1195 | * before making rt visible to other CPUS. | 1195 | * before making rt visible to other CPUS. |
1196 | */ | 1196 | */ |
1197 | rcu_assign_pointer(rt_hash_table[hash].chain, rt); | 1197 | rcu_assign_pointer(rt_hash_table[hash].chain, rt); |
@@ -1593,8 +1593,6 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
1593 | rt->rt_peer_genid = rt_peer_genid(); | 1593 | rt->rt_peer_genid = rt_peer_genid(); |
1594 | } | 1594 | } |
1595 | check_peer_pmtu(dst, peer); | 1595 | check_peer_pmtu(dst, peer); |
1596 | |||
1597 | inet_putpeer(peer); | ||
1598 | } | 1596 | } |
1599 | } | 1597 | } |
1600 | 1598 | ||
@@ -1720,7 +1718,7 @@ void ip_rt_get_source(u8 *addr, struct rtable *rt) | |||
1720 | 1718 | ||
1721 | rcu_read_lock(); | 1719 | rcu_read_lock(); |
1722 | if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res) == 0) | 1720 | if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res) == 0) |
1723 | src = FIB_RES_PREFSRC(res); | 1721 | src = FIB_RES_PREFSRC(dev_net(rt->dst.dev), res); |
1724 | else | 1722 | else |
1725 | src = inet_select_addr(rt->dst.dev, rt->rt_gateway, | 1723 | src = inet_select_addr(rt->dst.dev, rt->rt_gateway, |
1726 | RT_SCOPE_UNIVERSE); | 1724 | RT_SCOPE_UNIVERSE); |
@@ -1893,6 +1891,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
1893 | #ifdef CONFIG_IP_ROUTE_CLASSID | 1891 | #ifdef CONFIG_IP_ROUTE_CLASSID |
1894 | rth->dst.tclassid = itag; | 1892 | rth->dst.tclassid = itag; |
1895 | #endif | 1893 | #endif |
1894 | rth->rt_route_iif = dev->ifindex; | ||
1896 | rth->rt_iif = dev->ifindex; | 1895 | rth->rt_iif = dev->ifindex; |
1897 | rth->dst.dev = init_net.loopback_dev; | 1896 | rth->dst.dev = init_net.loopback_dev; |
1898 | dev_hold(rth->dst.dev); | 1897 | dev_hold(rth->dst.dev); |
@@ -2028,6 +2027,7 @@ static int __mkroute_input(struct sk_buff *skb, | |||
2028 | rth->rt_key_src = saddr; | 2027 | rth->rt_key_src = saddr; |
2029 | rth->rt_src = saddr; | 2028 | rth->rt_src = saddr; |
2030 | rth->rt_gateway = daddr; | 2029 | rth->rt_gateway = daddr; |
2030 | rth->rt_route_iif = in_dev->dev->ifindex; | ||
2031 | rth->rt_iif = in_dev->dev->ifindex; | 2031 | rth->rt_iif = in_dev->dev->ifindex; |
2032 | rth->dst.dev = (out_dev)->dev; | 2032 | rth->dst.dev = (out_dev)->dev; |
2033 | dev_hold(rth->dst.dev); | 2033 | dev_hold(rth->dst.dev); |
@@ -2204,6 +2204,7 @@ local_input: | |||
2204 | #ifdef CONFIG_IP_ROUTE_CLASSID | 2204 | #ifdef CONFIG_IP_ROUTE_CLASSID |
2205 | rth->dst.tclassid = itag; | 2205 | rth->dst.tclassid = itag; |
2206 | #endif | 2206 | #endif |
2207 | rth->rt_route_iif = dev->ifindex; | ||
2207 | rth->rt_iif = dev->ifindex; | 2208 | rth->rt_iif = dev->ifindex; |
2208 | rth->dst.dev = net->loopback_dev; | 2209 | rth->dst.dev = net->loopback_dev; |
2209 | dev_hold(rth->dst.dev); | 2210 | dev_hold(rth->dst.dev); |
@@ -2403,7 +2404,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
2403 | rth->rt_mark = oldflp4->flowi4_mark; | 2404 | rth->rt_mark = oldflp4->flowi4_mark; |
2404 | rth->rt_dst = fl4->daddr; | 2405 | rth->rt_dst = fl4->daddr; |
2405 | rth->rt_src = fl4->saddr; | 2406 | rth->rt_src = fl4->saddr; |
2406 | rth->rt_iif = 0; | 2407 | rth->rt_route_iif = 0; |
2408 | rth->rt_iif = oldflp4->flowi4_oif ? : dev_out->ifindex; | ||
2407 | /* 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 |
2408 | cache entry */ | 2410 | cache entry */ |
2409 | rth->dst.dev = dev_out; | 2411 | rth->dst.dev = dev_out; |
@@ -2617,7 +2619,7 @@ static struct rtable *ip_route_output_slow(struct net *net, | |||
2617 | fib_select_default(&res); | 2619 | fib_select_default(&res); |
2618 | 2620 | ||
2619 | if (!fl4.saddr) | 2621 | if (!fl4.saddr) |
2620 | fl4.saddr = FIB_RES_PREFSRC(res); | 2622 | fl4.saddr = FIB_RES_PREFSRC(net, res); |
2621 | 2623 | ||
2622 | dev_out = FIB_RES_DEV(res); | 2624 | dev_out = FIB_RES_DEV(res); |
2623 | fl4.flowi4_oif = dev_out->ifindex; | 2625 | fl4.flowi4_oif = dev_out->ifindex; |
@@ -2718,6 +2720,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or | |||
2718 | rt->rt_key_dst = ort->rt_key_dst; | 2720 | rt->rt_key_dst = ort->rt_key_dst; |
2719 | rt->rt_key_src = ort->rt_key_src; | 2721 | rt->rt_key_src = ort->rt_key_src; |
2720 | rt->rt_tos = ort->rt_tos; | 2722 | rt->rt_tos = ort->rt_tos; |
2723 | rt->rt_route_iif = ort->rt_route_iif; | ||
2721 | rt->rt_iif = ort->rt_iif; | 2724 | rt->rt_iif = ort->rt_iif; |
2722 | rt->rt_oif = ort->rt_oif; | 2725 | rt->rt_oif = ort->rt_oif; |
2723 | rt->rt_mark = ort->rt_mark; | 2726 | rt->rt_mark = ort->rt_mark; |
@@ -2727,7 +2730,6 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or | |||
2727 | rt->rt_type = ort->rt_type; | 2730 | rt->rt_type = ort->rt_type; |
2728 | rt->rt_dst = ort->rt_dst; | 2731 | rt->rt_dst = ort->rt_dst; |
2729 | rt->rt_src = ort->rt_src; | 2732 | rt->rt_src = ort->rt_src; |
2730 | rt->rt_iif = ort->rt_iif; | ||
2731 | rt->rt_gateway = ort->rt_gateway; | 2733 | rt->rt_gateway = ort->rt_gateway; |
2732 | rt->rt_spec_dst = ort->rt_spec_dst; | 2734 | rt->rt_spec_dst = ort->rt_spec_dst; |
2733 | rt->peer = ort->peer; | 2735 | rt->peer = ort->peer; |
@@ -3221,6 +3223,8 @@ static __net_init int rt_genid_init(struct net *net) | |||
3221 | { | 3223 | { |
3222 | get_random_bytes(&net->ipv4.rt_genid, | 3224 | get_random_bytes(&net->ipv4.rt_genid, |
3223 | sizeof(net->ipv4.rt_genid)); | 3225 | sizeof(net->ipv4.rt_genid)); |
3226 | get_random_bytes(&net->ipv4.dev_addr_genid, | ||
3227 | sizeof(net->ipv4.dev_addr_genid)); | ||
3224 | return 0; | 3228 | return 0; |
3225 | } | 3229 | } |
3226 | 3230 | ||