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

« back to all changes in this revision

Viewing changes to keepalived/vrrp/vrrp_data.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:        Dynamic data structure definition.
7
7
 *
8
 
 * Version:     $Id: vrrp_data.c,v 1.1.7 2004/04/04 23:28:05 acassen Exp $
 
8
 * Version:     $Id: vrrp_data.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 "vrrp_data.h"
29
29
#include "memory.h"
30
30
#include "utils.h"
31
31
 
32
 
/* Externals vars */
33
 
extern vrrp_conf_data *vrrp_data;
 
32
/* global vars */
 
33
vrrp_conf_data *vrrp_data = NULL;
 
34
vrrp_conf_data *old_vrrp_data = NULL;
 
35
char *vrrp_buffer;
34
36
 
35
37
/* Static addresses facility function */
36
38
void
58
60
 
59
61
        FREE(vgroup->gname);
60
62
        free_strvec(vgroup->iname);
61
 
        free_list(vgroup->index);
 
63
        free_list(vgroup->index_list);
62
64
        FREE_PTR(vgroup->script_backup);
63
65
        FREE_PTR(vgroup->script_master);
64
66
        FREE_PTR(vgroup->script_fault);
94
96
                syslog(LOG_INFO, "   Using smtp notification");
95
97
}
96
98
 
 
99
/* Socket pool functions */
 
100
static void
 
101
free_sock(void *sock_data_obj)
 
102
{
 
103
        sock *sock_obj = sock_data_obj;
 
104
        interface *ifp = if_get_by_ifindex(sock_obj->ifindex);
 
105
        if_leave_vrrp_group(sock_obj->fd_in, ifp);
 
106
        close(sock_obj->fd_out);
 
107
        FREE(sock_data_obj);
 
108
}
 
109
 
 
110
static void
 
111
dump_sock(void *sock_data_obj)
 
112
{
 
113
        sock *sock_obj = sock_data_obj;
 
114
        syslog(LOG_INFO, "VRRP sockpool: [ifindex(%d), proto(%d), fd(%d,%d)]",
 
115
               sock_obj->ifindex
 
116
               , sock_obj->proto
 
117
               , sock_obj->fd_in
 
118
               , sock_obj->fd_out);
 
119
}
 
120
 
97
121
static void
98
122
free_vrrp(void *data)
99
123
{
124
148
        else
125
149
                syslog(LOG_INFO, "   Want State = MASTER");
126
150
        syslog(LOG_INFO, "   Runing on device = %s", IF_NAME(vrrp->ifp));
 
151
        if (vrrp->dont_track_primary)
 
152
                syslog(LOG_INFO, "   VRRP interface tracking disabled");
127
153
        if (vrrp->mcast_saddr)
128
154
                syslog(LOG_INFO, "   Using mcast src_ip = %s",
129
155
                       inet_ntop2(vrrp->mcast_saddr));
137
163
        syslog(LOG_INFO, "   Priority = %d", vrrp->priority);
138
164
        syslog(LOG_INFO, "   Advert interval = %dsec",
139
165
               vrrp->adver_int / TIMER_HZ);
140
 
        if (vrrp->preempt)
141
 
                syslog(LOG_INFO, "   Preempt Active");
 
166
        if (vrrp->nopreempt)
 
167
                syslog(LOG_INFO, "   Preempt disabled");
 
168
        if (vrrp->preempt_delay)
 
169
                syslog(LOG_INFO, "   Preempt delay = %ld secs",
 
170
                       vrrp->preempt_delay / TIMER_HZ);
142
171
        if (vrrp->auth_type) {
143
172
                syslog(LOG_INFO, "   Authentication type = %s",
144
173
                       (vrrp->auth_type ==
278
307
        new->vrrp_index = alloc_mlist(NULL, NULL, 255);
279
308
        new->vrrp_index_fd = alloc_mlist(NULL, NULL, 1024+1);
280
309
        new->vrrp_sync_group = alloc_list(free_vgroup, dump_vgroup);
 
310
        new->vrrp_socket_pool = alloc_list(free_sock, dump_sock);
281
311
 
282
312
        return new;
283
313
}
284
314
 
285
315
void
286
 
free_vrrp_data(vrrp_conf_data * vrrp_data)
 
316
free_vrrp_data(vrrp_conf_data * vrrp_data_obj)
287
317
{
288
 
        free_list(vrrp_data->static_addresses);
289
 
        free_list(vrrp_data->static_routes);
290
 
        free_mlist(vrrp_data->vrrp_index, 255);
291
 
        free_mlist(vrrp_data->vrrp_index_fd, 1024+1);
292
 
        free_list(vrrp_data->vrrp);
293
 
        free_list(vrrp_data->vrrp_sync_group);
294
 
        FREE(vrrp_data);
 
318
        free_list(vrrp_data_obj->static_addresses);
 
319
        free_list(vrrp_data_obj->static_routes);
 
320
        free_mlist(vrrp_data_obj->vrrp_index, 255);
 
321
        free_mlist(vrrp_data_obj->vrrp_index_fd, 1024+1);
 
322
        free_list(vrrp_data_obj->vrrp);
 
323
        free_list(vrrp_data_obj->vrrp_sync_group);
 
324
        free_list(vrrp_data_obj->vrrp_socket_pool);
 
325
        FREE(vrrp_data_obj);
295
326
}
296
327
 
297
328
void
298
 
dump_vrrp_data(vrrp_conf_data * vrrp_data)
 
329
dump_vrrp_data(vrrp_conf_data * vrrp_data_obj)
299
330
{
300
 
        if (!LIST_ISEMPTY(vrrp_data->static_addresses)) {
 
331
        if (!LIST_ISEMPTY(vrrp_data_obj->static_addresses)) {
301
332
                syslog(LOG_INFO, "------< Static Addresses >------");
302
 
                dump_list(vrrp_data->static_addresses);
 
333
                dump_list(vrrp_data_obj->static_addresses);
303
334
        }
304
 
        if (!LIST_ISEMPTY(vrrp_data->static_routes)) {
 
335
        if (!LIST_ISEMPTY(vrrp_data_obj->static_routes)) {
305
336
                syslog(LOG_INFO, "------< Static Routes >------");
306
 
                dump_list(vrrp_data->static_routes);
 
337
                dump_list(vrrp_data_obj->static_routes);
307
338
        }
308
 
        if (!LIST_ISEMPTY(vrrp_data->vrrp)) {
 
339
        if (!LIST_ISEMPTY(vrrp_data_obj->vrrp)) {
309
340
                syslog(LOG_INFO, "------< VRRP Topology >------");
310
 
                dump_list(vrrp_data->vrrp);
 
341
                dump_list(vrrp_data_obj->vrrp);
311
342
        }
312
 
        if (!LIST_ISEMPTY(vrrp_data->vrrp_sync_group)) {
 
343
        if (!LIST_ISEMPTY(vrrp_data_obj->vrrp_sync_group)) {
313
344
                syslog(LOG_INFO, "------< VRRP Sync groups >------");
314
 
                dump_list(vrrp_data->vrrp_sync_group);
 
345
                dump_list(vrrp_data_obj->vrrp_sync_group);
315
346
        }
316
347
}