diff options
author | Neil Horman <nhorman@tuxdriver.com> | 2009-07-30 21:52:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-07-30 21:52:15 -0400 |
commit | a33bc5c15154c835aae26f16e6a3a7d9ad4acb45 (patch) | |
tree | cf7683b1b2d2fd170bfc6650ea84a4b9a81eebbf /net/ipv6/xfrm6_policy.c | |
parent | 9aada7ac047f789ffb27540cc1695989897b2dfe (diff) |
xfrm: select sane defaults for xfrm[4|6] gc_thresh
Choose saner defaults for xfrm[4|6] gc_thresh values on init
Currently, the xfrm[4|6] code has hard-coded initial gc_thresh values
(set to 1024). Given that the ipv4 and ipv6 routing caches are sized
dynamically at boot time, the static selections can be non-sensical.
This patch dynamically selects an appropriate gc threshold based on
the corresponding main routing table size, using the assumption that
we should in the worst case be able to handle as many connections as
the routing table can.
For ipv4, the maximum route cache size is 16 * the number of hash
buckets in the route cache. Given that xfrm4 starts garbage
collection at the gc_thresh and prevents new allocations at 2 *
gc_thresh, we set gc_thresh to half the maximum route cache size.
For ipv6, its a bit trickier. there is no maximum route cache size,
but the ipv6 dst_ops gc_thresh is statically set to 1024. It seems
sane to select a simmilar gc_thresh for the xfrm6 code that is half
the number of hash buckets in the v6 route cache times 16 (like the v4
code does).
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/xfrm6_policy.c')
-rw-r--r-- | net/ipv6/xfrm6_policy.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 4acc308eac7f..611cffcf554f 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -323,6 +323,7 @@ static struct ctl_table_header *sysctl_hdr; | |||
323 | int __init xfrm6_init(void) | 323 | int __init xfrm6_init(void) |
324 | { | 324 | { |
325 | int ret; | 325 | int ret; |
326 | unsigned int gc_thresh; | ||
326 | 327 | ||
327 | ret = xfrm6_policy_init(); | 328 | ret = xfrm6_policy_init(); |
328 | if (ret) | 329 | if (ret) |
@@ -331,6 +332,20 @@ int __init xfrm6_init(void) | |||
331 | ret = xfrm6_state_init(); | 332 | ret = xfrm6_state_init(); |
332 | if (ret) | 333 | if (ret) |
333 | goto out_policy; | 334 | goto out_policy; |
335 | /* | ||
336 | * We need a good default value for the xfrm6 gc threshold. | ||
337 | * In ipv4 we set it to the route hash table size * 8, which | ||
338 | * is half the size of the maximaum route cache for ipv4. It | ||
339 | * would be good to do the same thing for v6, except the table is | ||
340 | * constructed differently here. Here each table for a net namespace | ||
341 | * can have FIB_TABLE_HASHSZ entries, so lets go with the same | ||
342 | * computation that we used for ipv4 here. Also, lets keep the initial | ||
343 | * gc_thresh to a minimum of 1024, since, the ipv6 route cache defaults | ||
344 | * to that as a minimum as well | ||
345 | */ | ||
346 | gc_thresh = FIB6_TABLE_HASHSZ * 8; | ||
347 | xfrm6_dst_ops.gc_thresh = (gc_thresh < 1024) ? 1024 : gc_thresh; | ||
348 | |||
334 | sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv6_ctl_path, | 349 | sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv6_ctl_path, |
335 | xfrm6_policy_table); | 350 | xfrm6_policy_table); |
336 | out: | 351 | out: |