コード例 #1
0
ファイル: vrrp_parser.c プロジェクト: Olipro/keepalived
static void
vrrp_vmac_handler(vector_t *strvec)
{
	vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	vrrp->vmac |= 1;
	if (!vrrp->saddr)
		vrrp->saddr  = IF_ADDR(vrrp->ifp);
	if (vector_size(strvec) == 2) {
		strncpy(vrrp->vmac_ifname, vector_slot(strvec, 1),
			IFNAMSIZ - 1);
	} else if (vrrp->vrid) {
		snprintf(vrrp->vmac_ifname, IFNAMSIZ, "vrrp.%d", vrrp->vrid);
	}

	if (strlen(vrrp->vmac_ifname)) {
		log_message(LOG_INFO, "vmac_ifname=%s for vrrp_instace %s"
				    , vrrp->vmac_ifname
				    , vrrp->iname);
	}
	if (vrrp->ifp && !(vrrp->vmac & 2)) {
		unsigned int base_ifindex = vrrp->ifp->base_ifindex;
		netlink_link_add_vmac(vrrp);
		/* restore base ifindex (deleted when adding VMAC) */
		vrrp->ifp->base_ifindex = base_ifindex;
        }

        /* flag interface as a VMAC interface */
        vrrp->ifp->vmac = 1;
}
コード例 #2
0
static void
vrrp_int_handler(vector strvec)
{
	vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	char *name = VECTOR_SLOT(strvec, 1);
	vrrp->ifp = if_get_by_ifname(name);
	vrrp->xmit_ifp = vrrp->ifp;
	if (vrrp->vmac && !(vrrp->vmac & 2))
		netlink_link_add_vmac(vrrp);
}
コード例 #3
0
ファイル: vrrp_parser.c プロジェクト: Olipro/keepalived
static void
vrrp_int_handler(vector_t *strvec)
{
	vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	char *name = vector_slot(strvec, 1);
	unsigned int ifindex;

	vrrp->ifp = if_get_by_ifname(name);
	ifindex = vrrp->ifp->ifindex;
	if (vrrp->vmac && !(vrrp->vmac & 2))
		netlink_link_add_vmac(vrrp);

	/* save base ifindex (only used for VMAC interfaces) */
	vrrp->ifp->base_ifindex = ifindex;
}
コード例 #4
0
static void
vrrp_int_handler(vector_t *strvec)
{
	vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	char *name = vector_slot(strvec, 1);

	vrrp->ifp = if_get_by_ifname(name);
	if (!vrrp->ifp) {
		log_message(LOG_INFO, "Cant find interface %s for vrrp_instance %s !!!"
				    , name, vrrp->iname);
		return;
	}

	if (vrrp->vmac_flags & VRRP_VMAC_FL_SET) {
		netlink_link_add_vmac(vrrp);
	}
}
コード例 #5
0
static void
vrrp_vmac_handler(vector_t *strvec)
{
	vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	vrrp->vmac_flags |= VRRP_VMAC_FL_SET;
	if (!vrrp->saddr.ss_family && vrrp->family == AF_INET)
		inet_ip4tosockaddr(IF_ADDR(vrrp->ifp), &vrrp->saddr);
	if (vector_size(strvec) == 2) {
		strncpy(vrrp->vmac_ifname, vector_slot(strvec, 1),
			IFNAMSIZ - 1);
	} else if (vrrp->vrid) {
		snprintf(vrrp->vmac_ifname, IFNAMSIZ, "vrrp.%d", vrrp->vrid);
	} else {
		return;
	}

	netlink_link_add_vmac(vrrp);
}
コード例 #6
0
static void
vrrp_vmac_handler(vector strvec)
{
	vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	vrrp->vmac = 1;
	if (!(vrrp->mcast_saddr))
		vrrp->mcast_saddr  = IF_ADDR(vrrp->ifp);
	if (strvec && (strvec->allocated == 2))
		strncpy(vrrp->vmac_ifname, VECTOR_SLOT(strvec, 1),
			IFNAMSIZ - 1);
	else 
		snprintf(vrrp->vmac_ifname, IFNAMSIZ, "vrrp.%d", vrrp->vrid);
	log_message(LOG_INFO, "vrrp_vmac_handler: vmac ifname is %s",
			    vrrp->vmac_ifname);

	if (vrrp->ifp && !(vrrp->vmac & 2))
		netlink_link_add_vmac(vrrp);
}
コード例 #7
0
static void
vrrp_vrid_handler(vector_t *strvec)
{
	vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
	vrrp->vrid = atoi(vector_slot(strvec, 1));

	if (VRRP_IS_BAD_VID(vrrp->vrid)) {
		log_message(LOG_INFO, "VRRP Error : VRID not valid !");
		log_message(LOG_INFO,
		       "             must be between 1 & 255. reconfigure !");
	} else {
		alloc_vrrp_bucket(vrrp);
		if (vrrp->vmac_flags & VRRP_VMAC_FL_SET) {
			if (strlen(vrrp->vmac_ifname) == 0)
				snprintf(vrrp->vmac_ifname, IFNAMSIZ, "vrrp.%d", vrrp->vrid);
			netlink_link_add_vmac(vrrp);
		}
	}
}