/* Set instances group pointer */ void vrrp_sync_set_group(vrrp_sgroup_t *vgroup) { vrrp_t *vrrp; char *str; int i; for (i = 0; i < vector_size(vgroup->iname); i++) { str = vector_slot(vgroup->iname, i); vrrp = vrrp_get_instance(str); if (vrrp) { if (LIST_ISEMPTY(vgroup->index_list)) vgroup->index_list = alloc_list(NULL, NULL); list_add(vgroup->index_list, vrrp); vrrp->sync = vgroup; } } }
/* Set instances group pointer */ void vrrp_sync_set_group(vrrp_sgroup *vgroup) { vrrp_rt *vrrp; char *str; int i; for (i = 0; i < VECTOR_SIZE(vgroup->iname); i++) { str = VECTOR_SLOT(vgroup->iname, i); vrrp = vrrp_get_instance(str); if (vrrp) { if (LIST_ISEMPTY(vgroup->index_list)) vgroup->index_list = alloc_list(NULL, NULL); list_add(vgroup->index_list, vrrp); vrrp->sync = vgroup; } } }
/* Set instances group pointer */ void vrrp_sync_set_group(vrrp_sgroup_t *vgroup) { vrrp_t *vrrp; char *str; unsigned int i; vrrp_t *vrrp_last = NULL; /* Can't handle no members of the group */ if (!vgroup->iname) return; vgroup->index_list = alloc_list(NULL, NULL); for (i = 0; i < vector_size(vgroup->iname); i++) { str = vector_slot(vgroup->iname, i); vrrp = vrrp_get_instance(str); if (vrrp) { if (vrrp->sync) log_message(LOG_INFO, "Virtual router %s cannot exist in more than one sync group; ignoring %s", str, vgroup->gname); else { list_add(vgroup->index_list, vrrp); vrrp->sync = vgroup; vrrp_last = vrrp; } } else log_message(LOG_INFO, "Virtual router %s specified in sync group %s doesn't exist - ignoring", str, vgroup->gname); } if (LIST_SIZE(vgroup->index_list) <= 1) { /* The sync group will be removed by the calling function */ log_message(LOG_INFO, "Sync group %s has only %d virtual router(s) - removing", vgroup->gname, LIST_SIZE(vgroup->index_list)); /* If there is only one entry in the group, remove the group from the vrrp entry */ if (vrrp_last) vrrp_last->sync = NULL; } }