2 * IPVS An implementation of the IP virtual server support for the
3 * LINUX operating system. IPVS is now implemented as a module
4 * over the NetFilter framework. IPVS can be used to build a
5 * high-performance and highly available server based on a
8 * Authors: Wensong Zhang <wensong@linuxvirtualserver.org>
10 * ip_vs_sync: sync connection info from master load balancer to backups
14 * Alexandre Cassen : Added master & backup support at a time.
15 * Alexandre Cassen : Added SyncID support for incoming sync
17 * Justin Ossevoort : Fix endian problem on sync message size.
20 #include <linux/module.h>
21 #include <linux/slab.h>
22 #include <linux/inetdevice.h>
23 #include <linux/net.h>
24 #include <linux/completion.h>
25 #include <linux/delay.h>
26 #include <linux/skbuff.h>
28 #include <linux/igmp.h> /* for ip_mc_join_group */
29 #include <linux/udp.h>
30 #include <linux/err.h>
31 #include <linux/kthread.h>
32 #include <linux/wait.h>
37 #include <net/ip_vs.h>
39 #define IP_VS_SYNC_GROUP 0xe0000051 /* multicast addr - 224.0.0.81 */
40 #define IP_VS_SYNC_PORT 8848 /* multicast port */
44 * IPVS sync connection entry
46 struct ip_vs_sync_conn {
49 /* Protocol, addresses and port numbers */
50 __u8 protocol; /* Which protocol (TCP/UDP) */
54 __be32 caddr; /* client address */
55 __be32 vaddr; /* virtual address */
56 __be32 daddr; /* destination address */
58 /* Flags and state transition */
59 __be16 flags; /* status flags */
60 __be16 state; /* state info */
62 /* The sequence options start here */
65 struct ip_vs_sync_conn_options {
66 struct ip_vs_seq in_seq; /* incoming seq. struct */
67 struct ip_vs_seq out_seq; /* outgoing seq. struct */
70 struct ip_vs_sync_thread_data {
75 #define SIMPLE_CONN_SIZE (sizeof(struct ip_vs_sync_conn))
76 #define FULL_CONN_SIZE \
77 (sizeof(struct ip_vs_sync_conn) + sizeof(struct ip_vs_sync_conn_options))
81 The master mulitcasts messages to the backup load balancers in the
85 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
86 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87 | Count Conns | SyncID | Size |
88 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 | IPVS Sync Connection (1) |
91 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97 | IPVS Sync Connection (n) |
98 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
101 #define SYNC_MESG_HEADER_LEN 4
103 struct ip_vs_sync_mesg {
108 /* ip_vs_sync_conn entries start here */
111 /* the maximum length of sync (sending/receiving) message */
112 static int sync_send_mesg_maxlen;
113 static int sync_recv_mesg_maxlen;
115 struct ip_vs_sync_buff {
116 struct list_head list;
117 unsigned long firstuse;
119 /* pointers for the message data */
120 struct ip_vs_sync_mesg *mesg;
126 /* the sync_buff list head and the lock */
127 static LIST_HEAD(ip_vs_sync_queue);
128 static DEFINE_SPINLOCK(ip_vs_sync_lock);
130 /* current sync_buff for accepting new conn entries */
131 static struct ip_vs_sync_buff *curr_sb = NULL;
132 static DEFINE_SPINLOCK(curr_sb_lock);
134 /* ipvs sync daemon state */
135 volatile int ip_vs_sync_state = IP_VS_STATE_NONE;
136 volatile int ip_vs_master_syncid = 0;
137 volatile int ip_vs_backup_syncid = 0;
139 /* multicast interface name */
140 char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN];
141 char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN];
143 /* sync daemon tasks */
144 static struct task_struct *sync_master_thread;
145 static struct task_struct *sync_backup_thread;
148 static struct sockaddr_in mcast_addr = {
149 .sin_family = AF_INET,
150 .sin_port = __constant_htons(IP_VS_SYNC_PORT),
151 .sin_addr.s_addr = __constant_htonl(IP_VS_SYNC_GROUP),
155 static inline struct ip_vs_sync_buff *sb_dequeue(void)
157 struct ip_vs_sync_buff *sb;
159 spin_lock_bh(&ip_vs_sync_lock);
160 if (list_empty(&ip_vs_sync_queue)) {
163 sb = list_entry(ip_vs_sync_queue.next,
164 struct ip_vs_sync_buff,
168 spin_unlock_bh(&ip_vs_sync_lock);
173 static inline struct ip_vs_sync_buff * ip_vs_sync_buff_create(void)
175 struct ip_vs_sync_buff *sb;
177 if (!(sb=kmalloc(sizeof(struct ip_vs_sync_buff), GFP_ATOMIC)))
180 if (!(sb->mesg=kmalloc(sync_send_mesg_maxlen, GFP_ATOMIC))) {
184 sb->mesg->nr_conns = 0;
185 sb->mesg->syncid = ip_vs_master_syncid;
187 sb->head = (unsigned char *)sb->mesg + 4;
188 sb->end = (unsigned char *)sb->mesg + sync_send_mesg_maxlen;
189 sb->firstuse = jiffies;
193 static inline void ip_vs_sync_buff_release(struct ip_vs_sync_buff *sb)
199 static inline void sb_queue_tail(struct ip_vs_sync_buff *sb)
201 spin_lock(&ip_vs_sync_lock);
202 if (ip_vs_sync_state & IP_VS_STATE_MASTER)
203 list_add_tail(&sb->list, &ip_vs_sync_queue);
205 ip_vs_sync_buff_release(sb);
206 spin_unlock(&ip_vs_sync_lock);
210 * Get the current sync buffer if it has been created for more
211 * than the specified time or the specified time is zero.
213 static inline struct ip_vs_sync_buff *
214 get_curr_sync_buff(unsigned long time)
216 struct ip_vs_sync_buff *sb;
218 spin_lock_bh(&curr_sb_lock);
219 if (curr_sb && (time == 0 ||
220 time_before(jiffies - curr_sb->firstuse, time))) {
225 spin_unlock_bh(&curr_sb_lock);
231 * Add an ip_vs_conn information into the current sync_buff.
232 * Called by ip_vs_in.
234 void ip_vs_sync_conn(struct ip_vs_conn *cp)
236 struct ip_vs_sync_mesg *m;
237 struct ip_vs_sync_conn *s;
240 spin_lock(&curr_sb_lock);
242 if (!(curr_sb=ip_vs_sync_buff_create())) {
243 spin_unlock(&curr_sb_lock);
244 IP_VS_ERR("ip_vs_sync_buff_create failed.\n");
249 len = (cp->flags & IP_VS_CONN_F_SEQ_MASK) ? FULL_CONN_SIZE :
252 s = (struct ip_vs_sync_conn *)curr_sb->head;
255 s->protocol = cp->protocol;
256 s->cport = cp->cport;
257 s->vport = cp->vport;
258 s->dport = cp->dport;
259 s->caddr = cp->caddr;
260 s->vaddr = cp->vaddr;
261 s->daddr = cp->daddr;
262 s->flags = htons(cp->flags & ~IP_VS_CONN_F_HASHED);
263 s->state = htons(cp->state);
264 if (cp->flags & IP_VS_CONN_F_SEQ_MASK) {
265 struct ip_vs_sync_conn_options *opt =
266 (struct ip_vs_sync_conn_options *)&s[1];
267 memcpy(opt, &cp->in_seq, sizeof(*opt));
272 curr_sb->head += len;
274 /* check if there is a space for next one */
275 if (curr_sb->head+FULL_CONN_SIZE > curr_sb->end) {
276 sb_queue_tail(curr_sb);
279 spin_unlock(&curr_sb_lock);
281 /* synchronize its controller if it has */
283 ip_vs_sync_conn(cp->control);
288 * Process received multicast message and create the corresponding
289 * ip_vs_conn entries.
291 static void ip_vs_process_message(const char *buffer, const size_t buflen)
293 struct ip_vs_sync_mesg *m = (struct ip_vs_sync_mesg *)buffer;
294 struct ip_vs_sync_conn *s;
295 struct ip_vs_sync_conn_options *opt;
296 struct ip_vs_conn *cp;
297 struct ip_vs_protocol *pp;
298 struct ip_vs_dest *dest;
302 if (buflen < sizeof(struct ip_vs_sync_mesg)) {
303 IP_VS_ERR_RL("sync message header too short\n");
307 /* Convert size back to host byte order */
308 m->size = ntohs(m->size);
310 if (buflen != m->size) {
311 IP_VS_ERR_RL("bogus sync message size\n");
315 /* SyncID sanity check */
316 if (ip_vs_backup_syncid != 0 && m->syncid != ip_vs_backup_syncid) {
317 IP_VS_DBG(7, "Ignoring incoming msg with syncid = %d\n",
322 p = (char *)buffer + sizeof(struct ip_vs_sync_mesg);
323 for (i=0; i<m->nr_conns; i++) {
324 unsigned flags, state;
326 if (p + SIMPLE_CONN_SIZE > buffer+buflen) {
327 IP_VS_ERR_RL("bogus conn in sync message\n");
330 s = (struct ip_vs_sync_conn *) p;
331 flags = ntohs(s->flags) | IP_VS_CONN_F_SYNC;
332 flags &= ~IP_VS_CONN_F_HASHED;
333 if (flags & IP_VS_CONN_F_SEQ_MASK) {
334 opt = (struct ip_vs_sync_conn_options *)&s[1];
336 if (p > buffer+buflen) {
337 IP_VS_ERR_RL("bogus conn options in sync message\n");
342 p += SIMPLE_CONN_SIZE;
345 state = ntohs(s->state);
346 if (!(flags & IP_VS_CONN_F_TEMPLATE)) {
347 pp = ip_vs_proto_get(s->protocol);
349 IP_VS_ERR_RL("Unsupported protocol %u in sync msg\n",
353 if (state >= pp->num_states) {
354 IP_VS_DBG(2, "Invalid %s state %u in sync msg\n",
359 /* protocol in templates is not used for state/timeout */
362 IP_VS_DBG(2, "Invalid template state %u in sync msg\n",
368 if (!(flags & IP_VS_CONN_F_TEMPLATE))
369 cp = ip_vs_conn_in_get(s->protocol,
373 cp = ip_vs_ct_in_get(s->protocol,
378 * Find the appropriate destination for the connection.
379 * If it is not found the connection will remain unbound
382 dest = ip_vs_find_dest(s->daddr, s->dport,
385 /* Set the approprite ativity flag */
386 if (s->protocol == IPPROTO_TCP) {
387 if (state != IP_VS_TCP_S_ESTABLISHED)
388 flags |= IP_VS_CONN_F_INACTIVE;
390 flags &= ~IP_VS_CONN_F_INACTIVE;
392 cp = ip_vs_conn_new(s->protocol,
398 atomic_dec(&dest->refcnt);
400 IP_VS_ERR("ip_vs_conn_new failed\n");
403 } else if (!cp->dest) {
404 dest = ip_vs_try_bind_dest(cp);
406 atomic_dec(&dest->refcnt);
407 } else if ((cp->dest) && (cp->protocol == IPPROTO_TCP) &&
408 (cp->state != state)) {
409 /* update active/inactive flag for the connection */
411 if (!(cp->flags & IP_VS_CONN_F_INACTIVE) &&
412 (state != IP_VS_TCP_S_ESTABLISHED)) {
413 atomic_dec(&dest->activeconns);
414 atomic_inc(&dest->inactconns);
415 cp->flags |= IP_VS_CONN_F_INACTIVE;
416 } else if ((cp->flags & IP_VS_CONN_F_INACTIVE) &&
417 (state == IP_VS_TCP_S_ESTABLISHED)) {
418 atomic_inc(&dest->activeconns);
419 atomic_dec(&dest->inactconns);
420 cp->flags &= ~IP_VS_CONN_F_INACTIVE;
425 memcpy(&cp->in_seq, opt, sizeof(*opt));
426 atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]);
428 cp->old_state = cp->state;
430 * We can not recover the right timeout for templates
431 * in all cases, we can not find the right fwmark
432 * virtual service. If needed, we can do it for
433 * non-fwmark persistent services.
435 if (!(flags & IP_VS_CONN_F_TEMPLATE) && pp->timeout_table)
436 cp->timeout = pp->timeout_table[state];
438 cp->timeout = (3*60*HZ);
445 * Setup loopback of outgoing multicasts on a sending socket
447 static void set_mcast_loop(struct sock *sk, u_char loop)
449 struct inet_sock *inet = inet_sk(sk);
451 /* setsockopt(sock, SOL_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop)); */
453 inet->mc_loop = loop ? 1 : 0;
458 * Specify TTL for outgoing multicasts on a sending socket
460 static void set_mcast_ttl(struct sock *sk, u_char ttl)
462 struct inet_sock *inet = inet_sk(sk);
464 /* setsockopt(sock, SOL_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)); */
471 * Specifiy default interface for outgoing multicasts
473 static int set_mcast_if(struct sock *sk, char *ifname)
475 struct net_device *dev;
476 struct inet_sock *inet = inet_sk(sk);
478 if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
481 if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
485 inet->mc_index = dev->ifindex;
486 /* inet->mc_addr = 0; */
494 * Set the maximum length of sync message according to the
495 * specified interface's MTU.
497 static int set_sync_mesg_maxlen(int sync_state)
499 struct net_device *dev;
502 if (sync_state == IP_VS_STATE_MASTER) {
503 if ((dev = __dev_get_by_name(&init_net, ip_vs_master_mcast_ifn)) == NULL)
506 num = (dev->mtu - sizeof(struct iphdr) -
507 sizeof(struct udphdr) -
508 SYNC_MESG_HEADER_LEN - 20) / SIMPLE_CONN_SIZE;
509 sync_send_mesg_maxlen =
510 SYNC_MESG_HEADER_LEN + SIMPLE_CONN_SIZE * num;
511 IP_VS_DBG(7, "setting the maximum length of sync sending "
512 "message %d.\n", sync_send_mesg_maxlen);
513 } else if (sync_state == IP_VS_STATE_BACKUP) {
514 if ((dev = __dev_get_by_name(&init_net, ip_vs_backup_mcast_ifn)) == NULL)
517 sync_recv_mesg_maxlen = dev->mtu -
518 sizeof(struct iphdr) - sizeof(struct udphdr);
519 IP_VS_DBG(7, "setting the maximum length of sync receiving "
520 "message %d.\n", sync_recv_mesg_maxlen);
528 * Join a multicast group.
529 * the group is specified by a class D multicast address 224.0.0.0/8
530 * in the in_addr structure passed in as a parameter.
533 join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
535 struct ip_mreqn mreq;
536 struct net_device *dev;
539 memset(&mreq, 0, sizeof(mreq));
540 memcpy(&mreq.imr_multiaddr, addr, sizeof(struct in_addr));
542 if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
544 if (sk->sk_bound_dev_if && dev->ifindex != sk->sk_bound_dev_if)
547 mreq.imr_ifindex = dev->ifindex;
550 ret = ip_mc_join_group(sk, &mreq);
557 static int bind_mcastif_addr(struct socket *sock, char *ifname)
559 struct net_device *dev;
561 struct sockaddr_in sin;
563 if ((dev = __dev_get_by_name(&init_net, ifname)) == NULL)
566 addr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
568 IP_VS_ERR("You probably need to specify IP address on "
569 "multicast interface.\n");
571 IP_VS_DBG(7, "binding socket with (%s) %u.%u.%u.%u\n",
572 ifname, NIPQUAD(addr));
574 /* Now bind the socket with the address of multicast interface */
575 sin.sin_family = AF_INET;
576 sin.sin_addr.s_addr = addr;
579 return sock->ops->bind(sock, (struct sockaddr*)&sin, sizeof(sin));
583 * Set up sending multicast socket over UDP
585 static struct socket * make_send_sock(void)
590 /* First create a socket */
591 result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
593 IP_VS_ERR("Error during creation of socket; terminating\n");
594 return ERR_PTR(result);
597 result = set_mcast_if(sock->sk, ip_vs_master_mcast_ifn);
599 IP_VS_ERR("Error setting outbound mcast interface\n");
603 set_mcast_loop(sock->sk, 0);
604 set_mcast_ttl(sock->sk, 1);
606 result = bind_mcastif_addr(sock, ip_vs_master_mcast_ifn);
608 IP_VS_ERR("Error binding address of the mcast interface\n");
612 result = sock->ops->connect(sock, (struct sockaddr *) &mcast_addr,
613 sizeof(struct sockaddr), 0);
615 IP_VS_ERR("Error connecting to the multicast addr\n");
623 return ERR_PTR(result);
628 * Set up receiving multicast socket over UDP
630 static struct socket * make_receive_sock(void)
635 /* First create a socket */
636 result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
638 IP_VS_ERR("Error during creation of socket; terminating\n");
639 return ERR_PTR(result);
642 /* it is equivalent to the REUSEADDR option in user-space */
643 sock->sk->sk_reuse = 1;
645 result = sock->ops->bind(sock, (struct sockaddr *) &mcast_addr,
646 sizeof(struct sockaddr));
648 IP_VS_ERR("Error binding to the multicast addr\n");
652 /* join the multicast group */
653 result = join_mcast_group(sock->sk,
654 (struct in_addr *) &mcast_addr.sin_addr,
655 ip_vs_backup_mcast_ifn);
657 IP_VS_ERR("Error joining to the multicast group\n");
665 return ERR_PTR(result);
670 ip_vs_send_async(struct socket *sock, const char *buffer, const size_t length)
672 struct msghdr msg = {.msg_flags = MSG_DONTWAIT|MSG_NOSIGNAL};
677 iov.iov_base = (void *)buffer;
678 iov.iov_len = length;
680 len = kernel_sendmsg(sock, &msg, &iov, 1, (size_t)(length));
687 ip_vs_send_sync_msg(struct socket *sock, struct ip_vs_sync_mesg *msg)
693 /* Put size in network byte order */
694 msg->size = htons(msg->size);
696 if (ip_vs_send_async(sock, (char *)msg, msize) != msize)
697 IP_VS_ERR("ip_vs_send_async error\n");
701 ip_vs_receive(struct socket *sock, char *buffer, const size_t buflen)
703 struct msghdr msg = {NULL,};
709 /* Receive a packet */
710 iov.iov_base = buffer;
711 iov.iov_len = (size_t)buflen;
713 len = kernel_recvmsg(sock, &msg, &iov, 1, buflen, 0);
723 static int sync_thread_master(void *data)
725 struct ip_vs_sync_thread_data *tinfo = data;
726 struct ip_vs_sync_buff *sb;
728 IP_VS_INFO("sync thread started: state = MASTER, mcast_ifn = %s, "
730 ip_vs_master_mcast_ifn, ip_vs_master_syncid);
732 while (!kthread_should_stop()) {
733 while ((sb = sb_dequeue())) {
734 ip_vs_send_sync_msg(tinfo->sock, sb->mesg);
735 ip_vs_sync_buff_release(sb);
738 /* check if entries stay in curr_sb for 2 seconds */
739 sb = get_curr_sync_buff(2 * HZ);
741 ip_vs_send_sync_msg(tinfo->sock, sb->mesg);
742 ip_vs_sync_buff_release(sb);
745 schedule_timeout_interruptible(HZ);
748 /* clean up the sync_buff queue */
749 while ((sb=sb_dequeue())) {
750 ip_vs_sync_buff_release(sb);
753 /* clean up the current sync_buff */
754 if ((sb = get_curr_sync_buff(0))) {
755 ip_vs_sync_buff_release(sb);
758 /* release the sending multicast socket */
759 sock_release(tinfo->sock);
766 static int sync_thread_backup(void *data)
768 struct ip_vs_sync_thread_data *tinfo = data;
771 IP_VS_INFO("sync thread started: state = BACKUP, mcast_ifn = %s, "
773 ip_vs_backup_mcast_ifn, ip_vs_backup_syncid);
775 while (!kthread_should_stop()) {
776 wait_event_interruptible(*tinfo->sock->sk->sk_sleep,
777 !skb_queue_empty(&tinfo->sock->sk->sk_receive_queue)
778 || kthread_should_stop());
780 /* do we have data now? */
781 while (!skb_queue_empty(&(tinfo->sock->sk->sk_receive_queue))) {
782 len = ip_vs_receive(tinfo->sock, tinfo->buf,
783 sync_recv_mesg_maxlen);
785 IP_VS_ERR("receiving message error\n");
789 /* disable bottom half, because it accesses the data
790 shared by softirq while getting/creating conns */
792 ip_vs_process_message(tinfo->buf, len);
797 /* release the sending multicast socket */
798 sock_release(tinfo->sock);
806 int start_sync_thread(int state, char *mcast_ifn, __u8 syncid)
808 struct ip_vs_sync_thread_data *tinfo;
809 struct task_struct **realtask, *task;
811 char *name, *buf = NULL;
812 int (*threadfn)(void *data);
813 int result = -ENOMEM;
815 IP_VS_DBG(7, "%s: pid %d\n", __func__, task_pid_nr(current));
816 IP_VS_DBG(7, "Each ip_vs_sync_conn entry needs %Zd bytes\n",
817 sizeof(struct ip_vs_sync_conn));
819 if (state == IP_VS_STATE_MASTER) {
820 if (sync_master_thread)
823 strlcpy(ip_vs_master_mcast_ifn, mcast_ifn,
824 sizeof(ip_vs_master_mcast_ifn));
825 ip_vs_master_syncid = syncid;
826 realtask = &sync_master_thread;
827 name = "ipvs_syncmaster";
828 threadfn = sync_thread_master;
829 sock = make_send_sock();
830 } else if (state == IP_VS_STATE_BACKUP) {
831 if (sync_backup_thread)
834 strlcpy(ip_vs_backup_mcast_ifn, mcast_ifn,
835 sizeof(ip_vs_backup_mcast_ifn));
836 ip_vs_backup_syncid = syncid;
837 realtask = &sync_backup_thread;
838 name = "ipvs_syncbackup";
839 threadfn = sync_thread_backup;
840 sock = make_receive_sock();
846 result = PTR_ERR(sock);
850 set_sync_mesg_maxlen(state);
851 if (state == IP_VS_STATE_BACKUP) {
852 buf = kmalloc(sync_recv_mesg_maxlen, GFP_KERNEL);
857 tinfo = kmalloc(sizeof(*tinfo), GFP_KERNEL);
864 task = kthread_run(threadfn, tinfo, name);
866 result = PTR_ERR(task);
872 ip_vs_sync_state |= state;
874 /* increase the module use count */
875 ip_vs_use_count_inc();
890 int stop_sync_thread(int state)
892 IP_VS_DBG(7, "%s: pid %d\n", __func__, task_pid_nr(current));
894 if (state == IP_VS_STATE_MASTER) {
895 if (!sync_master_thread)
898 IP_VS_INFO("stopping master sync thread %d ...\n",
899 task_pid_nr(sync_master_thread));
902 * The lock synchronizes with sb_queue_tail(), so that we don't
903 * add sync buffers to the queue, when we are already in
904 * progress of stopping the master sync daemon.
907 spin_lock_bh(&ip_vs_sync_lock);
908 ip_vs_sync_state &= ~IP_VS_STATE_MASTER;
909 spin_unlock_bh(&ip_vs_sync_lock);
910 kthread_stop(sync_master_thread);
911 sync_master_thread = NULL;
912 } else if (state == IP_VS_STATE_BACKUP) {
913 if (!sync_backup_thread)
916 IP_VS_INFO("stopping backup sync thread %d ...\n",
917 task_pid_nr(sync_backup_thread));
919 ip_vs_sync_state &= ~IP_VS_STATE_BACKUP;
920 kthread_stop(sync_backup_thread);
921 sync_backup_thread = NULL;
926 /* decrease the module use count */
927 ip_vs_use_count_dec();