From 67275d23aaef66c8b0ab854db93a1a3dd0e5124e Mon Sep 17 00:00:00 2001 From: Quentin Armitage Date: Thu, 31 Aug 2017 08:56:37 +0100 Subject: [PATCH] Fix calculation of checksum for VRRPv3 IPv4 unicast peers Alternate unicast peers were being sent adverts with the checksum set to 0. The reason for this was that the checksum field was not being set to 0 before the checksum calculation, hence causing the calculated checksum to be 0 for the second, fourth, sixth etc unicast peer. Signed-off-by: Quentin Armitage --- keepalived/vrrp/vrrp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/keepalived/vrrp/vrrp.c b/keepalived/vrrp/vrrp.c index a297c5e..0813a00 100644 --- a/keepalived/vrrp/vrrp.c +++ b/keepalived/vrrp/vrrp.c @@ -965,6 +965,10 @@ vrrp_build_vrrp_v3(vrrp_t *vrrp, uint8_t prio, char *buffer) hd->naddr = (uint8_t)((!LIST_ISEMPTY(vrrp->vip)) ? LIST_SIZE(vrrp->vip) : 0); hd->v3.adver_int = htons((vrrp->adver_int / TIMER_CENTI_HZ) & 0x0FFF); /* interval in centiseconds, reserved bits zero */ + /* For IPv4 to calculate the checksum, the value must start as 0. + * For IPv6, the kernel will update checksum field. */ + hd->chksum = 0; + /* Family specific */ if (vrrp->family == AF_INET) { /* copy the ip addresses */ @@ -994,8 +998,6 @@ vrrp_build_vrrp_v3(vrrp_t *vrrp, uint8_t prio, char *buffer) ip6arr[i++] = ip_addr->u.sin6_addr; } } - /* Kernel will update checksum field. let it be 0 now. */ - hd->chksum = 0; } return 0; -- 2.9.5