vrrpd: some more error logging fixes

- Give the correct log message when refusing to start because the vr is
  already started
- Fix a couple other : whynot; cases missed

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2019-10-29 18:47:04 +00:00
parent 05baa0e0fb
commit d8b92c67bf

View file

@ -281,7 +281,7 @@ void vrrp_check_start(struct vrrp_vrouter *vr)
{ {
struct vrrp_router *r; struct vrrp_router *r;
bool start; bool start;
const char *whynot; const char *whynot = NULL;
if (vr->shutdown || vr->ifp == NULL) if (vr->shutdown || vr->ifp == NULL)
return; return;
@ -289,13 +289,14 @@ void vrrp_check_start(struct vrrp_vrouter *vr)
r = vr->v4; r = vr->v4;
/* Must not already be started */ /* Must not already be started */
start = r->fsm.state == VRRP_STATE_INITIALIZE; start = r->fsm.state == VRRP_STATE_INITIALIZE;
whynot = NULL; whynot = (!start && !whynot) ? "Already running" : whynot;
/* Must have a parent interface */ /* Must have a parent interface */
start = start && (vr->ifp != NULL); start = start && (vr->ifp != NULL);
whynot = (!start && !whynot) ? "No base interface" : whynot; whynot = (!start && !whynot) ? "No base interface" : whynot;
#if 0 #if 0
/* Parent interface must be up */ /* Parent interface must be up */
start = start && if_is_operative(vr->ifp); start = start && if_is_operative(vr->ifp);
start = (!start && !whynot) ? "Base interface inoperative" : whynot;
#endif #endif
/* Parent interface must have at least one v4 */ /* Parent interface must have at least one v4 */
start = start && connected_count_by_family(vr->ifp, AF_INET) > 0; start = start && connected_count_by_family(vr->ifp, AF_INET) > 0;
@ -306,6 +307,7 @@ void vrrp_check_start(struct vrrp_vrouter *vr)
#if 0 #if 0
/* Macvlan interface must be admin up */ /* Macvlan interface must be admin up */
start = start && CHECK_FLAG(r->mvl_ifp->flags, IFF_UP); start = start && CHECK_FLAG(r->mvl_ifp->flags, IFF_UP);
start = (!start && !whynot) ? "Macvlan device admin down" : whynot;
#endif #endif
/* Must have at least one VIP configured */ /* Must have at least one VIP configured */
start = start && r->addrs->count > 0; start = start && r->addrs->count > 0;
@ -318,10 +320,12 @@ void vrrp_check_start(struct vrrp_vrouter *vr)
"Refusing to start Virtual Router: %s", "Refusing to start Virtual Router: %s",
vr->vrid, family2str(r->family), whynot); vr->vrid, family2str(r->family), whynot);
whynot = NULL;
r = vr->v6; r = vr->v6;
/* Must not already be started */ /* Must not already be started */
start = r->fsm.state == VRRP_STATE_INITIALIZE; start = r->fsm.state == VRRP_STATE_INITIALIZE;
whynot = NULL; whynot = (!start && !whynot) ? "Already running" : whynot;
/* Must not be v2 */ /* Must not be v2 */
start = start && vr->version != 2; start = start && vr->version != 2;
whynot = (!start && !whynot) ? "VRRPv2 does not support v6" : whynot; whynot = (!start && !whynot) ? "VRRPv2 does not support v6" : whynot;
@ -331,6 +335,7 @@ void vrrp_check_start(struct vrrp_vrouter *vr)
#if 0 #if 0
/* Parent interface must be up */ /* Parent interface must be up */
start = start && if_is_operative(vr->ifp); start = start && if_is_operative(vr->ifp);
start = (!start && !whynot) ? "Base interface inoperative" : whynot;
#endif #endif
/* Must have a macvlan interface */ /* Must have a macvlan interface */
start = start && (r->mvl_ifp != NULL); start = start && (r->mvl_ifp != NULL);
@ -338,6 +343,7 @@ void vrrp_check_start(struct vrrp_vrouter *vr)
#if 0 #if 0
/* Macvlan interface must be admin up */ /* Macvlan interface must be admin up */
start = start && CHECK_FLAG(r->mvl_ifp->flags, IFF_UP); start = start && CHECK_FLAG(r->mvl_ifp->flags, IFF_UP);
start = (!start && !whynot) ? "Macvlan device admin down" : whynot;
/* Macvlan interface must have a link local */ /* Macvlan interface must have a link local */
start = start && connected_get_linklocal(r->mvl_ifp); start = start && connected_get_linklocal(r->mvl_ifp);
whynot = whynot =