Skip to content

Commit

Permalink
vrrp: Go to fault state if fail to add IPv6 link-local address to VMAC
Browse files Browse the repository at this point in the history
If an IPv6 VRRP instance uses a VMAC, but adding a link-local address
to the interface fails, then the vrrp instance now transitions to
fault state, just as happens if the link-local address is removed after
it has been added.

Signed-off-by: Quentin Armitage <[email protected]>
  • Loading branch information
pqarmitage committed Oct 15, 2023
1 parent f2b9789 commit 0b3265b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions keepalived/vrrp/vrrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4292,8 +4292,7 @@ set_vrrp_src_addr(void)
if (vrrp->family == AF_INET) {
if (!(VRRP_CONFIGURED_IFP(vrrp))->sin_addr.s_addr)
addr_missing = true;
}
else {
} else {
#ifdef _HAVE_VRRP_VMAC_
if (!__test_bit(VRRP_VMAC_BIT, &vrrp->flags))
#endif
Expand All @@ -4311,8 +4310,13 @@ set_vrrp_src_addr(void)
else if (vrrp->family == AF_INET)
inet_ip4tosockaddr(&VRRP_CONFIGURED_IFP(vrrp)->sin_addr, &vrrp->saddr);
else if (vrrp->family == AF_INET6) {
#ifdef _HAVE_VRRP_VMAC_
if (!__test_bit(VRRP_VMAC_XMITBASE_BIT, &vrrp->flags) &&
(
#ifdef _HAVE_VRRP_IPVLAN_
if (__test_bit(VRRP_IPVLAN_BIT, &vrrp->flags)) {
__test_bit(VRRP_IPVLAN_BIT, &vrrp->flags) ||
#endif
__test_bit(VRRP_VMAC_BIT, &vrrp->flags))) {
if (!IN6_IS_ADDR_UNSPECIFIED(&vrrp->ifp->sin6_addr))
inet_ip6tosockaddr(&vrrp->ifp->sin6_addr, &vrrp->saddr);
} else
Expand Down
7 changes: 5 additions & 2 deletions keepalived/vrrp/vrrp_vmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ netlink_link_add_vmac(vrrp_t *vrrp, const interface_t *old_interface)
} req;
u_char if_ll_addr[ETH_ALEN];
bool update_interface = false;
bool ret = true;

if (!vrrp->ifp || __test_bit(VRRP_VMAC_UP_BIT, &vrrp->flags) || !vrrp->vrid)
return false;
Expand Down Expand Up @@ -495,8 +496,10 @@ netlink_link_add_vmac(vrrp_t *vrrp, const interface_t *old_interface)

if (vrrp->family == AF_INET6 &&
!__test_bit(VRRP_VMAC_XMITBASE_BIT, &vrrp->flags)) {
if (!set_link_local_address(vrrp) && create_interface)
if (!set_link_local_address(vrrp) && create_interface) {
log_message(LOG_INFO, "(%s) adding link-local address to %s failed", vrrp->iname, vrrp->ifp->ifname);
ret = false;
}
}

/* If the base interface does not implement IFF_UNICAST_FLT, for example
Expand Down Expand Up @@ -543,7 +546,7 @@ netlink_link_add_vmac(vrrp_t *vrrp, const interface_t *old_interface)
* as we progress */
kernel_netlink_poll();

return true;
return ret;
}

#ifdef _INCLUDE_UNUSED_CODE_
Expand Down

0 comments on commit 0b3265b

Please sign in to comment.