~ubuntu-branches/ubuntu/vivid/keepalived/vivid

« back to all changes in this revision

Viewing changes to keepalived/check/ipwrapper.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2011-10-25 16:10:58 UTC
  • mfrom: (3.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20111025161058-bgqn5elt0xo1tq0a
Tags: 1:1.2.2-1ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - debian/rules: DEB_UPDATE_RCD_PARAMS := explicit init start/stop
    parameters (don't stop at 0 and 6)
  - debian/init.d: init script header adapted to stop rule
  - debian/keepalived.postinst: Remove shutdown and reboot links
* Build with libnl3, thanks to a patch from Marc - A. Dahlhaus.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *              as published by the Free Software Foundation; either version
18
18
 *              2 of the License, or (at your option) any later version.
19
19
 *
20
 
 * Copyright (C) 2001-2010 Alexandre Cassen, <acassen@freebox.fr>
 
20
 * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
21
21
 */
22
22
 
23
23
#include "ipwrapper.h"
50
50
{
51
51
        element e;
52
52
        real_server *rs;
53
 
        char rsip[16], vsip[16];
 
53
        char rsip[INET6_ADDRSTRLEN];
54
54
 
55
55
        for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
56
56
                rs = ELEMENT_DATA(e);
57
57
                if (ISALIVE(rs)) {
58
 
                        if (!ipvs_cmd(LVS_CMD_DEL_DEST
59
 
                                      , vs_group
60
 
                                      , vs
61
 
                                      , rs))
 
58
                        if (!ipvs_cmd(LVS_CMD_DEL_DEST, vs_group, vs, rs))
62
59
                                return 0;
63
60
                        UNSET_ALIVE(rs);
64
61
                        if (!vs->omega)
68
65
                         * all the way down the exit, as necessary.
69
66
                         */
70
67
                        if (rs->notify_down) {
71
 
                                log_message(LOG_INFO, "Executing [%s] for service [%s:%d]"
72
 
                                            " in VS [%s:%d]"
73
 
                                            , rs->notify_down
74
 
                                            , inet_ntoa2(SVR_IP(rs), rsip)
75
 
                                            , ntohs(SVR_PORT(rs))
76
 
                                            , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
77
 
                                            , ntohs(SVR_PORT(vs)));
 
68
                                log_message(LOG_INFO, "Executing [%s] for service [%s]:%d in VS [%s]:%d"
 
69
                                                    , rs->notify_down
 
70
                                                    , inet_sockaddrtos2(&rs->addr, rsip)
 
71
                                                    , ntohs(inet_sockaddrport(&rs->addr))
 
72
                                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
73
                                                    , ntohs(inet_sockaddrport(&vs->addr)));
78
74
                                notify_exec(rs->notify_down);
79
75
                        }
80
76
 
82
78
                         * we don't push in a sorry server then, hence the regression
83
79
                         * is intended.
84
80
                         */
85
 
                        if (vs->quorum_state == UP && vs->quorum_down
86
 
                          && weigh_live_realservers(vs) < vs->quorum - vs->hysteresis) {
 
81
                        if (vs->quorum_state == UP && vs->quorum_down &&
 
82
                            weigh_live_realservers(vs) < vs->quorum - vs->hysteresis) {
87
83
                                vs->quorum_state = DOWN;
88
 
                                log_message(LOG_INFO, "Executing [%s] for VS [%s:%d]"
89
 
                                            , vs->quorum_down
90
 
                                            , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
91
 
                                            , ntohs(SVR_PORT(vs)));
 
84
                                log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
 
85
                                                    , vs->quorum_down
 
86
                                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
87
                                                    , ntohs(inet_sockaddrport(&vs->addr)));
92
88
                                notify_exec(vs->quorum_down);
93
89
                        }
94
90
                }
95
91
        }
 
92
 
96
93
        return 1;
97
94
}
98
95
 
104
101
        if (!LIST_ISEMPTY(vs->rs)) {
105
102
                if (vs->s_svr) {
106
103
                        if (ISALIVE(vs->s_svr))
107
 
                                if (!ipvs_cmd(LVS_CMD_DEL_DEST
108
 
                                              , vs_group
109
 
                                              , vs
110
 
                                              , vs->s_svr))
 
104
                                if (!ipvs_cmd(LVS_CMD_DEL_DEST, vs_group, vs, vs->s_svr))
111
105
                                        return 0;
112
106
                } else if (!clear_service_rs(vs_group, vs, vs->rs))
113
107
                        return 0;
216
210
{
217
211
        element e;
218
212
        real_server *rs;
219
 
        char vsip[16];
 
213
 
220
214
        if (LIST_ISEMPTY(vs->rs))
221
215
                return;
222
 
        log_message(LOG_INFO,
223
 
               "%s the pool for VS [%s:%d]"
224
 
               , add?"Adding alive servers to":"Removing alive servers from"
225
 
               , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
226
 
               , ntohs(SVR_PORT(vs)));
 
216
 
 
217
        log_message(LOG_INFO, "%s the pool for VS [%s]:%d"
 
218
                            , add?"Adding alive servers to":"Removing alive servers from"
 
219
                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
220
                            , ntohs(inet_sockaddrport(&vs->addr)));
227
221
        for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
228
222
                rs = ELEMENT_DATA(e);
229
223
                if (!ISALIVE(rs)) /* We only handle alive servers */
230
224
                        continue;
231
 
                if (!(add ^ rs->set)) /* Already done */
232
 
                        continue;
233
 
                if (add) rs->alive = 0;
234
 
                ipvs_cmd(add?LVS_CMD_ADD_DEST:LVS_CMD_DEL_DEST,
235
 
                         check_data->vs_group, vs, rs);
 
225
                if (add)
 
226
                        rs->alive = 0;
 
227
                ipvs_cmd(add?LVS_CMD_ADD_DEST:LVS_CMD_DEL_DEST, check_data->vs_group, vs, rs);
236
228
                rs->alive = 1;
237
229
        }
238
230
}
239
231
 
 
232
/* set quorum state depending on current weight of real servers */
 
233
void
 
234
update_quorum_state(virtual_server * vs)
 
235
{
 
236
        char rsip[INET6_ADDRSTRLEN];
 
237
 
 
238
        /* If we have just gained quorum, it's time to consider notify_up. */
 
239
        if (vs->quorum_state == DOWN &&
 
240
            weigh_live_realservers(vs) >= vs->quorum + vs->hysteresis) {
 
241
                vs->quorum_state = UP;
 
242
                log_message(LOG_INFO, "Gained quorum %lu+%lu=%lu <= %u for VS [%s]:%d"
 
243
                                    , vs->quorum
 
244
                                    , vs->hysteresis
 
245
                                    , vs->quorum + vs->hysteresis
 
246
                                    , weigh_live_realservers(vs)
 
247
                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
248
                                    , ntohs(inet_sockaddrport(&vs->addr)));
 
249
                if (vs->s_svr && ISALIVE(vs->s_svr)) {
 
250
                        log_message(LOG_INFO, "Removing sorry server [%s]:%d from VS [%s]:%d"
 
251
                                            , inet_sockaddrtos2(&vs->s_svr->addr, rsip)
 
252
                                            , ntohs(inet_sockaddrport(&vs->s_svr->addr))
 
253
                                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
254
                                            , ntohs(inet_sockaddrport(&vs->addr)));
 
255
 
 
256
                        ipvs_cmd(LVS_CMD_DEL_DEST, check_data->vs_group, vs, vs->s_svr);
 
257
                        vs->s_svr->alive = 0;
 
258
 
 
259
                        /* Adding back alive real servers */
 
260
                        perform_quorum_state(vs, 1);
 
261
                }
 
262
                if (vs->quorum_up) {
 
263
                        log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
 
264
                                            , vs->quorum_up
 
265
                                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
266
                                            , ntohs(inet_sockaddrport(&vs->addr)));
 
267
                        notify_exec(vs->quorum_up);
 
268
                }
 
269
                return;
 
270
        }
 
271
 
 
272
        /* If we have just lost quorum for the VS, we need to consider
 
273
         * VS notify_down and sorry_server cases
 
274
         */
 
275
        if (vs->quorum_state == UP &&
 
276
            weigh_live_realservers(vs) < vs->quorum - vs->hysteresis) {
 
277
                vs->quorum_state = DOWN;
 
278
                log_message(LOG_INFO, "Lost quorum %lu-%lu=%lu > %u for VS [%s]:%d"
 
279
                                    , vs->quorum
 
280
                                    , vs->hysteresis
 
281
                                    , vs->quorum - vs->hysteresis
 
282
                                    , weigh_live_realservers(vs)
 
283
                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
284
                                    , ntohs(inet_sockaddrport(&vs->addr)));
 
285
                if (vs->quorum_down) {
 
286
                        log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
 
287
                                            , vs->quorum_down
 
288
                                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
289
                                            , ntohs(inet_sockaddrport(&vs->addr)));
 
290
                        notify_exec(vs->quorum_down);
 
291
                }
 
292
                if (vs->s_svr) {
 
293
                        log_message(LOG_INFO, "Adding sorry server [%s]:%d to VS [%s]:%d"
 
294
                                            , inet_sockaddrtos2(&vs->s_svr->addr, rsip)
 
295
                                            , ntohs(inet_sockaddrport(&vs->s_svr->addr))
 
296
                                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
297
                                            , ntohs(inet_sockaddrport(&vs->addr)));
 
298
 
 
299
                        /* the sorry server is now up in the pool, we flag it alive */
 
300
                        ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, vs->s_svr);
 
301
                        vs->s_svr->alive = 1;
 
302
 
 
303
                        /* Remove remaining alive real servers */
 
304
                        perform_quorum_state(vs, 0);
 
305
                }
 
