Skip to content

Commit

Permalink
vrrp: Don't send IPv6 advert from interface with no address
Browse files Browse the repository at this point in the history
If an interface has no IPv6 address, no advert can be sent. Rather
that logging an error when the send fails, simply don't send the
advert.

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
  • Loading branch information
pqarmitage committed Oct 15, 2023
1 parent 0b3265b commit e73702a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions keepalived/core/keepalived_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,14 @@ netlink_if_address_filter(__attribute__((unused)) struct sockaddr_nl *snl, struc
IF_ISUP(ifp)) &&
#endif
(!__test_bit(VRRP_FLAG_SADDR_FROM_CONFIG, &vrrp->flags) || is_tracking_saddr)) {
/* Don't attempt to send an IPv6 advert if no address on the interface */
if (vrrp->saddr.ss_family == AF_INET6
#ifdef _HAVE_VRRP_VMAC_
&& !__test_bit(VRRP_VMAC_XMITBASE_BIT, &vrrp->flags)
#endif
)
vrrp->saddr.ss_family = AF_UNSPEC;

down_instance(vrrp);
vrrp->saddr.ss_family = AF_UNSPEC;
}
Expand Down
5 changes: 4 additions & 1 deletion keepalived/vrrp/vrrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,10 @@ vrrp_state_leave_master(vrrp_t * vrrp, bool advF)
}
else if (vrrp->wantstate == VRRP_STATE_FAULT) {
log_message(LOG_INFO, "(%s) Entering FAULT STATE", vrrp->iname);
vrrp_send_adv(vrrp, VRRP_PRIO_STOP);

/* If there is no address on the interface we cannot sent an IPv6 advert */
if (vrrp->family == AF_INET || vrrp->saddr.ss_family != AF_UNSPEC)
vrrp_send_adv(vrrp, VRRP_PRIO_STOP);
}
else {
log_message(LOG_INFO, "(%s) vrrp_state_leave_master called with invalid wantstate %d", vrrp->iname, vrrp->wantstate);
Expand Down

0 comments on commit e73702a

Please sign in to comment.