staticd: add debug static bfd command

This command helps in troubleshooting static bfd feature.
Add traces upon bfd events.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Philippe Guibert 2021-09-28 14:53:23 +02:00 committed by Rafael Zalamena
parent 771fdeaf39
commit b27499d6ba
4 changed files with 25 additions and 10 deletions

View File

@ -28,6 +28,7 @@
#include "staticd/static_routes.h"
#include "staticd/static_zebra.h"
#include "staticd/static_debug.h"
#include "lib/openbsd-queue.h"
@ -45,13 +46,15 @@ static void static_next_hop_bfd_change(struct static_nexthop *sn,
break;
case BSS_DOWN:
/* Peer went down, remove this next hop. */
zlog_info("%s: next hop is down, remove it from RIB", __func__);
DEBUGD(&static_dbg_bfd,
"%s: next hop is down, remove it from RIB", __func__);
sn->path_down = true;
static_zebra_route_add(sn->pn, true);
break;
case BSS_UP:
/* Peer is back up, add this next hop. */
zlog_info("%s: next hop is up, add it to RIB", __func__);
DEBUGD(&static_dbg_bfd, "%s: next hop is up, add it to RIB",
__func__);
sn->path_down = false;
static_zebra_route_add(sn->pn, true);
break;

View File

@ -24,6 +24,7 @@
#include "lib/command.h"
#include "lib/debug.h"
#include "lib/bfd.h"
#include "static_debug.h"
@ -35,15 +36,18 @@
/* clang-format off */
struct debug static_dbg_events = {0, "Staticd events"};
struct debug static_dbg_route = {0, "Staticd route"};
struct debug static_dbg_bfd = {0, "Staticd bfd"};
struct debug *static_debug_arr[] = {
&static_dbg_events,
&static_dbg_route
&static_dbg_route,
&static_dbg_bfd
};
const char *static_debugs_conflines[] = {
"debug static events",
"debug static route"
"debug static route",
"debug static bfd"
};
/* clang-format on */
@ -105,7 +109,8 @@ int static_debug_status_write(struct vty *vty)
* Debug general internal events
*
*/
void static_debug_set(int vtynode, bool onoff, bool events, bool route)
void static_debug_set(int vtynode, bool onoff, bool events, bool route,
bool bfd)
{
uint32_t mode = DEBUG_NODE2MODE(vtynode);
@ -113,6 +118,10 @@ void static_debug_set(int vtynode, bool onoff, bool events, bool route)
DEBUG_MODE_SET(&static_dbg_events, mode, onoff);
if (route)
DEBUG_MODE_SET(&static_dbg_route, mode, onoff);
if (bfd) {
DEBUG_MODE_SET(&static_dbg_bfd, mode, onoff);
bfd_protocol_integration_set_debug(onoff);
}
}
/*

View File

@ -34,6 +34,7 @@ extern "C" {
/* staticd debugging records */
extern struct debug static_dbg_events;
extern struct debug static_dbg_route;
extern struct debug static_dbg_bfd;
/*
* Initialize staticd debugging.
@ -71,7 +72,8 @@ int static_debug_status_write(struct vty *vty);
* Debug general internal events
*
*/
void static_debug_set(int vtynode, bool onoff, bool events, bool route);
void static_debug_set(int vtynode, bool onoff, bool events, bool route,
bool bfd);
#ifdef __cplusplus
}

View File

@ -1457,16 +1457,17 @@ int static_path_list_cli_cmp(const struct lyd_node *dnode1,
}
DEFPY_YANG(debug_staticd, debug_staticd_cmd,
"[no] debug static [{events$events|route$route}]",
"[no] debug static [{events$events|route$route|bfd$bfd}]",
NO_STR DEBUG_STR STATICD_STR
"Debug events\n"
"Debug route\n")
"Debug route\n"
"Debug bfd\n")
{
/* If no specific category, change all */
if (strmatch(argv[argc - 1]->text, "static"))
static_debug_set(vty->node, !no, true, true);
static_debug_set(vty->node, !no, true, true, true);
else
static_debug_set(vty->node, !no, !!events, !!route);
static_debug_set(vty->node, !no, !!events, !!route, !!bfd);
return CMD_SUCCESS;
}