diff options
author | Simon Horman <horms@verge.net.au> | 2011-02-04 04:33:01 -0500 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2011-03-14 20:36:59 -0400 |
commit | b27d777ec54205eb56cf4e873d043a426881c629 (patch) | |
tree | 17f5e387077dae41c4dfa489452d306033ec008d /net/netfilter | |
parent | 8e1b0b1b560019cafebe45a7d9e6ec1122fedc7b (diff) |
IPVS: Conditinally use sysctl_lblc{r}_expiration
In preparation for not including sysctl_lblc{r}_expiration in
struct netns_ipvs when CONFIG_SYCTL is not defined.
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_lblc.c | 16 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_lblcr.c | 21 |
2 files changed, 28 insertions, 9 deletions
diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c index 6bf7a807649c..51a27f58030d 100644 --- a/net/netfilter/ipvs/ip_vs_lblc.c +++ b/net/netfilter/ipvs/ip_vs_lblc.c | |||
@@ -63,6 +63,8 @@ | |||
63 | #define CHECK_EXPIRE_INTERVAL (60*HZ) | 63 | #define CHECK_EXPIRE_INTERVAL (60*HZ) |
64 | #define ENTRY_TIMEOUT (6*60*HZ) | 64 | #define ENTRY_TIMEOUT (6*60*HZ) |
65 | 65 | ||
66 | #define DEFAULT_EXPIRATION (24*60*60*HZ) | ||
67 | |||
66 | /* | 68 | /* |
67 | * It is for full expiration check. | 69 | * It is for full expiration check. |
68 | * When there is no partial expiration check (garbage collection) | 70 | * When there is no partial expiration check (garbage collection) |
@@ -238,6 +240,15 @@ static void ip_vs_lblc_flush(struct ip_vs_lblc_table *tbl) | |||
238 | } | 240 | } |
239 | } | 241 | } |
240 | 242 | ||
243 | static int sysctl_lblc_expiration(struct ip_vs_service *svc) | ||
244 | { | ||
245 | #ifdef CONFIG_SYSCTL | ||
246 | struct netns_ipvs *ipvs = net_ipvs(svc->net); | ||
247 | return ipvs->sysctl_lblc_expiration; | ||
248 | #else | ||
249 | return DEFAULT_EXPIRATION; | ||
250 | #endif | ||
251 | } | ||
241 | 252 | ||
242 | static inline void ip_vs_lblc_full_check(struct ip_vs_service *svc) | 253 | static inline void ip_vs_lblc_full_check(struct ip_vs_service *svc) |
243 | { | 254 | { |
@@ -245,7 +256,6 @@ static inline void ip_vs_lblc_full_check(struct ip_vs_service *svc) | |||
245 | struct ip_vs_lblc_entry *en, *nxt; | 256 | struct ip_vs_lblc_entry *en, *nxt; |
246 | unsigned long now = jiffies; | 257 | unsigned long now = jiffies; |
247 | int i, j; | 258 | int i, j; |
248 | struct netns_ipvs *ipvs = net_ipvs(svc->net); | ||
249 | 259 | ||
250 | for (i=0, j=tbl->rover; i<IP_VS_LBLC_TAB_SIZE; i++) { | 260 | for (i=0, j=tbl->rover; i<IP_VS_LBLC_TAB_SIZE; i++) { |
251 | j = (j + 1) & IP_VS_LBLC_TAB_MASK; | 261 | j = (j + 1) & IP_VS_LBLC_TAB_MASK; |
@@ -254,7 +264,7 @@ static inline void ip_vs_lblc_full_check(struct ip_vs_service *svc) | |||
254 | list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) { | 264 | list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) { |
255 | if (time_before(now, | 265 | if (time_before(now, |
256 | en->lastuse + | 266 | en->lastuse + |
257 | ipvs->sysctl_lblc_expiration)) | 267 | sysctl_lblc_expiration(svc))) |
258 | continue; | 268 | continue; |
259 | 269 | ||
260 | ip_vs_lblc_free(en); | 270 | ip_vs_lblc_free(en); |
@@ -550,7 +560,7 @@ static int __net_init __ip_vs_lblc_init(struct net *net) | |||
550 | return -ENOMEM; | 560 | return -ENOMEM; |
551 | } else | 561 | } else |
552 | ipvs->lblc_ctl_table = vs_vars_table; | 562 | ipvs->lblc_ctl_table = vs_vars_table; |
553 | ipvs->sysctl_lblc_expiration = 24*60*60*HZ; | 563 | ipvs->sysctl_lblc_expiration = DEFAULT_EXPIRATION; |
554 | ipvs->lblc_ctl_table[0].data = &ipvs->sysctl_lblc_expiration; | 564 | ipvs->lblc_ctl_table[0].data = &ipvs->sysctl_lblc_expiration; |
555 | 565 | ||
556 | #ifdef CONFIG_SYSCTL | 566 | #ifdef CONFIG_SYSCTL |
diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c index 00631765b92a..7fb919061296 100644 --- a/net/netfilter/ipvs/ip_vs_lblcr.c +++ b/net/netfilter/ipvs/ip_vs_lblcr.c | |||
@@ -63,6 +63,8 @@ | |||
63 | #define CHECK_EXPIRE_INTERVAL (60*HZ) | 63 | #define CHECK_EXPIRE_INTERVAL (60*HZ) |
64 | #define ENTRY_TIMEOUT (6*60*HZ) | 64 | #define ENTRY_TIMEOUT (6*60*HZ) |
65 | 65 | ||
66 | #define DEFAULT_EXPIRATION (24*60*60*HZ) | ||
67 | |||
66 | /* | 68 | /* |
67 | * It is for full expiration check. | 69 | * It is for full expiration check. |
68 | * When there is no partial expiration check (garbage collection) | 70 | * When there is no partial expiration check (garbage collection) |
@@ -410,6 +412,15 @@ static void ip_vs_lblcr_flush(struct ip_vs_lblcr_table *tbl) | |||
410 | } | 412 | } |
411 | } | 413 | } |
412 | 414 | ||
415 | static int sysctl_lblcr_expiration(struct ip_vs_service *svc) | ||
416 | { | ||
417 | #ifdef CONFIG_SYSCTL | ||
418 | struct netns_ipvs *ipvs = net_ipvs(svc->net); | ||
419 | return ipvs->sysctl_lblcr_expiration; | ||
420 | #else | ||
421 | return DEFAULT_EXPIRATION; | ||
422 | #endif | ||
423 | } | ||
413 | 424 | ||
414 | static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc) | 425 | static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc) |
415 | { | 426 | { |
@@ -417,15 +428,14 @@ static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc) | |||
417 | unsigned long now = jiffies; | 428 | unsigned long now = jiffies; |
418 | int i, j; | 429 | int i, j; |
419 | struct ip_vs_lblcr_entry *en, *nxt; | 430 | struct ip_vs_lblcr_entry *en, *nxt; |
420 | struct netns_ipvs *ipvs = net_ipvs(svc->net); | ||
421 | 431 | ||
422 | for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) { | 432 | for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) { |
423 | j = (j + 1) & IP_VS_LBLCR_TAB_MASK; | 433 | j = (j + 1) & IP_VS_LBLCR_TAB_MASK; |
424 | 434 | ||
425 | write_lock(&svc->sched_lock); | 435 | write_lock(&svc->sched_lock); |
426 | list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) { | 436 | list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) { |
427 | if (time_after(en->lastuse | 437 | if (time_after(en->lastuse + |
428 | + ipvs->sysctl_lblcr_expiration, now)) | 438 | sysctl_lblcr_expiration(svc), now)) |
429 | continue; | 439 | continue; |
430 | 440 | ||
431 | ip_vs_lblcr_free(en); | 441 | ip_vs_lblcr_free(en); |
@@ -650,7 +660,6 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb) | |||
650 | read_lock(&svc->sched_lock); | 660 | read_lock(&svc->sched_lock); |
651 | en = ip_vs_lblcr_get(svc->af, tbl, &iph.daddr); | 661 | en = ip_vs_lblcr_get(svc->af, tbl, &iph.daddr); |
652 | if (en) { | 662 | if (en) { |
653 | struct netns_ipvs *ipvs = net_ipvs(svc->net); | ||
654 | /* We only hold a read lock, but this is atomic */ | 663 | /* We only hold a read lock, but this is atomic */ |
655 | en->lastuse = jiffies; | 664 | en->lastuse = jiffies; |
656 | 665 | ||
@@ -662,7 +671,7 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb) | |||
662 | /* More than one destination + enough time passed by, cleanup */ | 671 | /* More than one destination + enough time passed by, cleanup */ |
663 | if (atomic_read(&en->set.size) > 1 && | 672 | if (atomic_read(&en->set.size) > 1 && |
664 | time_after(jiffies, en->set.lastmod + | 673 | time_after(jiffies, en->set.lastmod + |
665 | ipvs->sysctl_lblcr_expiration)) { | 674 | sysctl_lblcr_expiration(svc))) { |
666 | struct ip_vs_dest *m; | 675 | struct ip_vs_dest *m; |
667 | 676 | ||
668 | write_lock(&en->set.lock); | 677 | write_lock(&en->set.lock); |
@@ -746,7 +755,7 @@ static int __net_init __ip_vs_lblcr_init(struct net *net) | |||
746 | return -ENOMEM; | 755 | return -ENOMEM; |
747 | } else | 756 | } else |
748 | ipvs->lblcr_ctl_table = vs_vars_table; | 757 | ipvs->lblcr_ctl_table = vs_vars_table; |
749 | ipvs->sysctl_lblcr_expiration = 24*60*60*HZ; | 758 | ipvs->sysctl_lblcr_expiration = DEFAULT_EXPIRATION; |
750 | ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration; | 759 | ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration; |
751 | 760 | ||
752 | #ifdef CONFIG_SYSCTL | 761 | #ifdef CONFIG_SYSCTL |