306
                return;
 
307
        }
 
308
}
 
309
 
240
310
/* manipulate add/remove rs according to alive state */
241
311
void
242
312
perform_svr_state(int alive, virtual_server * vs, real_server * rs)
243
313
{
244
 
        char rsip[16], vsip[16];
245
 
/*
246
 
 * | ISALIVE(rs) | alive | context
247
 
 * | 0           | 0     | first check failed under alpha mode, unreachable here
248
 
 * | 0           | 1     | RS went up, add it to the pool
249
 
 * | 1           | 0     | RS went down, remove it from the pool
250
 
 * | 1           | 1     | first check succeeded w/o alpha mode, unreachable here
251
 
 */
 
314
        char rsip[INET6_ADDRSTRLEN];
252
315
 
 
316
        /*
 
317
         * | ISALIVE(rs) | alive | context
 
318
         * | 0           | 0     | first check failed under alpha mode, unreachable here
 
319
         * | 0           | 1     | RS went up, add it to the pool
 
320
         * | 1           | 0     | RS went down, remove it from the pool
 
321
         * | 1           | 1     | first check succeeded w/o alpha mode, unreachable here
 
322
         */
253
323
        if (!ISALIVE(rs) && alive) {
254
 
 
255
 
                /* adding a server to the vs pool, if sorry server is flagged alive,
256
 
                 * we remove it from the vs pool.
257
 
                 */
258
 
                if (vs->s_svr) {
259
 
                        if (ISALIVE(vs->s_svr) &&
260
 
                            (vs->quorum_state == UP ||
261
 
                             (weigh_live_realservers(vs) + rs->weight >=
262
 
                              vs->quorum + vs->hysteresis))) {
263
 
                                log_message(LOG_INFO,
264
 
                                       "Removing sorry server [%s:%d] from VS [%s:%d]",
265
 
                                       inet_ntoa2(SVR_IP(vs->s_svr), rsip)
266
 
                                       , ntohs(SVR_PORT(vs->s_svr))
267
 
                                       , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
268
 
                                       , ntohs(SVR_PORT(vs)));
269
 
 
270
 
                                ipvs_cmd(LVS_CMD_DEL_DEST
271
 
                                         , check_data->vs_group
272
 
                                         , vs
273
 
                                         , vs->s_svr);
274
 
                                vs->s_svr->alive = 0;
275
 
                        }
276
 
                }
277
 
 
278
 
                log_message(LOG_INFO, "%s service [%s:%d] to VS [%s:%d]",
279
 
                       (rs->inhibit) ? "Enabling" : "Adding"
280
 
                       , inet_ntoa2(SVR_IP(rs), rsip)
281
 
                       , ntohs(SVR_PORT(rs))
282
 
                       , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
283
 
                       , ntohs(SVR_PORT(vs)));
 
324
                log_message(LOG_INFO, "%s service [%s]:%d to VS [%s]:%d"
 
325
                                    , (rs->inhibit) ? "Enabling" : "Adding"
 
326
                                    , inet_sockaddrtos2(&rs->addr, rsip)
 
327
                                    , ntohs(inet_sockaddrport(&rs->addr))
 
328
                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
329
                                    , ntohs(inet_sockaddrport(&vs->addr)));
284
330
                /* Add only if we have quorum or no sorry server */
285
331
                if (vs->quorum_state == UP || !vs->s_svr || !ISALIVE(vs->s_svr)) {
286
332
                        ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, rs);
287
333
                }
288
334
                rs->alive = alive;
289
335
                if (rs->notify_up) {
290
 
                        log_message(LOG_INFO, "Executing [%s] for service [%s:%d]"
291
 
                               " in VS [%s:%d]"
292
 
                               , rs->notify_up
293
 
                               , inet_ntoa2(SVR_IP(rs), rsip)
294
 
                               , ntohs(SVR_PORT(rs))
295
 
                               , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
296
 
                               , ntohs(SVR_PORT(vs)));
 
336
                        log_message(LOG_INFO, "Executing [%s] for service [%s]:%d in VS [%s]:%d"
 
337
                                            , rs->notify_up
 
338
                                            , inet_sockaddrtos2(&rs->addr, rsip)
 
339
                                            , ntohs(inet_sockaddrport(&rs->addr))
 
340
                                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
341
                                            , ntohs(inet_sockaddrport(&vs->addr)));
297
342
                        notify_exec(rs->notify_up);
298
343
                }
299
 
                /* If we have just gained quorum, it's time to consider notify_up. */
300
 
                if (vs->quorum_state == DOWN
301
 
                  && weigh_live_realservers(vs) >= vs->quorum + vs->hysteresis) {
302
 
                        vs->quorum_state = UP;
303
 
                        log_message(LOG_INFO, "Gained quorum %lu+%lu=%lu <= %u for VS [%s:%d]"
304
 
                                    , vs->quorum
305
 
                                    , vs->hysteresis
306
 
                                    , vs->quorum + vs->hysteresis
307
 
                                    , weigh_live_realservers(vs)
308
 
                                    , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
309
 
                                    , ntohs(SVR_PORT(vs)));
310
 
                        if (vs->s_svr)
311
 
                                /* Adding back alive real servers */
312
 
                                perform_quorum_state(vs, 1);
313
 
                        if (vs->quorum_up) {
314
 
                                log_message(LOG_INFO, "Executing [%s] for VS [%s:%d]"
315
 
                                            , vs->quorum_up
316
 
                                            , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
317
 
                                            , ntohs(SVR_PORT(vs)));
318
 
                                notify_exec(vs->quorum_up);
319
 
                        }
320
 
                }
321
 
                return;
 
344
 
 
345
                /* We may have gained quorum */
 
346
                update_quorum_state(vs);
322
347
        }
