From e73702a7b1f02c50f903faceeabd23ab099b0fdc Mon Sep 17 00:00:00 2001 From: Quentin Armitage Date: Sun, 15 Oct 2023 14:29:21 +0100 Subject: [PATCH] vrrp: Don't send IPv6 advert from interface with no address 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 --- keepalived/core/keepalived_netlink.c | 8 ++++++++ keepalived/vrrp/vrrp.c | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/keepalived/core/keepalived_netlink.c b/keepalived/core/keepalived_netlink.c index 1bde1e63a..251b353d9 100644 --- a/keepalived/core/keepalived_netlink.c +++ b/keepalived/core/keepalived_netlink.c @@ -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; } diff --git a/keepalived/vrrp/vrrp.c b/keepalived/vrrp/vrrp.c index 1accd7576..e0891a669 100644 --- a/keepalived/vrrp/vrrp.c +++ b/keepalived/vrrp/vrrp.c @@ -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);