netfilter: Remove unnecessary OOM logging messages
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / netfilter / ipvs / ip_vs_lblcr.c
blobeec797f8cce705a1676caeb3c3078053ddcdf523
1 /*
2 * IPVS: Locality-Based Least-Connection with Replication scheduler
4 * Authors: Wensong Zhang <wensong@gnuchina.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
11 * Changes:
12 * Julian Anastasov : Added the missing (dest->weight>0)
13 * condition in the ip_vs_dest_set_max.
18 * The lblc/r algorithm is as follows (pseudo code):
20 * if serverSet[dest_ip] is null then
21 * n, serverSet[dest_ip] <- {weighted least-conn node};
22 * else
23 * n <- {least-conn (alive) node in serverSet[dest_ip]};
24 * if (n is null) OR
25 * (n.conns>n.weight AND
26 * there is a node m with m.conns<m.weight/2) then
27 * n <- {weighted least-conn node};
28 * add n to serverSet[dest_ip];
29 * if |serverSet[dest_ip]| > 1 AND
30 * now - serverSet[dest_ip].lastMod > T then
31 * m <- {most conn node in serverSet[dest_ip]};
32 * remove m from serverSet[dest_ip];
33 * if serverSet[dest_ip] changed then
34 * serverSet[dest_ip].lastMod <- now;
36 * return n;
40 #define KMSG_COMPONENT "IPVS"
41 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
43 #include <linux/ip.h>
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/skbuff.h>
47 #include <linux/jiffies.h>
48 #include <linux/list.h>
49 #include <linux/slab.h>
51 /* for sysctl */
52 #include <linux/fs.h>
53 #include <linux/sysctl.h>
54 #include <net/net_namespace.h>
56 #include <net/ip_vs.h>
60 * It is for garbage collection of stale IPVS lblcr entries,
61 * when the table is full.
63 #define CHECK_EXPIRE_INTERVAL (60*HZ)
64 #define ENTRY_TIMEOUT (6*60*HZ)
66 #define DEFAULT_EXPIRATION (24*60*60*HZ)
69 * It is for full expiration check.
70 * When there is no partial expiration check (garbage collection)
71 * in a half hour, do a full expiration check to collect stale
72 * entries that haven't been touched for a day.
74 #define COUNT_FOR_FULL_EXPIRATION 30
77 * for IPVS lblcr entry hash table
79 #ifndef CONFIG_IP_VS_LBLCR_TAB_BITS
80 #define CONFIG_IP_VS_LBLCR_TAB_BITS 10
81 #endif
82 #define IP_VS_LBLCR_TAB_BITS CONFIG_IP_VS_LBLCR_TAB_BITS
83 #define IP_VS_LBLCR_TAB_SIZE (1 << IP_VS_LBLCR_TAB_BITS)
84 #define IP_VS_LBLCR_TAB_MASK (IP_VS_LBLCR_TAB_SIZE - 1)
88 * IPVS destination set structure and operations
90 struct ip_vs_dest_set_elem {
91 struct list_head list; /* list link */
92 struct ip_vs_dest *dest; /* destination server */
95 struct ip_vs_dest_set {
96 atomic_t size; /* set size */
97 unsigned long lastmod; /* last modified time */
98 struct list_head list; /* destination list */
99 rwlock_t lock; /* lock for this list */
103 static struct ip_vs_dest_set_elem *
104 ip_vs_dest_set_insert(struct ip_vs_dest_set *set, struct ip_vs_dest *dest)
106 struct ip_vs_dest_set_elem *e;
108 list_for_each_entry(e, &set->list, list) {
109 if (e->dest == dest)
110 /* already existed */
111 return NULL;
114 e = kmalloc(sizeof(*e), GFP_ATOMIC);
115 if (e == NULL)
116 return NULL;
118 atomic_inc(&dest->refcnt);
119 e->dest = dest;
121 list_add(&e->list, &set->list);
122 atomic_inc(&set->size);
124 set->lastmod = jiffies;
125 return e;
128 static void
129 ip_vs_dest_set_erase(struct ip_vs_dest_set *set, struct ip_vs_dest *dest)
131 struct ip_vs_dest_set_elem *e;
133 list_for_each_entry(e, &set->list, list) {
134 if (e->dest == dest) {
135 /* HIT */
136 atomic_dec(&set->size);
137 set->lastmod = jiffies;
138 atomic_dec(&e->dest->refcnt);
139 list_del(&e->list);
140 kfree(e);
141 break;
146 static void ip_vs_dest_set_eraseall(struct ip_vs_dest_set *set)
148 struct ip_vs_dest_set_elem *e, *ep;
150 write_lock(&set->lock);
151 list_for_each_entry_safe(e, ep, &set->list, list) {
153 * We don't kfree dest because it is referred either
154 * by its service or by the trash dest list.
156 atomic_dec(&e->dest->refcnt);
157 list_del(&e->list);
158 kfree(e);
160 write_unlock(&set->lock);
163 /* get weighted least-connection node in the destination set */
164 static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set)
166 register struct ip_vs_dest_set_elem *e;
167 struct ip_vs_dest *dest, *least;
168 int loh, doh;
170 if (set == NULL)
171 return NULL;
173 /* select the first destination server, whose weight > 0 */
174 list_for_each_entry(e, &set->list, list) {
175 least = e->dest;
176 if (least->flags & IP_VS_DEST_F_OVERLOAD)
177 continue;
179 if ((atomic_read(&least->weight) > 0)
180 && (least->flags & IP_VS_DEST_F_AVAILABLE)) {
181 loh = ip_vs_dest_conn_overhead(least);
182 goto nextstage;
185 return NULL;
187 /* find the destination with the weighted least load */
188 nextstage:
189 list_for_each_entry(e, &set->list, list) {
190 dest = e->dest;
191 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
192 continue;
194 doh = ip_vs_dest_conn_overhead(dest);
195 if ((loh * atomic_read(&dest->weight) >
196 doh * atomic_read(&least->weight))
197 && (dest->flags & IP_VS_DEST_F_AVAILABLE)) {
198 least = dest;
199 loh = doh;
203 IP_VS_DBG_BUF(6, "%s(): server %s:%d "
204 "activeconns %d refcnt %d weight %d overhead %d\n",
205 __func__,
206 IP_VS_DBG_ADDR(least->af, &least->addr),
207 ntohs(least->port),
208 atomic_read(&least->activeconns),
209 atomic_read(&least->refcnt),
210 atomic_read(&least->weight), loh);
211 return least;
215 /* get weighted most-connection node in the destination set */
216 static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
218 register struct ip_vs_dest_set_elem *e;
219 struct ip_vs_dest *dest, *most;
220 int moh, doh;
222 if (set == NULL)
223 return NULL;
225 /* select the first destination server, whose weight > 0 */
226 list_for_each_entry(e, &set->list, list) {
227 most = e->dest;
228 if (atomic_read(&most->weight) > 0) {
229 moh = ip_vs_dest_conn_overhead(most);
230 goto nextstage;
233 return NULL;
235 /* find the destination with the weighted most load */
236 nextstage:
237 list_for_each_entry(e, &set->list, list) {
238 dest = e->dest;
239 doh = ip_vs_dest_conn_overhead(dest);
240 /* moh/mw < doh/dw ==> moh*dw < doh*mw, where mw,dw>0 */
241 if ((moh * atomic_read(&dest->weight) <
242 doh * atomic_read(&most->weight))
243 && (atomic_read(&dest->weight) > 0)) {
244 most = dest;
245 moh = doh;
249 IP_VS_DBG_BUF(6, "%s(): server %s:%d "
250 "activeconns %d refcnt %d weight %d overhead %d\n",
251 __func__,
252 IP_VS_DBG_ADDR(most->af, &most->addr), ntohs(most->port),
253 atomic_read(&most->activeconns),
254 atomic_read(&most->refcnt),
255 atomic_read(&most->weight), moh);
256 return most;
261 * IPVS lblcr entry represents an association between destination
262 * IP address and its destination server set
264 struct ip_vs_lblcr_entry {
265 struct list_head list;
266 int af; /* address family */
267 union nf_inet_addr addr; /* destination IP address */
268 struct ip_vs_dest_set set; /* destination server set */
269 unsigned long lastuse; /* last used time */
274 * IPVS lblcr hash table
276 struct ip_vs_lblcr_table {
277 struct list_head bucket[IP_VS_LBLCR_TAB_SIZE]; /* hash bucket */
278 atomic_t entries; /* number of entries */
279 int max_size; /* maximum size of entries */
280 struct timer_list periodic_timer; /* collect stale entries */
281 int rover; /* rover for expire check */
282 int counter; /* counter for no expire */
286 #ifdef CONFIG_SYSCTL
288 * IPVS LBLCR sysctl table
291 static ctl_table vs_vars_table[] = {
293 .procname = "lblcr_expiration",
294 .data = NULL,
295 .maxlen = sizeof(int),
296 .mode = 0644,
297 .proc_handler = proc_dointvec_jiffies,
301 #endif
303 static inline void ip_vs_lblcr_free(struct ip_vs_lblcr_entry *en)
305 list_del(&en->list);
306 ip_vs_dest_set_eraseall(&en->set);
307 kfree(en);
312 * Returns hash value for IPVS LBLCR entry
314 static inline unsigned
315 ip_vs_lblcr_hashkey(int af, const union nf_inet_addr *addr)
317 __be32 addr_fold = addr->ip;
319 #ifdef CONFIG_IP_VS_IPV6
320 if (af == AF_INET6)
321 addr_fold = addr->ip6[0]^addr->ip6[1]^
322 addr->ip6[2]^addr->ip6[3];
323 #endif
324 return (ntohl(addr_fold)*2654435761UL) & IP_VS_LBLCR_TAB_MASK;
329 * Hash an entry in the ip_vs_lblcr_table.
330 * returns bool success.
332 static void
333 ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en)
335 unsigned hash = ip_vs_lblcr_hashkey(en->af, &en->addr);
337 list_add(&en->list, &tbl->bucket[hash]);
338 atomic_inc(&tbl->entries);
343 * Get ip_vs_lblcr_entry associated with supplied parameters. Called under
344 * read lock.
346 static inline struct ip_vs_lblcr_entry *
347 ip_vs_lblcr_get(int af, struct ip_vs_lblcr_table *tbl,
348 const union nf_inet_addr *addr)
350 unsigned hash = ip_vs_lblcr_hashkey(af, addr);
351 struct ip_vs_lblcr_entry *en;
353 list_for_each_entry(en, &tbl->bucket[hash], list)
354 if (ip_vs_addr_equal(af, &en->addr, addr))
355 return en;
357 return NULL;
362 * Create or update an ip_vs_lblcr_entry, which is a mapping of a destination
363 * IP address to a server. Called under write lock.
365 static inline struct ip_vs_lblcr_entry *
366 ip_vs_lblcr_new(struct ip_vs_lblcr_table *tbl, const union nf_inet_addr *daddr,
367 struct ip_vs_dest *dest)
369 struct ip_vs_lblcr_entry *en;
371 en = ip_vs_lblcr_get(dest->af, tbl, daddr);
372 if (!en) {
373 en = kmalloc(sizeof(*en), GFP_ATOMIC);
374 if (!en)
375 return NULL;
377 en->af = dest->af;
378 ip_vs_addr_copy(dest->af, &en->addr, daddr);
379 en->lastuse = jiffies;
381 /* initialize its dest set */
382 atomic_set(&(en->set.size), 0);
383 INIT_LIST_HEAD(&en->set.list);
384 rwlock_init(&en->set.lock);
386 ip_vs_lblcr_hash(tbl, en);
389 write_lock(&en->set.lock);
390 ip_vs_dest_set_insert(&en->set, dest);
391 write_unlock(&en->set.lock);
393 return en;
398 * Flush all the entries of the specified table.
400 static void ip_vs_lblcr_flush(struct ip_vs_lblcr_table *tbl)
402 int i;
403 struct ip_vs_lblcr_entry *en, *nxt;
405 /* No locking required, only called during cleanup. */
406 for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) {
407 list_for_each_entry_safe(en, nxt, &tbl->bucket[i], list) {
408 ip_vs_lblcr_free(en);
413 static int sysctl_lblcr_expiration(struct ip_vs_service *svc)
415 #ifdef CONFIG_SYSCTL
416 struct netns_ipvs *ipvs = net_ipvs(svc->net);
417 return ipvs->sysctl_lblcr_expiration;
418 #else
419 return DEFAULT_EXPIRATION;
420 #endif
423 static inline void ip_vs_lblcr_full_check(struct ip_vs_service *svc)
425 struct ip_vs_lblcr_table *tbl = svc->sched_data;
426 unsigned long now = jiffies;
427 int i, j;
428 struct ip_vs_lblcr_entry *en, *nxt;
430 for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) {
431 j = (j + 1) & IP_VS_LBLCR_TAB_MASK;
433 write_lock(&svc->sched_lock);
434 list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
435 if (time_after(en->lastuse +
436 sysctl_lblcr_expiration(svc), now))
437 continue;
439 ip_vs_lblcr_free(en);
440 atomic_dec(&tbl->entries);
442 write_unlock(&svc->sched_lock);
444 tbl->rover = j;
449 * Periodical timer handler for IPVS lblcr table
450 * It is used to collect stale entries when the number of entries
451 * exceeds the maximum size of the table.
453 * Fixme: we probably need more complicated algorithm to collect
454 * entries that have not been used for a long time even
455 * if the number of entries doesn't exceed the maximum size
456 * of the table.
457 * The full expiration check is for this purpose now.
459 static void ip_vs_lblcr_check_expire(unsigned long data)
461 struct ip_vs_service *svc = (struct ip_vs_service *) data;
462 struct ip_vs_lblcr_table *tbl = svc->sched_data;
463 unsigned long now = jiffies;
464 int goal;
465 int i, j;
466 struct ip_vs_lblcr_entry *en, *nxt;
468 if ((tbl->counter % COUNT_FOR_FULL_EXPIRATION) == 0) {
469 /* do full expiration check */
470 ip_vs_lblcr_full_check(svc);
471 tbl->counter = 1;
472 goto out;
475 if (atomic_read(&tbl->entries) <= tbl->max_size) {
476 tbl->counter++;
477 goto out;
480 goal = (atomic_read(&tbl->entries) - tbl->max_size)*4/3;
481 if (goal > tbl->max_size/2)
482 goal = tbl->max_size/2;
484 for (i=0, j=tbl->rover; i<IP_VS_LBLCR_TAB_SIZE; i++) {
485 j = (j + 1) & IP_VS_LBLCR_TAB_MASK;
487 write_lock(&svc->sched_lock);
488 list_for_each_entry_safe(en, nxt, &tbl->bucket[j], list) {
489 if (time_before(now, en->lastuse+ENTRY_TIMEOUT))
490 continue;
492 ip_vs_lblcr_free(en);
493 atomic_dec(&tbl->entries);
494 goal--;
496 write_unlock(&svc->sched_lock);
497 if (goal <= 0)
498 break;
500 tbl->rover = j;
502 out:
503 mod_timer(&tbl->periodic_timer, jiffies+CHECK_EXPIRE_INTERVAL);
506 static int ip_vs_lblcr_init_svc(struct ip_vs_service *svc)
508 int i;
509 struct ip_vs_lblcr_table *tbl;
512 * Allocate the ip_vs_lblcr_table for this service
514 tbl = kmalloc(sizeof(*tbl), GFP_ATOMIC);
515 if (tbl == NULL)
516 return -ENOMEM;
518 svc->sched_data = tbl;
519 IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) allocated for "
520 "current service\n", sizeof(*tbl));
523 * Initialize the hash buckets
525 for (i=0; i<IP_VS_LBLCR_TAB_SIZE; i++) {
526 INIT_LIST_HEAD(&tbl->bucket[i]);
528 tbl->max_size = IP_VS_LBLCR_TAB_SIZE*16;
529 tbl->rover = 0;
530 tbl->counter = 1;
533 * Hook periodic timer for garbage collection
535 setup_timer(&tbl->periodic_timer, ip_vs_lblcr_check_expire,
536 (unsigned long)svc);
537 mod_timer(&tbl->periodic_timer, jiffies + CHECK_EXPIRE_INTERVAL);
539 return 0;
543 static int ip_vs_lblcr_done_svc(struct ip_vs_service *svc)
545 struct ip_vs_lblcr_table *tbl = svc->sched_data;
547 /* remove periodic timer */
548 del_timer_sync(&tbl->periodic_timer);
550 /* got to clean up table entries here */
551 ip_vs_lblcr_flush(tbl);
553 /* release the table itself */
554 kfree(tbl);
555 IP_VS_DBG(6, "LBLCR hash table (memory=%Zdbytes) released\n",
556 sizeof(*tbl));
558 return 0;
562 static inline struct ip_vs_dest *
563 __ip_vs_lblcr_schedule(struct ip_vs_service *svc)
565 struct ip_vs_dest *dest, *least;
566 int loh, doh;
569 * We use the following formula to estimate the load:
570 * (dest overhead) / dest->weight
572 * Remember -- no floats in kernel mode!!!
573 * The comparison of h1*w2 > h2*w1 is equivalent to that of
574 * h1/w1 > h2/w2
575 * if every weight is larger than zero.
577 * The server with weight=0 is quiesced and will not receive any
578 * new connection.
580 list_for_each_entry(dest, &svc->destinations, n_list) {
581 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
582 continue;
584 if (atomic_read(&dest->weight) > 0) {
585 least = dest;
586 loh = ip_vs_dest_conn_overhead(least);
587 goto nextstage;
590 return NULL;
593 * Find the destination with the least load.
595 nextstage:
596 list_for_each_entry_continue(dest, &svc->destinations, n_list) {
597 if (dest->flags & IP_VS_DEST_F_OVERLOAD)
598 continue;
600 doh = ip_vs_dest_conn_overhead(dest);
601 if (loh * atomic_read(&dest->weight) >
602 doh * atomic_read(&least->weight)) {
603 least = dest;
604 loh = doh;
608 IP_VS_DBG_BUF(6, "LBLCR: server %s:%d "
609 "activeconns %d refcnt %d weight %d overhead %d\n",
610 IP_VS_DBG_ADDR(least->af, &least->addr),
611 ntohs(least->port),
612 atomic_read(&least->activeconns),
613 atomic_read(&least->refcnt),
614 atomic_read(&least->weight), loh);
616 return least;
621 * If this destination server is overloaded and there is a less loaded
622 * server, then return true.
624 static inline int
625 is_overloaded(struct ip_vs_dest *dest, struct ip_vs_service *svc)
627 if (atomic_read(&dest->activeconns) > atomic_read(&dest->weight)) {
628 struct ip_vs_dest *d;
630 list_for_each_entry(d, &svc->destinations, n_list) {
631 if (atomic_read(&d->activeconns)*2
632 < atomic_read(&d->weight)) {
633 return 1;
637 return 0;
642 * Locality-Based (weighted) Least-Connection scheduling
644 static struct ip_vs_dest *
645 ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
647 struct ip_vs_lblcr_table *tbl = svc->sched_data;
648 struct ip_vs_iphdr iph;
649 struct ip_vs_dest *dest = NULL;
650 struct ip_vs_lblcr_entry *en;
652 ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
654 IP_VS_DBG(6, "%s(): Scheduling...\n", __func__);
656 /* First look in our cache */
657 read_lock(&svc->sched_lock);
658 en = ip_vs_lblcr_get(svc->af, tbl, &iph.daddr);
659 if (en) {
660 /* We only hold a read lock, but this is atomic */
661 en->lastuse = jiffies;
663 /* Get the least loaded destination */
664 read_lock(&en->set.lock);
665 dest = ip_vs_dest_set_min(&en->set);
666 read_unlock(&en->set.lock);
668 /* More than one destination + enough time passed by, cleanup */
669 if (atomic_read(&en->set.size) > 1 &&
670 time_after(jiffies, en->set.lastmod +
671 sysctl_lblcr_expiration(svc))) {
672 struct ip_vs_dest *m;
674 write_lock(&en->set.lock);
675 m = ip_vs_dest_set_max(&en->set);
676 if (m)
677 ip_vs_dest_set_erase(&en->set, m);
678 write_unlock(&en->set.lock);
681 /* If the destination is not overloaded, use it */
682 if (dest && !is_overloaded(dest, svc)) {
683 read_unlock(&svc->sched_lock);
684 goto out;
687 /* The cache entry is invalid, time to schedule */
688 dest = __ip_vs_lblcr_schedule(svc);
689 if (!dest) {
690 ip_vs_scheduler_err(svc, "no destination available");
691 read_unlock(&svc->sched_lock);
692 return NULL;
695 /* Update our cache entry */
696 write_lock(&en->set.lock);
697 ip_vs_dest_set_insert(&en->set, dest);
698 write_unlock(&en->set.lock);
700 read_unlock(&svc->sched_lock);
702 if (dest)
703 goto out;
705 /* No cache entry, time to schedule */
706 dest = __ip_vs_lblcr_schedule(svc);
707 if (!dest) {
708 IP_VS_DBG(1, "no destination available\n");
709 return NULL;
712 /* If we fail to create a cache entry, we'll just use the valid dest */
713 write_lock(&svc->sched_lock);
714 ip_vs_lblcr_new(tbl, &iph.daddr, dest);
715 write_unlock(&svc->sched_lock);
717 out:
718 IP_VS_DBG_BUF(6, "LBLCR: destination IP address %s --> server %s:%d\n",
719 IP_VS_DBG_ADDR(svc->af, &iph.daddr),
720 IP_VS_DBG_ADDR(svc->af, &dest->addr), ntohs(dest->port));
722 return dest;
727 * IPVS LBLCR Scheduler structure
729 static struct ip_vs_scheduler ip_vs_lblcr_scheduler =
731 .name = "lblcr",
732 .refcnt = ATOMIC_INIT(0),
733 .module = THIS_MODULE,
734 .n_list = LIST_HEAD_INIT(ip_vs_lblcr_scheduler.n_list),
735 .init_service = ip_vs_lblcr_init_svc,
736 .done_service = ip_vs_lblcr_done_svc,
737 .schedule = ip_vs_lblcr_schedule,
741 * per netns init.
743 #ifdef CONFIG_SYSCTL
744 static int __net_init __ip_vs_lblcr_init(struct net *net)
746 struct netns_ipvs *ipvs = net_ipvs(net);
748 if (!net_eq(net, &init_net)) {
749 ipvs->lblcr_ctl_table = kmemdup(vs_vars_table,
750 sizeof(vs_vars_table),
751 GFP_KERNEL);
752 if (ipvs->lblcr_ctl_table == NULL)
753 return -ENOMEM;
754 } else
755 ipvs->lblcr_ctl_table = vs_vars_table;
756 ipvs->sysctl_lblcr_expiration = DEFAULT_EXPIRATION;
757 ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration;
759 ipvs->lblcr_ctl_header =
760 register_net_sysctl_table(net, net_vs_ctl_path,
761 ipvs->lblcr_ctl_table);
762 if (!ipvs->lblcr_ctl_header) {
763 if (!net_eq(net, &init_net))
764 kfree(ipvs->lblcr_ctl_table);
765 return -ENOMEM;
768 return 0;
771 static void __net_exit __ip_vs_lblcr_exit(struct net *net)
773 struct netns_ipvs *ipvs = net_ipvs(net);
775 unregister_net_sysctl_table(ipvs->lblcr_ctl_header);
777 if (!net_eq(net, &init_net))
778 kfree(ipvs->lblcr_ctl_table);
781 #else
783 static int __net_init __ip_vs_lblcr_init(struct net *net) { return 0; }
784 static void __net_exit __ip_vs_lblcr_exit(struct net *net) { }
786 #endif
788 static struct pernet_operations ip_vs_lblcr_ops = {
789 .init = __ip_vs_lblcr_init,
790 .exit = __ip_vs_lblcr_exit,
793 static int __init ip_vs_lblcr_init(void)
795 int ret;
797 ret = register_pernet_subsys(&ip_vs_lblcr_ops);
798 if (ret)
799 return ret;
801 ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
802 if (ret)
803 unregister_pernet_subsys(&ip_vs_lblcr_ops);
804 return ret;
807 static void __exit ip_vs_lblcr_cleanup(void)
809 unregister_ip_vs_scheduler(&ip_vs_lblcr_scheduler);
810 unregister_pernet_subsys(&ip_vs_lblcr_ops);
814 module_init(ip_vs_lblcr_init);
815 module_exit(ip_vs_lblcr_cleanup);
816 MODULE_LICENSE("GPL");