Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: remove ip_rt_secret timer (v4)

A while back there was a discussion regarding the rt_secret_interval timer.
Given that we've had the ability to do emergency route cache rebuilds for awhile
now, based on a statistical analysis of the various hash chain lengths in the
cache, the use of the flush timer is somewhat redundant. This patch removes the
rt_secret_interval sysctl, allowing us to rely solely on the statistical
analysis mechanism to determine the need for route cache flushes.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Neil Horman and committed by
David S. Miller
3ee94372 e0e33280

+8 -102
-1
include/net/netns/ipv4.h
··· 55 55 int sysctl_rt_cache_rebuild_count; 56 56 int current_rt_cache_rebuild_count; 57 57 58 - struct timer_list rt_secret_timer; 59 58 atomic_t rt_genid; 60 59 61 60 #ifdef CONFIG_IP_MROUTE
-1
kernel/sysctl_binary.c
··· 224 224 { CTL_INT, NET_IPV4_ROUTE_MTU_EXPIRES, "mtu_expires" }, 225 225 { CTL_INT, NET_IPV4_ROUTE_MIN_PMTU, "min_pmtu" }, 226 226 { CTL_INT, NET_IPV4_ROUTE_MIN_ADVMSS, "min_adv_mss" }, 227 - { CTL_INT, NET_IPV4_ROUTE_SECRET_INTERVAL, "secret_interval" }, 228 227 {} 229 228 }; 230 229
+8 -100
net/ipv4/route.c
··· 129 129 static int ip_rt_mtu_expires __read_mostly = 10 * 60 * HZ; 130 130 static int ip_rt_min_pmtu __read_mostly = 512 + 20 + 20; 131 131 static int ip_rt_min_advmss __read_mostly = 256; 132 - static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ; 133 132 static int rt_chain_length_max __read_mostly = 20; 134 133 135 134 static struct delayed_work expires_work; ··· 917 918 rt_do_flush(!in_softirq()); 918 919 } 919 920 920 - /* 921 - * We change rt_genid and let gc do the cleanup 922 - */ 923 - static void rt_secret_rebuild(unsigned long __net) 924 - { 925 - struct net *net = (struct net *)__net; 926 - rt_cache_invalidate(net); 927 - mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval); 928 - } 929 - 930 - static void rt_secret_rebuild_oneshot(struct net *net) 931 - { 932 - del_timer_sync(&net->ipv4.rt_secret_timer); 933 - rt_cache_invalidate(net); 934 - if (ip_rt_secret_interval) 935 - mod_timer(&net->ipv4.rt_secret_timer, jiffies + ip_rt_secret_interval); 936 - } 937 - 938 921 static void rt_emergency_hash_rebuild(struct net *net) 939 922 { 940 - if (net_ratelimit()) { 923 + if (net_ratelimit()) 941 924 printk(KERN_WARNING "Route hash chain too long!\n"); 942 - printk(KERN_WARNING "Adjust your secret_interval!\n"); 943 - } 944 - 945 - rt_secret_rebuild_oneshot(net); 925 + rt_cache_invalidate(net); 946 926 } 947 927 948 928 /* ··· 3079 3101 return -EINVAL; 3080 3102 } 3081 3103 3082 - static void rt_secret_reschedule(int old) 3083 - { 3084 - struct net *net; 3085 - int new = ip_rt_secret_interval; 3086 - int diff = new - old; 3087 - 3088 - if (!diff) 3089 - return; 3090 - 3091 - rtnl_lock(); 3092 - for_each_net(net) { 3093 - int deleted = del_timer_sync(&net->ipv4.rt_secret_timer); 3094 - long time; 3095 - 3096 - if (!new) 3097 - continue; 3098 - 3099 - if (deleted) { 3100 - time = net->ipv4.rt_secret_timer.expires - jiffies; 3101 - 3102 - if (time <= 0 || (time += diff) <= 0) 3103 - time = 0; 3104 - } else 3105 - time = new; 3106 - 3107 - mod_timer(&net->ipv4.rt_secret_timer, jiffies + time); 3108 - } 3109 - rtnl_unlock(); 3110 - } 3111 - 3112 - static int ipv4_sysctl_rt_secret_interval(ctl_table *ctl, int write, 3113 - void __user *buffer, size_t *lenp, 3114 - loff_t *ppos) 3115 - { 3116 - int old = ip_rt_secret_interval; 3117 - int ret = proc_dointvec_jiffies(ctl, write, buffer, lenp, ppos); 3118 - 3119 - rt_secret_reschedule(old); 3120 - 3121 - return ret; 3122 - } 3123 - 3124 3104 static ctl_table ipv4_route_table[] = { 3125 3105 { 3126 3106 .procname = "gc_thresh", ··· 3187 3251 .mode = 0644, 3188 3252 .proc_handler = proc_dointvec, 3189 3253 }, 3190 - { 3191 - .procname = "secret_interval", 3192 - .data = &ip_rt_secret_interval, 3193 - .maxlen = sizeof(int), 3194 - .mode = 0644, 3195 - .proc_handler = ipv4_sysctl_rt_secret_interval, 3196 - }, 3197 3254 { } 3198 3255 }; 3199 3256 ··· 3265 3336 }; 3266 3337 #endif 3267 3338 3268 - 3269 - static __net_init int rt_secret_timer_init(struct net *net) 3339 + static __net_init int rt_genid_init(struct net *net) 3270 3340 { 3271 - atomic_set(&net->ipv4.rt_genid, 3272 - (int) ((num_physpages ^ (num_physpages>>8)) ^ 3273 - (jiffies ^ (jiffies >> 7)))); 3274 - 3275 - net->ipv4.rt_secret_timer.function = rt_secret_rebuild; 3276 - net->ipv4.rt_secret_timer.data = (unsigned long)net; 3277 - init_timer_deferrable(&net->ipv4.rt_secret_timer); 3278 - 3279 - if (ip_rt_secret_interval) { 3280 - net->ipv4.rt_secret_timer.expires = 3281 - jiffies + net_random() % ip_rt_secret_interval + 3282 - ip_rt_secret_interval; 3283 - add_timer(&net->ipv4.rt_secret_timer); 3284 - } 3341 + get_random_bytes(&net->ipv4.rt_genid, 3342 + sizeof(net->ipv4.rt_genid)); 3285 3343 return 0; 3286 3344 } 3287 3345 3288 - static __net_exit void rt_secret_timer_exit(struct net *net) 3289 - { 3290 - del_timer_sync(&net->ipv4.rt_secret_timer); 3291 - } 3292 - 3293 - static __net_initdata struct pernet_operations rt_secret_timer_ops = { 3294 - .init = rt_secret_timer_init, 3295 - .exit = rt_secret_timer_exit, 3346 + static __net_initdata struct pernet_operations rt_genid_ops = { 3347 + .init = rt_genid_init, 3296 3348 }; 3297 3349 3298 3350 ··· 3334 3424 schedule_delayed_work(&expires_work, 3335 3425 net_random() % ip_rt_gc_interval + ip_rt_gc_interval); 3336 3426 3337 - if (register_pernet_subsys(&rt_secret_timer_ops)) 3338 - printk(KERN_ERR "Unable to setup rt_secret_timer\n"); 3339 - 3340 3427 if (ip_rt_proc_init()) 3341 3428 printk(KERN_ERR "Unable to create route proc files\n"); 3342 3429 #ifdef CONFIG_XFRM ··· 3345 3438 #ifdef CONFIG_SYSCTL 3346 3439 register_pernet_subsys(&sysctl_route_ops); 3347 3440 #endif 3441 + register_pernet_subsys(&rt_genid_ops); 3348 3442 return rc; 3349 3443 } 3350 3444