~ubuntu-branches/ubuntu/trusty/keepalived/trusty

« back to all changes in this revision

Viewing changes to keepalived/check/ipwrapper.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Wirt
  • Date: 2005-04-29 23:22:40 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050429232240-a8m3jtpi3cvuyyy2
Tags: 1.1.11-3
Added a warning about sarge kernels to README.Debian and 
the package description 

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * Part:        Manipulation functions for IPVS & IPFW wrappers.
7
7
 *
8
 
 * Version:     $id: ipwrapper.c,v 1.1.7 2004/04/04 23:28:05 acassen Exp $
 
8
 * Version:     $Id: ipwrapper.c,v 1.1.11 2005/03/01 01:22:13 acassen Exp $
9
9
 *
10
10
 * Author:      Alexandre Cassen, <acassen@linux-vs.org>
11
11
 *
19
19
 *              as published by the Free Software Foundation; either version
20
20
 *              2 of the License, or (at your option) any later version.
21
21
 *
22
 
 * Copyright (C) 2001-2004 Alexandre Cassen, <acassen@linux-vs.org>
 
22
 * Copyright (C) 2001-2005 Alexandre Cassen, <acassen@linux-vs.org>
23
23
 */
24
24
 
25
25
#include "ipwrapper.h"
28
28
#include "utils.h"
29
29
#include "notify.h"
30
30
 
31
 
/* extern global vars */
32
 
extern check_conf_data *check_data;
33
 
extern check_conf_data *old_check_data;
34
 
 
35
31
/* Remove a realserver IPVS rule */
36
32
static int
37
33
clear_service_rs(list vs_group, virtual_server * vs, list l)
300
296
                        ipfw_cmd(IP_FW_CMD_ADD, vs, vs->s_svr);
301
297
#endif
302
298
                }
303
 
 
 
299
        }
 
300
}
 
301
 
 
302
/* Store new weight in real_server struct and then update kernel. */
 
303
void
 
304
update_svr_wgt(int weight, virtual_server * vs, real_server * rs)
 
305
{
 
306
        char rsip[16], vsip[16];
 
307
 
 
308
        if (weight != rs->weight) {
 
309
                syslog(LOG_INFO, "Changing weight from %d to %d for %s service [%s:%d]"
 
310
                                 " of VS [%s:%d]"
 
311
                                 , rs->weight
 
312
                                 , weight
 
313
                                 , ISALIVE(rs) ? "active" : "inactive"
 
314
                                 , inet_ntoa2(SVR_IP(rs), rsip)
 
315
                                 , ntohs(SVR_PORT(rs))
 
316
                                 , (vs->vsgname) ? vs->vsgname : inet_ntoa2(SVR_IP(vs), vsip)
 
317
                                 , ntohs(SVR_PORT(vs)));
 
318
                rs->weight = weight;
 
319
                /*
 
320
                 * Have weight change take effect now only if rs is alive.
 
321
                 * If not, it will take effect later when it becomes alive.
 
322
                 */
 
323
                if (ISALIVE(rs))
 
324
                        ipvs_cmd(LVS_CMD_EDIT_DEST, check_data->vs_group, vs, rs);
304
325
        }
305
326
}
306
327
 
437
458
        virtual_server *vs;
438
459
        virtual_server_group *vsg;
439
460
 
 
461
        if (LIST_ISEMPTY(l))
 
462
                return 0;
 
463
 
440
464
        for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
441
465
                vs = ELEMENT_DATA(e);
442
466
                if (VS_ISEQ(old_vs, vs)) {
475
499
        element e;
476
500
        real_server *rs;
477
501
 
 
502
        if (LIST_ISEMPTY(l))
 
503
                return 0;
 
504
 
478
505
        for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
479
506
                rs = ELEMENT_DATA(e);
480
507
                if (RS_ISEQ(rs, old_rs)) {
500
527
        list l = check_data->vs;
501
528
        virtual_server *vsvr;
502
529
 
 
530
        if (LIST_ISEMPTY(l))
 
531
                return NULL;
 
532
 
503
533
        for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
504
534
                vsvr = ELEMENT_DATA(e);
505
535
                if (VS_ISEQ(vs, vsvr))
520
550
        real_server *rs;
521
551
        char rsip[16], vsip[16];
522
552
 
 
553
        /* If old vs didn't own rs then nothing return */
 
554
        if (LIST_ISEMPTY(l))
 
555
                return 1;
 
556
 
523
557
        for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
524
558
                rs = ELEMENT_DATA(e);
525
559
                if (!rs_exist(rs, new)) {
549
583
        list l = old_check_data->vs;
550
584
        virtual_server *vs;
551
585
 
 
586
        /* If old config didn't own vs then nothing return */
 
587
        if (LIST_ISEMPTY(l))
 
588
                return 1;
 
589
 
552
590
        /* Remove diff entries from previous IPVS rules */
553
591
        for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
554
592
                vs = ELEMENT_DATA(e);