323
348
 
324
349
        if (ISALIVE(rs) && !alive) {
325
 
 
326
 
                log_message(LOG_INFO, "%s service [%s:%d] from VS [%s:%d]",
327
 
                       (rs->inhibit) ? "Disabling" : "Removing"
328
 
                       , inet_ntoa2(SVR_IP(rs), rsip)
329
 
                       , ntohs(SVR_PORT(rs))
330
 
                       , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
331
 
                       , ntohs(SVR_PORT(vs)));
332
 
 
333
 
                /* server is down, it is removed from the LVS realserver pool */
334
 
                /* Remove only if we have quorum or no sorry server */
 
350
                log_message(LOG_INFO, "%s service [%s]:%d from VS [%s]:%d"
 
351
                                    , (rs->inhibit) ? "Disabling" : "Removing"
 
352
                                    , inet_sockaddrtos2(&rs->addr, rsip)
 
353
                                    , ntohs(inet_sockaddrport(&rs->addr))
 
354
                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
355
                                    , ntohs(inet_sockaddrport(&vs->addr)));
 
356
 
 
357
                /* server is down, it is removed from the LVS realserver pool
 
358
                 * Remove only if we have quorum or no sorry server
 
359
                 */
335
360
                if (vs->quorum_state == UP || !vs->s_svr || !ISALIVE(vs->s_svr)) {
336
361
                        ipvs_cmd(LVS_CMD_DEL_DEST, check_data->vs_group, vs, rs);
337
362
                }
338
363
                rs->alive = alive;
339
364
                if (rs->notify_down) {
340
 
                        log_message(LOG_INFO, "Executing [%s] for service [%s:%d]"
341
 
                               " in VS [%s:%d]"
342
 
                               , rs->notify_down
343
 
                               , inet_ntoa2(SVR_IP(rs), rsip)
344
 
                               , ntohs(SVR_PORT(rs))
345
 
                               , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
346
 
                               , ntohs(SVR_PORT(vs)));
 
365
                        log_message(LOG_INFO, "Executing [%s] for service [%s]:%d in VS [%s]:%d"
 
366
                                            , rs->notify_down
 
367
                                            , inet_sockaddrtos2(&rs->addr, rsip)
 
368
                                            , ntohs(inet_sockaddrport(&rs->addr))
 
369
                                            , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
370
                                            , ntohs(inet_sockaddrport(&vs->addr)));
347
371
                        notify_exec(rs->notify_down);
348
372
                }
349
373
 
350
 
                /* If we have just lost quorum for the VS, we need to consider
351
 
                 * VS notify_down and sorry_server cases
352
 
                 */
353
 
                if (vs->quorum_state == UP
354
 
                    && weigh_live_realservers(vs) < vs->quorum - vs->hysteresis) {
355
 
                        vs->quorum_state = DOWN;
356
 
                        log_message(LOG_INFO, "Lost quorum %lu-%lu=%lu > %u for VS [%s:%d]"
357
 
                                    , vs->quorum
358
 
                                    , vs->hysteresis
359
 
                                    , vs->quorum - vs->hysteresis
360
 
                                    , weigh_live_realservers(vs)
361
 
                                    , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
362
 
                                    , ntohs(SVR_PORT(vs)));
363
 
                        if (vs->quorum_down) {
364
 
                                log_message(LOG_INFO, "Executing [%s] for VS [%s:%d]"
365
 
                                            , vs->quorum_down
366
 
                                            , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
367
 
                                            , ntohs(SVR_PORT(vs)));
368
 
                                notify_exec(vs->quorum_down);
369
 
                        }
370
 
                        if (vs->s_svr) {
371
 
                                log_message(LOG_INFO,
372
 
                                            "Adding sorry server [%s:%d] to VS [%s:%d]",
373
 
                                            inet_ntoa2(SVR_IP(vs->s_svr), rsip)
374
 
                                            , ntohs(SVR_PORT(vs->s_svr))
375
 
                                            , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
376
 
                                            , ntohs(SVR_PORT(vs)));
377
 
 
378
 
                                /* the sorry server is now up in the pool, we flag it alive */
379
 
                                ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, vs->s_svr);
380
 
                                vs->s_svr->alive = 1;
381
 
 
382
 
                                /* Remove remaining alive real servers */
383
 
                                perform_quorum_state(vs, 0);
384
 
                        }
385
 
                }
 
