Lines 85-90
Link Here
|
85 |
#include <linux/mroute.h> |
85 |
#include <linux/mroute.h> |
86 |
#include <linux/netfilter_ipv4.h> |
86 |
#include <linux/netfilter_ipv4.h> |
87 |
#include <linux/random.h> |
87 |
#include <linux/random.h> |
|
|
88 |
#include <linux/jhash.h> |
88 |
#include <net/protocol.h> |
89 |
#include <net/protocol.h> |
89 |
#include <net/ip.h> |
90 |
#include <net/ip.h> |
90 |
#include <net/route.h> |
91 |
#include <net/route.h> |
Lines 117-129
Link Here
|
117 |
int ip_rt_mtu_expires = 10 * 60 * HZ; |
118 |
int ip_rt_mtu_expires = 10 * 60 * HZ; |
118 |
int ip_rt_min_pmtu = 512 + 20 + 20; |
119 |
int ip_rt_min_pmtu = 512 + 20 + 20; |
119 |
int ip_rt_min_advmss = 256; |
120 |
int ip_rt_min_advmss = 256; |
120 |
|
121 |
int ip_rt_secret_interval = 10 * 60 * HZ; |
121 |
static unsigned long rt_deadline; |
122 |
static unsigned long rt_deadline; |
122 |
|
123 |
|
123 |
#define RTprint(a...) printk(KERN_DEBUG a) |
124 |
#define RTprint(a...) printk(KERN_DEBUG a) |
124 |
|
125 |
|
125 |
static struct timer_list rt_flush_timer; |
126 |
static struct timer_list rt_flush_timer; |
126 |
static struct timer_list rt_periodic_timer; |
127 |
static struct timer_list rt_periodic_timer; |
|
|
128 |
static struct timer_list rt_secret_timer; |
127 |
|
129 |
|
128 |
/* |
130 |
/* |
129 |
* Interface to generic destination cache. |
131 |
* Interface to generic destination cache. |
Lines 194-212
Link Here
|
194 |
static struct rt_hash_bucket *rt_hash_table; |
196 |
static struct rt_hash_bucket *rt_hash_table; |
195 |
static unsigned rt_hash_mask; |
197 |
static unsigned rt_hash_mask; |
196 |
static int rt_hash_log; |
198 |
static int rt_hash_log; |
|
|
199 |
static unsigned int rt_hash_rnd; |
197 |
|
200 |
|
198 |
struct rt_cache_stat rt_cache_stat[NR_CPUS]; |
201 |
struct rt_cache_stat rt_cache_stat[NR_CPUS]; |
199 |
|
202 |
|
200 |
static int rt_intern_hash(unsigned hash, struct rtable *rth, |
203 |
static int rt_intern_hash(unsigned hash, struct rtable *rth, |
201 |
struct rtable **res); |
204 |
struct rtable **res); |
202 |
|
205 |
|
203 |
static __inline__ unsigned rt_hash_code(u32 daddr, u32 saddr, u8 tos) |
206 |
static unsigned int rt_hash_code(u32 daddr, u32 saddr, u8 tos) |
204 |
{ |
207 |
{ |
205 |
unsigned hash = ((daddr & 0xF0F0F0F0) >> 4) | |
208 |
return (jenkins_hash_3words(daddr, saddr, (u32) tos, rt_hash_rnd) |
206 |
((daddr & 0x0F0F0F0F) << 4); |
209 |
& rt_hash_mask); |
207 |
hash ^= saddr ^ tos; |
|
|
208 |
hash ^= (hash >> 16); |
209 |
return (hash ^ (hash >> 8)) & rt_hash_mask; |
210 |
} |
210 |
} |
211 |
|
211 |
|
212 |
static int rt_cache_get_info(char *buffer, char **start, off_t offset, |
212 |
static int rt_cache_get_info(char *buffer, char **start, off_t offset, |
Lines 479-484
Link Here
|
479 |
spin_unlock_bh(&rt_flush_lock); |
479 |
spin_unlock_bh(&rt_flush_lock); |
480 |
} |
480 |
} |
481 |
|
481 |
|
|
|
482 |
static void rt_secret_rebuild(unsigned long dummy) |
483 |
{ |
484 |
unsigned long now = jiffies; |
485 |
|
486 |
get_random_bytes(&rt_hash_rnd, 4); |
487 |
rt_cache_flush(0); |
488 |
mod_timer(&rt_secret_timer, now + ip_rt_secret_interval); |
489 |
} |
490 |
|
482 |
/* |
491 |
/* |
483 |
Short description of GC goals. |
492 |
Short description of GC goals. |
484 |
|
493 |
|
Lines 2414-2419
Link Here
|
2414 |
mode: 0644, |
2423 |
mode: 0644, |
2415 |
proc_handler: &proc_dointvec, |
2424 |
proc_handler: &proc_dointvec, |
2416 |
}, |
2425 |
}, |
|
|
2426 |
{ |
2427 |
ctl_name: NET_IPV4_ROUTE_SECRET_INTERVAL, |
2428 |
procname: "secret_interval", |
2429 |
data: &ip_rt_secret_interval, |
2430 |
maxlen: sizeof(int), |
2431 |
mode: 0644, |
2432 |
proc_handler: &proc_dointvec_jiffies, |
2433 |
strategy: &sysctl_jiffies, |
2434 |
}, |
2417 |
{ 0 } |
2435 |
{ 0 } |
2418 |
}; |
2436 |
}; |
2419 |
#endif |
2437 |
#endif |
Lines 2444-2458
Link Here
|
2444 |
*eof = 1; |
2462 |
*eof = 1; |
2445 |
} |
2463 |
} |
2446 |
|
2464 |
|
2447 |
/* Copy first cpu. */ |
2465 |
offset /= sizeof(u32); |
2448 |
*start = buffer; |
2466 |
|
2449 |
memcpy(buffer, IP_RT_ACCT_CPU(0), length); |
2467 |
if (length > 0) { |
2450 |
|
2468 |
u32 *src = ((u32 *) IP_RT_ACCT_CPU(0)) + offset; |
2451 |
/* Add the other cpus in, one int at a time */ |
2469 |
u32 *dst = (u32 *) buffer; |
2452 |
for (i = 1; i < smp_num_cpus; i++) { |
2470 |
|
2453 |
unsigned int j; |
2471 |
/* Copy first cpu. */ |
2454 |
for (j = 0; j < length/4; j++) |
2472 |
*start = buffer; |
2455 |
((u32*)buffer)[j] += ((u32*)IP_RT_ACCT_CPU(i))[j]; |
2473 |
memcpy(dst, src, length); |
|
|
2474 |
|
2475 |
/* Add the other cpus in, one int at a time */ |
2476 |
for (i = 1; i < smp_num_cpus; i++) { |
2477 |
unsigned int j; |
2478 |
|
2479 |
src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset; |
2480 |
|
2481 |
for (j = 0; j < length/4; j++) |
2482 |
dst[j] += src[j]; |
2483 |
} |
2456 |
} |
2484 |
} |
2457 |
return length; |
2485 |
return length; |
2458 |
} |
2486 |
} |
Lines 2462-2467
Link Here
|
2462 |
{ |
2490 |
{ |
2463 |
int i, order, goal; |
2491 |
int i, order, goal; |
2464 |
|
2492 |
|
|
|
2493 |
rt_hash_rnd = (int) ((num_physpages ^ (num_physpages>>8)) ^ |
2494 |
(jiffies ^ (jiffies >> 7))); |
2495 |
|
2465 |
#ifdef CONFIG_NET_CLS_ROUTE |
2496 |
#ifdef CONFIG_NET_CLS_ROUTE |
2466 |
for (order = 0; |
2497 |
for (order = 0; |
2467 |
(PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++) |
2498 |
(PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++) |
Lines 2518-2523
Link Here
|
2518 |
|
2549 |
|
2519 |
rt_flush_timer.function = rt_run_flush; |
2550 |
rt_flush_timer.function = rt_run_flush; |
2520 |
rt_periodic_timer.function = rt_check_expire; |
2551 |
rt_periodic_timer.function = rt_check_expire; |
|
|
2552 |
rt_secret_timer.function = rt_secret_rebuild; |
2521 |
|
2553 |
|
2522 |
/* All the timers, started at system startup tend |
2554 |
/* All the timers, started at system startup tend |
2523 |
to synchronize. Perturb it a bit. |
2555 |
to synchronize. Perturb it a bit. |
Lines 2525-2530
Link Here
|
2525 |
rt_periodic_timer.expires = jiffies + net_random() % ip_rt_gc_interval + |
2557 |
rt_periodic_timer.expires = jiffies + net_random() % ip_rt_gc_interval + |
2526 |
ip_rt_gc_interval; |
2558 |
ip_rt_gc_interval; |
2527 |
add_timer(&rt_periodic_timer); |
2559 |
add_timer(&rt_periodic_timer); |
|
|
2560 |
|
2561 |
rt_secret_timer.expires = jiffies + net_random() % ip_rt_secret_interval + |
2562 |
ip_rt_secret_interval; |
2563 |
add_timer(&rt_secret_timer); |
2528 |
|
2564 |
|
2529 |
proc_net_create ("rt_cache", 0, rt_cache_get_info); |
2565 |
proc_net_create ("rt_cache", 0, rt_cache_get_info); |
2530 |
proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info); |
2566 |
proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info); |