aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 870b5182ddd8..99e6e4bb1c72 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;
@@ -2688,6 +2690,12 @@ static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu)
2688{ 2690{
2689} 2691}
2690 2692
2693static u32 *ipv4_rt_blackhole_cow_metrics(struct dst_entry *dst,
2694 unsigned long old)
2695{
2696 return NULL;
2697}
2698
2691static struct dst_ops ipv4_dst_blackhole_ops = { 2699static struct dst_ops ipv4_dst_blackhole_ops = {
2692 .family = AF_INET, 2700 .family = AF_INET,
2693 .protocol = cpu_to_be16(ETH_P_IP), 2701 .protocol = cpu_to_be16(ETH_P_IP),
@@ -2696,6 +2704,7 @@ static struct dst_ops ipv4_dst_blackhole_ops = {
2696 .default_mtu = ipv4_blackhole_default_mtu, 2704 .default_mtu = ipv4_blackhole_default_mtu,
2697 .default_advmss = ipv4_default_advmss, 2705 .default_advmss = ipv4_default_advmss,
2698 .update_pmtu = ipv4_rt_blackhole_update_pmtu, 2706 .update_pmtu = ipv4_rt_blackhole_update_pmtu,
2707 .cow_metrics = ipv4_rt_blackhole_cow_metrics,
2699}; 2708};
2700 2709
2701struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig) 2710struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig)
@@ -2718,6 +2727,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
2718 rt->rt_key_dst = ort->rt_key_dst; 2727 rt->rt_key_dst = ort->rt_key_dst;
2719 rt->rt_key_src = ort->rt_key_src; 2728 rt->rt_key_src = ort->rt_key_src;
2720 rt->rt_tos = ort->rt_tos; 2729 rt->rt_tos = ort->rt_tos;
2730 rt->rt_route_iif = ort->rt_route_iif;
2721 rt->rt_iif = ort->rt_iif; 2731 rt->rt_iif = ort->rt_iif;
2722 rt->rt_oif = ort->rt_oif; 2732 rt->rt_oif = ort->rt_oif;
2723 rt->rt_mark = ort->rt_mark; 2733 rt->rt_mark = ort->rt_mark;
@@ -2727,7 +2737,6 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
2727 rt->rt_type = ort->rt_type; 2737 rt->rt_type = ort->rt_type;
2728 rt->rt_dst = ort->rt_dst; 2738 rt->rt_dst = ort->rt_dst;
2729 rt->rt_src = ort->rt_src; 2739 rt->rt_src = ort->rt_src;
2730 rt->rt_iif = ort->rt_iif;
2731 rt->rt_gateway = ort->rt_gateway; 2740 rt->rt_gateway = ort->rt_gateway;
2732 rt->rt_spec_dst = ort->rt_spec_dst; 2741 rt->rt_spec_dst = ort->rt_spec_dst;
2733 rt->peer = ort->peer; 2742 rt->peer = ort->peer;
@@ -3221,6 +3230,8 @@ static __net_init int rt_genid_init(struct net *net)
3221{ 3230{
3222 get_random_bytes(&net->ipv4.rt_genid, 3231 get_random_bytes(&net->ipv4.rt_genid,
3223 sizeof(net->ipv4.rt_genid)); 3232 sizeof(net->ipv4.rt_genid));
3233 get_random_bytes(&net->ipv4.dev_addr_genid,
3234 sizeof(net->ipv4.dev_addr_genid));
3224 return 0; 3235 return 0;
3225} 3236}
3226 3237