374
                /* We may have lost quorum */
 
375
                update_quorum_state(vs);
386
376
        }
387
377
}
388
378
 
390
380
void
391
381
update_svr_wgt(int weight, virtual_server * vs, real_server * rs)
392
382
{
393
 
        char rsip[16], vsip[16];
 
383
        char rsip[INET6_ADDRSTRLEN];
394
384
 
395
385
        if (weight != rs->weight) {
396
 
                log_message(LOG_INFO, "Changing weight from %d to %d for %s service [%s:%d]"
397
 
                                 " of VS [%s:%d]"
398
 
                                 , rs->weight
399
 
                                 , weight
400
 
                                 , ISALIVE(rs) ? "active" : "inactive"
401
 
                                 , inet_ntoa2(SVR_IP(rs), rsip)
402
 
                                 , ntohs(SVR_PORT(rs))
403
 
                                 , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
404
 
                                 , ntohs(SVR_PORT(vs)));
 
386
                log_message(LOG_INFO, "Changing weight from %d to %d for %s service [%s]:%d of VS [%s]:%d"
 
387
                                    , rs->weight
 
388
                                    , weight
 
389
                                    , ISALIVE(rs) ? "active" : "inactive"
 
390
                                    , inet_sockaddrtos2(&rs->addr, rsip)
 
391
                                    , ntohs(inet_sockaddrport(&rs->addr))
 
392
                                    , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
 
393
                                    , ntohs(inet_sockaddrport(&vs->addr)));
405
394
                rs->weight = weight;
406
395
                /*
407
 
                 * Have weight change take effect now only if rs is alive.
408
 
                 * If not, it will take effect later when it becomes alive.
 
396
                 * Have weight change take effect now only if rs is in
 
397
                 * the pool and alive and the quorum is met (or if
 
398
                 * there is no sorry server). If not, it will take
 
399
                 * effect later when it becomes alive.
409
400
                 */
410
 
                if (ISALIVE(rs))
 
401
                if (rs->set && ISALIVE(rs) &&
 
402
                    (vs->quorum_state == UP || !vs->s_svr || !ISALIVE(vs->s_svr)))
411
403
                        ipvs_cmd(LVS_CMD_EDIT_DEST, check_data->vs_group, vs, rs);
 
404
                update_quorum_state(vs);
412
405
        }
413
406
}
414
407
 
