From 1b5e2a229dada21c07829e41275114f3c927f360 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 11 Feb 2019 21:22:05 +0000 Subject: [PATCH] vrrpd: set sockets to -1 after closing This also fixes a bug where assigning the same address as a VIP twice would succeed the second time even if it actually failed both times. Signed-off-by: Quentin Young --- vrrpd/vrrp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c index b01bcb939c..14347c239f 100644 --- a/vrrpd/vrrp.c +++ b/vrrpd/vrrp.c @@ -1001,10 +1001,14 @@ done: zlog_warn(VRRP_LOGPFX VRRP_LOGPFX_VRID "Failed to initialize VRRP %s router", r->vr->vrid, family2str(r->family)); - if (r->sock_rx >= 0) + if (r->sock_rx >= 0) { close(r->sock_rx); - if (r->sock_tx >= 0) + r->sock_rx = -1; + } + if (r->sock_tx >= 0) { close(r->sock_tx); + r->sock_tx = -1; + } ret = -1; } -- 2.39.5