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

« back to all changes in this revision

Viewing changes to keepalived/check/ipvswrapper.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2009-05-12 20:26:15 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20090512202615-k850bw35qpuvpq4p
Tags: 1.1.17-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/rules: DEB_UPDATE_RCD_PARAMS := expicit 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

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * Part:        IPVS Kernel wrapper. Use setsockopt call to add/remove
7
7
 *              server to/from the loadbalanced server pool.
8
8
 *  
9
 
 * Version:     $Id: ipvswrapper.c,v 1.1.15 2007/09/15 04:07:41 acassen Exp $
 
9
 * Version:     $Id: ipvswrapper.c,v 1.1.17 2009/03/05 01:31:12 acassen Exp $
10
10
 * 
11
11
 * Author:      Alexandre Cassen, <acassen@linux-vs.org>
12
12
 *              
20
20
 *               as published by the Free Software Foundation; either version
21
21
 *               2 of the License, or (at your option) any later version.
22
22
 *
23
 
 * Copyright (C) 2001-2007 Alexandre Cassen, <acassen@freebox.fr>
 
23
 * Copyright (C) 2001-2009 Alexandre Cassen, <acassen@freebox.fr>
24
24
 */
25
25
 
26
26
#include "ipvswrapper.h"
28
28
#include "list.h"
29
29
#include "utils.h"
30
30
#include "memory.h"
 
31
#include "logger.h"
31
32
 
32
33
/* local helpers functions */
33
34
static int parse_timeout(char *, unsigned *);
65
66
int
66
67
ipvs_syncd_cmd(int cmd, char *ifname, int state, int syncid)
67
68
{
68
 
        syslog(LOG_INFO, "IPVS : Sync daemon not supported on kernel v2.2");
 
69
        log_message(LOG_INFO, "IPVS : Sync daemon not supported on kernel v2.2");
69
70
        return IPVS_ERROR;
70
71
}
71
72
 
87
88
        ctl.u.vs_user.protocol = vs->service_type;
88
89
 
89
90
        if (!parse_timeout(vs->timeout_persistence, &ctl.u.vs_user.timeout))
90
 
                syslog(LOG_INFO,
 
91
                log_message(LOG_INFO,
91
92
                       "IPVS : Virtual service [%s:%d] illegal timeout.",
92
93
                       inet_ntop2(SVR_IP(vs))
93
94
                       , ntohs(SVR_PORT(vs)));
125
126
 
126
127
        sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
127
128
        if (sockfd == -1) {
128
 
                syslog(LOG_INFO,
 
129
                log_message(LOG_INFO,
129
130
                       "IPVS : Can not initialize SOCK_RAW descriptor.");
130
131
                return IPVS_ERROR;
131
132
        }
135
136
                       sizeof (ctl));
136
137
 
137
138
        if (errno == ESRCH) {
138
 
                syslog(LOG_INFO, "IPVS : Virtual service [%s:%d] not defined.",
 
139
                log_message(LOG_INFO, "IPVS : Virtual service [%s:%d] not defined.",
139
140
                       inet_ntop2(SVR_IP(vs))
140
141
                       , ntohs(SVR_PORT(vs)));
141
142
                close(sockfd);
142
143
                return IPVS_ERROR;
143
144
        } else if (errno == EEXIST) {
144
145
                if (rs)
145
 
                        syslog(LOG_INFO,
 
146
                        log_message(LOG_INFO,
146
147
                               "IPVS : Destination already exists [%s:%d].",
147
148
                               inet_ntop2(SVR_IP(rs))
148
149
                               , ntohs(SVR_PORT(rs)));
149
150
        } else if (errno == ENOENT) {
150
151
                if (rs)
151
 
                        syslog(LOG_INFO, "IPVS : No such destination [%s:%d].",
 
152
                        log_message(LOG_INFO, "IPVS : No such destination [%s:%d].",
152
153
                               inet_ntop2(SVR_IP(rs))
153
154
                               , ntohs(SVR_PORT(rs)));
154
155
        }
167
168
int
168
169
ipvs_start(void)
169
170
{
 
171
        log_message(LOG_DEBUG, "Initializing ipvs 2.4");
170
172
        /* Init IPVS kernel channel */
171
173
        if (ipvs_init()) {
172
174
                /* try to insmod the ip_vs module if ipvs_init failed */
173
175
                if (modprobe_ipvs() || ipvs_init()) {
174
 
                        syslog(LOG_INFO,
 
176
                        log_message(LOG_INFO,
175
177
                               "IPVS : Can't initialize ipvs: %s",
176
178
                               ipvs_strerror(errno));
177
179
                        return IPVS_ERROR;
195
197
ipvs_talk(int cmd)
196
198
{
197
199
        if (ipvs_command(cmd, urule))
198
 
                syslog(LOG_INFO, "IPVS : %s", ipvs_strerror(errno));
 
200
                log_message(LOG_INFO, "IPVS : %s", ipvs_strerror(errno));
199
201
        return IPVS_SUCCESS;
200
202
}
201
203
 
216
218
        return ipvs_talk(cmd);
217
219
 
218
220
#else
219
 
        syslog(LOG_INFO, "IPVS : Sync daemon not supported");
 
221
        log_message(LOG_INFO, "IPVS : Sync daemon not supported");
220
222
        return IPVS_ERROR;
221
223
#endif
222
224
}
314
316
        urule->protocol = vs->service_type;
315
317
 
316
318
        if (!parse_timeout(vs->timeout_persistence, &urule->timeout))
317
 
                syslog(LOG_INFO,
 
319
                log_message(LOG_INFO,
318
320
                       "IPVS : Virtual service [%s:%d] illegal timeout.",
319
321
                       inet_ntop2(SVR_IP(vs)), ntohs(SVR_PORT(vs)));
320
322
 
438
440
int
439
441
ipvs_start(void)
440
442
{
 
443
        log_message(LOG_DEBUG, "Initializing ipvs 2.6");
441
444
        /* Initialize IPVS module */
442
445
        if (ipvs_init()) {
443
446
                if (modprobe_ipvs() || ipvs_init()) {
444
 
                        syslog(LOG_INFO, "IPVS: Can't initialize ipvs: %s",
 
447
                        log_message(LOG_INFO, "IPVS: Can't initialize ipvs: %s",
445
448
                               ipvs_strerror(errno));
446
449
                        return IPVS_ERROR;
447
450
                }
501
504
        }
502
505
 
503
506
        if (result)
504
 
                syslog(LOG_INFO, "IPVS: %s", ipvs_strerror(errno));
 
507
                log_message(LOG_INFO, "IPVS: %s", ipvs_strerror(errno));
505
508
}
506
509
 
507
510
int
609
612
        srule->protocol = vs->service_type;
610
613
 
611
614
        if (!parse_timeout(vs->timeout_persistence, &srule->timeout))
612
 
                syslog(LOG_INFO,
 
615
                log_message(LOG_INFO,
613
616
                       "IPVS : Virtual service [%s:%d] illegal timeout.",
614
617
                       inet_ntop2(SVR_IP(vs)), ntohs(SVR_PORT(vs)));
615
618