498
491
static int
499
492
clear_diff_vsge(list old, list new, virtual_server * old_vs)
500
493
{
 
494
        virtual_server_group_entry *vsge;
501
495
        element e;
502
 
        virtual_server_group_entry *vsge;
503
496
 
504
497
        for (e = LIST_HEAD(old); e; ELEMENT_NEXT(e)) {
505
498
                vsge = ELEMENT_DATA(e);
506
499
                if (!vsge_exist(vsge, new)) {
507
 
                        log_message(LOG_INFO, "VS [%s:%d:%d:%d] in group %s"
508
 
                               " no longer exist\n" 
509
 
                               , inet_ntop2(vsge->addr_ip)
510
 
                               , ntohs(vsge->addr_port)
511
 
                               , vsge->range
512
 
                               , vsge->vfwmark
513
 
                               , old_vs->vsgname);
 
500
                        log_message(LOG_INFO, "VS [%s:%d:%d:%d] in group %s no longer exist\n" 
 
501
                                            , inet_sockaddrtos(&vsge->addr)
 
502
                                            , ntohs(inet_sockaddrport(&vsge->addr))
 
503
                                            , vsge->range
 
504
                                            , vsge->vfwmark
 
505
                                            , old_vs->vsgname);
514
506
 
515
507
                        if (!ipvs_group_remove_entry(old_vs, vsge))
516
508
                                return 0;
599
591
                         */
600
592
                        rs->alive = old_rs->alive;
601
593
                        rs->set = old_rs->set;
 
594
                        rs->weight = old_rs->weight;
602
595
                        return 1;
603
596
                }
604
597
        }
635
628
        list l = old_vs->rs;
636
629
        list new = get_rs_list(old_vs);
637
630
        real_server *rs;
638
 
        char rsip[16], vsip[16];
 
631
        char rsip[INET6_ADDRSTRLEN];
639
632
 
640
633
        /* If old vs didn't own rs then nothing return */
641
634
        if (LIST_ISEMPTY(l))
645
638
                rs = ELEMENT_DATA(e);
646
639
                if (!rs_exist(rs, new)) {
647
640
                        /* Reset inhibit flag to delete inhibit entries */
648
 
                        log_message(LOG_INFO, "service [%s:%d] no longer exist"
649
 
                               , inet_ntoa2(SVR_IP(rs), rsip)
650
 
                               , ntohs(SVR_PORT(rs)));
651
 
                        log_message(LOG_INFO, "Removing service [%s:%d] from VS [%s:%d]"
652
 
                               , inet_ntoa2(SVR_IP(rs), rsip)
653
 
                               , ntohs(SVR_PORT(rs))
654
 
                               , inet_ntoa2(SVR_IP(old_vs), vsip)
655
 
                               , ntohs(SVR_PORT(old_vs)));
 
641
                        log_message(LOG_INFO, "service [%s]:%d no longer exist"
 
642
                                            , inet_sockaddrtos(&rs->addr)
 
643
                                            , ntohs(inet_sockaddrport(&rs->addr)));
 
644
                        log_message(LOG_INFO, "Removing service [%s]:%d from VS [%s]:%d"
 
645
                                            , inet_sockaddrtos2(&rs->addr, rsip)
 
646
                                            , ntohs(inet_sockaddrport(&rs->addr))
 
647
                                            , (old_vs->vsgname) ? old_vs->vsgname : inet_sockaddrtos(&old_vs->addr)
 
648
                                            , ntohs(inet_sockaddrport(&old_vs->addr)));
656
649
                        rs->inhibit = 0;
657
650
                        if (!ipvs_cmd(LVS_CMD_DEL_DEST, check_data->vs_group, old_vs, rs))
658
651
                                return 0;
685
678
                if (!vs_exist(vs)) {
686
679
                        if (vs->vsgname)
687
680
                                log_message(LOG_INFO, "Removing Virtual Server Group [%s]"
688
 
                                       , vs->vsgname);
 
681
                                                    , vs->vsgname);
689
682
                        else
690
 
                                log_message(LOG_INFO, "Removing Virtual Server [%s:%d]"
691
 
                                       , inet_ntop2(vs->addr_ip)
692
 
                                       , ntohs(vs->addr_port));
 
683
                                log_message(LOG_INFO, "Removing Virtual Server [%s]:%d"
 
684
                                                    , inet_sockaddrtos(&vs->addr)
 
685
                                                    , ntohs(inet_sockaddrport(&vs->addr)));
693
686
 
694
687
                        /* Clear VS entry */
695
688
                        if (!clear_service_vs(old_check_data->vs_group, vs))