From 3c7fdf058f5512da574e9638f4d72918425b48a0 Mon Sep 17 00:00:00 2001 From: Quentin Armitage Date: Sun, 1 Nov 2015 20:11:40 +0000 Subject: Leave VRRP multicast group by ifindex Since we know the interface index, use that instead of the address since it is more efficient. Also, in the unlikely event that the interface doesn't have an address, then this avoids a problem. Signed-off-by: Quentin Armitage (cherry picked from commit cdb75d4fe12d2dff35d3bc99f31416dd1b78c8d2) --- keepalived/vrrp/vrrp_if.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keepalived/vrrp/vrrp_if.c b/keepalived/vrrp/vrrp_if.c index 8374df1..9355a5c 100644 --- a/keepalived/vrrp/vrrp_if.c +++ b/keepalived/vrrp/vrrp_if.c @@ -488,7 +488,7 @@ if_join_vrrp_group(sa_family_t family, int *sd, interface_t *ifp, int proto) int if_leave_vrrp_group(sa_family_t family, int sd, interface_t *ifp) { - struct ip_mreq imr; + struct ip_mreqn imr; struct ipv6_mreq imr6; int ret = 0; @@ -500,9 +500,9 @@ if_leave_vrrp_group(sa_family_t family, int sd, interface_t *ifp) if (family == AF_INET) { memset(&imr, 0, sizeof(imr)); imr.imr_multiaddr = ((struct sockaddr_in *) &global_data->vrrp_mcast_group4)->sin_addr; - imr.imr_interface.s_addr = IF_ADDR(ifp); + imr.imr_ifindex = IF_INDEX(ifp); ret = setsockopt(sd, IPPROTO_IP, IP_DROP_MEMBERSHIP, - (char *) &imr, sizeof(struct ip_mreq)); + (char *) &imr, sizeof(imr)); } else { memset(&imr6, 0, sizeof(imr6)); imr6.ipv6mr_multiaddr = ((struct sockaddr_in6 *) &global_data->vrrp_mcast_group6)->sin6_addr; -- 1.7.12.1