diff options
| author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-03-04 15:15:00 -0300 | 
|---|---|---|
| committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-03-23 10:18:42 -0300 | 
| commit | e4505a2e6d9f89bbb7cab78a0b4063f319402c44 (patch) | |
| tree | 338719e6b8f48c6e1fb1db65706a9d8dec8376b5 | |
| parent | 8d69272b8ff4980b386924e94074049b2d6f6ae7 (diff) | |
ospfd: add debug option for BFD
Add specialized debug option for BFD which also enables library debugging.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| -rw-r--r-- | ospfd/ospf_bfd.c | 12 | ||||
| -rw-r--r-- | ospfd/ospf_dump.c | 44 | ||||
| -rw-r--r-- | ospfd/ospf_dump.h | 3 | 
3 files changed, 53 insertions, 6 deletions
diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index f4470ad833..123515e039 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -70,18 +70,18 @@ static void ospf_bfd_session_change(struct bfd_session_params *bsp,  	/* BFD peer went down. */  	if (bss->state == BFD_STATUS_DOWN  	    && bss->previous_state == BFD_STATUS_UP) { -		if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) -			zlog_debug("NSM[%s:%pI4]: BFD Down", IF_NAME(nbr->oi), -				   &nbr->address.u.prefix4); +		if (IS_DEBUG_OSPF(bfd, BFD_LIB)) +			zlog_debug("%s: NSM[%s:%pI4]: BFD Down", __func__, +				   IF_NAME(nbr->oi), &nbr->address.u.prefix4);  		OSPF_NSM_EVENT_SCHEDULE(nbr, NSM_InactivityTimer);  	}  	/* BFD peer went up. */  	if (bss->state == BSS_UP && bss->previous_state == BSS_DOWN) -		if (IS_DEBUG_OSPF(nsm, NSM_EVENTS)) -			zlog_debug("NSM[%s:%pI4]: BFD Up", IF_NAME(nbr->oi), -				   &nbr->address.u.prefix4); +		if (IS_DEBUG_OSPF(bfd, BFD_LIB)) +			zlog_debug("%s: NSM[%s:%pI4]: BFD Up", __func__, +				   IF_NAME(nbr->oi), &nbr->address.u.prefix4);  }  void ospf_neighbor_bfd_apply(struct ospf_neighbor *nbr) diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 19829d4546..cd4fbc6dcd 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -21,6 +21,7 @@  #include <zebra.h> +#include "lib/bfd.h"  #include "monotime.h"  #include "linklist.h"  #include "thread.h" @@ -60,6 +61,7 @@ unsigned long conf_debug_ospf_ti_lfa = 0;  unsigned long conf_debug_ospf_defaultinfo = 0;  unsigned long conf_debug_ospf_ldp_sync = 0;  unsigned long conf_debug_ospf_gr = 0; +unsigned long conf_debug_ospf_bfd = 0;  /* Enable debug option variables -- valid only session. */  unsigned long term_debug_ospf_packet[5] = {0, 0, 0, 0, 0}; @@ -76,6 +78,7 @@ unsigned long term_debug_ospf_ti_lfa = 0;  unsigned long term_debug_ospf_defaultinfo;  unsigned long term_debug_ospf_ldp_sync;  unsigned long term_debug_ospf_gr = 0; +unsigned long term_debug_ospf_bfd = 0;  const char *ospf_redist_string(unsigned int route_type)  { @@ -1563,6 +1566,31 @@ DEFPY (debug_ospf_gr,  	return CMD_SUCCESS;  } +DEFPY(debug_ospf_bfd, debug_ospf_bfd_cmd, +      "[no] debug ospf bfd", +      NO_STR +      DEBUG_STR +      OSPF_STR +      "Bidirection Forwarding Detection\n") +{ +	if (vty->node == CONFIG_NODE) { +		if (no) { +			bfd_protocol_integration_set_debug(false); +			CONF_DEBUG_OFF(bfd, BFD_LIB); +		} else { +			bfd_protocol_integration_set_debug(true); +			CONF_DEBUG_ON(bfd, BFD_LIB); +		} +	} + +	if (no) +		TERM_DEBUG_OFF(bfd, BFD_LIB); +	else +		TERM_DEBUG_ON(bfd, BFD_LIB); + +	return CMD_SUCCESS; +} +  DEFUN (no_debug_ospf,         no_debug_ospf_cmd,         "no debug ospf", @@ -1594,6 +1622,10 @@ DEFUN (no_debug_ospf,  		DEBUG_OFF(defaultinfo, DEFAULTINFO);  		DEBUG_OFF(ldp_sync, LDP_SYNC); +		/* BFD debugging is two parts: OSPF and library. */ +		DEBUG_OFF(bfd, BFD_LIB); +		bfd_protocol_integration_set_debug(false); +  		for (i = 0; i < 5; i++)  			DEBUG_PACKET_OFF(i, flag);  	} @@ -1621,6 +1653,7 @@ DEFUN (no_debug_ospf,  	TERM_DEBUG_OFF(zebra, ZEBRA_REDISTRIBUTE);  	TERM_DEBUG_OFF(defaultinfo, DEFAULTINFO);  	TERM_DEBUG_OFF(ldp_sync, LDP_SYNC); +	TERM_DEBUG_OFF(bfd, BFD_LIB);  	return CMD_SUCCESS;  } @@ -1730,6 +1763,10 @@ static int show_debugging_ospf_common(struct vty *vty)  	if (IS_DEBUG_OSPF(gr, GR_HELPER) == OSPF_DEBUG_GR_HELPER)  		vty_out(vty, "  OSPF Graceful Restart Helper debugging is on\n"); +	if (IS_DEBUG_OSPF(bfd, BFD_LIB) == OSPF_DEBUG_BFD_LIB) +		vty_out(vty, +			"  OSPF BFD integration library debugging is on\n"); +  	vty_out(vty, "\n");  	return CMD_SUCCESS; @@ -1917,6 +1954,11 @@ static int config_write_debug(struct vty *vty)  		write = 1;  	} +	if (IS_CONF_DEBUG_OSPF(bfd, BFD_LIB) == OSPF_DEBUG_BFD_LIB) { +		vty_out(vty, "debug ospf%s bfd\n", str); +		write = 1; +	} +  	return write;  } @@ -1949,6 +1991,7 @@ void ospf_debug_init(void)  	install_element(ENABLE_NODE, &no_debug_ospf_default_info_cmd);  	install_element(ENABLE_NODE, &no_debug_ospf_ldp_sync_cmd);  	install_element(ENABLE_NODE, &debug_ospf_gr_cmd); +	install_element(ENABLE_NODE, &debug_ospf_bfd_cmd);  	install_element(ENABLE_NODE, &show_debugging_ospf_instance_cmd);  	install_element(ENABLE_NODE, &debug_ospf_packet_cmd); @@ -1992,6 +2035,7 @@ void ospf_debug_init(void)  	install_element(CONFIG_NODE, &no_debug_ospf_default_info_cmd);  	install_element(CONFIG_NODE, &no_debug_ospf_ldp_sync_cmd);  	install_element(CONFIG_NODE, &debug_ospf_gr_cmd); +	install_element(CONFIG_NODE, &debug_ospf_bfd_cmd);  	install_element(CONFIG_NODE, &debug_ospf_instance_nsm_cmd);  	install_element(CONFIG_NODE, &debug_ospf_instance_lsa_cmd); diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h index c4c5606663..b1c1d02a51 100644 --- a/ospfd/ospf_dump.h +++ b/ospfd/ospf_dump.h @@ -67,6 +67,8 @@  #define OSPF_DEBUG_GR_HELPER 0x01  #define OSPF_DEBUG_GR 0x03 +#define OSPF_DEBUG_BFD_LIB 0x01 +  /* Macro for setting debug option. */  #define CONF_DEBUG_PACKET_ON(a, b)	    conf_debug_ospf_packet[a] |= (b)  #define CONF_DEBUG_PACKET_OFF(a, b)	    conf_debug_ospf_packet[a] &= ~(b) @@ -140,6 +142,7 @@ extern unsigned long term_debug_ospf_ti_lfa;  extern unsigned long term_debug_ospf_defaultinfo;  extern unsigned long term_debug_ospf_ldp_sync;  extern unsigned long term_debug_ospf_gr; +extern unsigned long term_debug_ospf_bfd;  /* Message Strings. */  extern char *ospf_lsa_type_str[];  | 
