bgpd: add debug option for BFD

Add new BGP debug option to enable BFD related debugging messages.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
This commit is contained in:
Rafael Zalamena 2021-03-01 16:07:28 -03:00
parent 21bfce9827
commit 259f42367c
3 changed files with 53 additions and 8 deletions

View File

@ -51,7 +51,7 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,
{
struct peer *peer = arg;
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug("%s: neighbor %s vrf %s(%u) bfd state %s -> %s",
__func__, peer->conf_if ? peer->conf_if : peer->host,
bfd_sess_vrf(bsp), bfd_sess_vrf_id(bsp),
@ -61,7 +61,7 @@ static void bfd_session_status_update(struct bfd_session_params *bsp,
if (bss->state == BSS_DOWN && bss->previous_state == BSS_UP) {
if (CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_MODE)
&& bfd_sess_cbit(bsp) && !bss->remote_cbit) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_info(
"%s BFD DOWN message ignored in the process of graceful restart when C bit is cleared",
peer->host);
@ -167,7 +167,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
if ((p->su_local
&& p->su_local->sin.sin_addr.s_addr != src.v4.s_addr)
|| p->su.sin.sin_addr.s_addr != dst.v4.s_addr) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug(
"%s: address [%pI4->%pI4] to [%pI4->%pI4]",
__func__, &src.v4, &dst.v4,
@ -185,7 +185,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
if ((p->su_local
&& memcmp(&p->su_local->sin6, &src.v6, sizeof(src.v6)))
|| memcmp(&p->su.sin6, &dst.v6, sizeof(dst.v6))) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug(
"%s: address [%pI6->%pI6] to [%pI6->%pI6]",
__func__, &src.v6, &dst.v6,
@ -205,7 +205,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
/* Update interface. */
if (p->nexthop.ifp && bfd_sess_interface(session) == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug("%s: interface none to %s", __func__,
p->nexthop.ifp->name);
@ -222,7 +222,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
* - eBGP multi hop / TTL security changed.
*/
if (!PEER_IS_MULTIHOP(p) && bfd_sess_hop_count(session) > 1) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug("%s: TTL %d to 1", __func__,
bfd_sess_hop_count(session));
@ -230,7 +230,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
changed = true;
}
if (PEER_IS_MULTIHOP(p) && p->ttl != bfd_sess_hop_count(session)) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug("%s: TTL %d to %d", __func__,
bfd_sess_hop_count(session), p->ttl);
@ -240,7 +240,7 @@ void bgp_peer_bfd_update_source(struct peer *p)
/* Update VRF. */
if (bfd_sess_vrf_id(session) != p->bgp->vrf_id) {
if (BGP_DEBUG(zebra, ZEBRA))
if (BGP_DEBUG(bfd, BFD_LIB))
zlog_debug(
"%s: VRF %s(%d) to %s(%d)", __func__,
bfd_sess_vrf(session), bfd_sess_vrf_id(session),

View File

@ -21,6 +21,7 @@
#include <zebra.h>
#include <lib/version.h>
#include "lib/bfd.h"
#include "lib/printfrr.h"
#include "prefix.h"
#include "linklist.h"
@ -67,6 +68,7 @@ unsigned long conf_bgp_debug_labelpool;
unsigned long conf_bgp_debug_pbr;
unsigned long conf_bgp_debug_graceful_restart;
unsigned long conf_bgp_debug_evpn_mh;
unsigned long conf_bgp_debug_bfd;
unsigned long term_bgp_debug_as4;
unsigned long term_bgp_debug_neighbor_events;
@ -86,6 +88,7 @@ unsigned long term_bgp_debug_labelpool;
unsigned long term_bgp_debug_pbr;
unsigned long term_bgp_debug_graceful_restart;
unsigned long term_bgp_debug_evpn_mh;
unsigned long term_bgp_debug_bfd;
struct list *bgp_debug_neighbor_events_peers = NULL;
struct list *bgp_debug_keepalive_peers = NULL;
@ -2093,6 +2096,31 @@ DEFUN (no_debug_bgp_labelpool,
return CMD_SUCCESS;
}
DEFPY(debug_bgp_bfd, debug_bgp_bfd_cmd,
"[no] debug bgp bfd",
NO_STR
DEBUG_STR
BGP_STR
"Bidirection Forwarding Detection\n")
{
if (vty->node == CONFIG_NODE) {
if (no) {
DEBUG_OFF(bfd, BFD_LIB);
bfd_protocol_integration_set_debug(false);
} else {
DEBUG_ON(bfd, BFD_LIB);
bfd_protocol_integration_set_debug(true);
}
} else {
if (no)
TERM_DEBUG_OFF(bfd, BFD_LIB);
else
TERM_DEBUG_ON(bfd, BFD_LIB);
}
return CMD_SUCCESS;
}
DEFUN (no_debug_bgp,
no_debug_bgp_cmd,
"no debug bgp",
@ -2136,6 +2164,7 @@ DEFUN (no_debug_bgp,
TERM_DEBUG_OFF(graceful_restart, GRACEFUL_RESTART);
TERM_DEBUG_OFF(evpn_mh, EVPN_MH_ES);
TERM_DEBUG_OFF(evpn_mh, EVPN_MH_RT);
TERM_DEBUG_OFF(bfd, BFD_LIB);
vty_out(vty, "All possible debugging has been turned off\n");
@ -2225,6 +2254,9 @@ DEFUN_NOSH (show_debugging_bgp,
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
vty_out(vty, " BGP EVPN-MH route debugging is on\n");
if (BGP_DEBUG(bfd, BFD_LIB))
vty_out(vty, " BGP BFD library debugging is on\n");
vty_out(vty, "\n");
return CMD_SUCCESS;
}
@ -2350,6 +2382,11 @@ static int bgp_config_write_debug(struct vty *vty)
write++;
}
if (CONF_BGP_DEBUG(bfd, BFD_LIB)) {
vty_out(vty, "debug bgp bfd\n");
write++;
}
return write;
}
@ -2478,6 +2515,10 @@ void bgp_debug_init(void)
install_element(ENABLE_NODE, &debug_bgp_evpn_mh_cmd);
install_element(CONFIG_NODE, &debug_bgp_evpn_mh_cmd);
/* debug bgp bfd */
install_element(ENABLE_NODE, &debug_bgp_bfd_cmd);
install_element(CONFIG_NODE, &debug_bgp_bfd_cmd);
}
/* Return true if this prefix is on the per_prefix_list of prefixes to debug

View File

@ -78,6 +78,7 @@ extern unsigned long conf_bgp_debug_labelpool;
extern unsigned long conf_bgp_debug_pbr;
extern unsigned long conf_bgp_debug_graceful_restart;
extern unsigned long conf_bgp_debug_evpn_mh;
extern unsigned long conf_bgp_debug_bfd;
extern unsigned long term_bgp_debug_as4;
extern unsigned long term_bgp_debug_neighbor_events;
@ -95,6 +96,7 @@ extern unsigned long term_bgp_debug_labelpool;
extern unsigned long term_bgp_debug_pbr;
extern unsigned long term_bgp_debug_graceful_restart;
extern unsigned long term_bgp_debug_evpn_mh;
extern unsigned long term_bgp_debug_bfd;
extern struct list *bgp_debug_neighbor_events_peers;
extern struct list *bgp_debug_keepalive_peers;
@ -139,6 +141,8 @@ struct bgp_debug_filter {
#define BGP_DEBUG_GRACEFUL_RESTART 0x01
#define BGP_DEBUG_BFD_LIB 0x01
#define CONF_DEBUG_ON(a, b) (conf_bgp_debug_ ## a |= (BGP_DEBUG_ ## b))
#define CONF_DEBUG_OFF(a, b) (conf_bgp_debug_ ## a &= ~(BGP_DEBUG_ ## b))