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.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index f6436d3b207a..be27cfa96e88 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -447,23 +447,9 @@ static inline bool rt_is_expired(const struct rtable *rth)
447 return rth->rt_genid != rt_genid(dev_net(rth->dst.dev)); 447 return rth->rt_genid != rt_genid(dev_net(rth->dst.dev));
448} 448}
449 449
450/*
451 * Perturbation of rt_genid by a small quantity [1..256]
452 * Using 8 bits of shuffling ensure we can call rt_cache_invalidate()
453 * many times (2^24) without giving recent rt_genid.
454 * Jenkins hash is strong enough that litle changes of rt_genid are OK.
455 */
456static void rt_cache_invalidate(struct net *net)
457{
458 unsigned char shuffle;
459
460 get_random_bytes(&shuffle, sizeof(shuffle));
461 atomic_add(shuffle + 1U, &net->ipv4.rt_genid);
462}
463
464void rt_cache_flush(struct net *net) 450void rt_cache_flush(struct net *net)
465{ 451{
466 rt_cache_invalidate(net); 452 atomic_inc(&net->ipv4.rt_genid);
467} 453}
468 454
469static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, 455static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst,
@@ -2520,8 +2506,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
2520 2506
2521static __net_init int rt_genid_init(struct net *net) 2507static __net_init int rt_genid_init(struct net *net)
2522{ 2508{
2523 get_random_bytes(&net->ipv4.rt_genid, 2509 atomic_set(&net->ipv4.rt_genid, 0);
2524 sizeof(net->ipv4.rt_genid));
2525 get_random_bytes(&net->ipv4.dev_addr_genid, 2510 get_random_bytes(&net->ipv4.dev_addr_genid,
2526 sizeof(net->ipv4.dev_addr_genid)); 2511 sizeof(net->ipv4.dev_addr_genid));
2527 return 0; 2512 return 0;