~keepalived/keepalived/unicast

« back to all changes in this revision

Viewing changes to keepalived/vrrp/vrrp_data.c

  • Committer: Ryan O'Hara
  • Date: 2012-10-23 19:14:21 UTC
  • Revision ID: git-v1:4f8e63b03eb3e360ea94142023dd9055517ce6fb
Add support for VRRP unicast

This patch adds the ability to use VRRP over unicast. Unicast IP
addresses may be specified for each VRRP instance with the 'unicast'
option. When a VRRP instance has one or more unicast IP address defined,
VRRP advertisements will be sent to each of those addresses. Unicast IP
addresses may be either IPv4 or IPv6.

Signed-off-by: Ryan O'Hara <rohara@redhat.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
        interface *ifp;
143
143
        if (sock->fd_in > 0) {
144
144
                ifp = if_get_by_ifindex(sock->ifindex);
145
 
                if_leave_vrrp_group(sock->family, sock->fd_in, ifp);
 
145
                if (!sock->unicast) {
 
146
                        if_leave_vrrp_group(sock->family, sock->fd_in, ifp);
 
147
                } else {
 
148
                        close(sock->fd_in);
 
149
                }
146
150
        }
147
151
        if (sock->fd_out > 0)
148
152
                close(sock->fd_out);
153
157
dump_sock(void *sock_data)
154
158
{
155
159
        sock_t *sock = sock_data;
156
 
        log_message(LOG_INFO, "VRRP sockpool: [ifindex(%d), proto(%d), fd(%d,%d)]"
 
160
        log_message(LOG_INFO, "VRRP sockpool: [ifindex(%d), unicast(%d), proto(%d), fd(%d,%d)]"
157
161
                            , sock->ifindex
 
162
                            , sock->unicast
158
163
                            , sock->proto
159
164
                            , sock->fd_in
160
165
                            , sock->fd_out);
189
194
        free_list(vrrp->vip);
190
195
        free_list(vrrp->evip);
191
196
        free_list(vrrp->vroutes);
 
197
        free_list(vrrp->unicast);
192
198
        FREE(vrrp);
193
199
}
194
200
static void
255
261
                log_message(LOG_INFO, "   Virtual Routes = %d", LIST_SIZE(vrrp->vroutes));
256
262
                dump_list(vrrp->vroutes);
257
263
        }
 
264
        if (!LIST_ISEMPTY(vrrp->unicast)) {
 
265
                log_message(LOG_INFO, "   Unicast IP = %d", LIST_SIZE(vrrp->unicast));
 
266
                dump_list(vrrp->unicast);
 
267
        }
258
268
        if (vrrp->script_backup)
259
269
                log_message(LOG_INFO, "   Backup state transition script = %s",
260
270
                       vrrp->script_backup);
368
378
}
369
379
 
370
380
void
 
381
alloc_vrrp_unicast(vector_t *strvec)
 
382
{
 
383
        vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
 
384
 
 
385
        if (LIST_ISEMPTY(vrrp->unicast))
 
386
                vrrp->unicast = alloc_list(free_unicast, dump_unicast);
 
387
        alloc_unicast(vrrp->unicast, strvec);
 
388
}
 
389
 
 
390
void
371
391
alloc_vrrp_script(char *sname)
372
392
{
373
393
        int size = strlen(sname);