ospfd: Add 'debug ospf ti-lfa' command

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
This commit is contained in:
GalaxyGorilla 2020-11-24 09:56:18 +00:00
parent 3e94c9a4a3
commit a4553b5bdb
4 changed files with 78 additions and 30 deletions

View File

@ -56,6 +56,7 @@ unsigned long conf_debug_ospf_nssa = 0;
unsigned long conf_debug_ospf_te = 0; unsigned long conf_debug_ospf_te = 0;
unsigned long conf_debug_ospf_ext = 0; unsigned long conf_debug_ospf_ext = 0;
unsigned long conf_debug_ospf_sr = 0; unsigned long conf_debug_ospf_sr = 0;
unsigned long conf_debug_ospf_ti_lfa = 0;
unsigned long conf_debug_ospf_defaultinfo = 0; unsigned long conf_debug_ospf_defaultinfo = 0;
unsigned long conf_debug_ospf_ldp_sync = 0; unsigned long conf_debug_ospf_ldp_sync = 0;
unsigned long conf_debug_ospf_gr = 0; unsigned long conf_debug_ospf_gr = 0;
@ -71,6 +72,7 @@ unsigned long term_debug_ospf_nssa = 0;
unsigned long term_debug_ospf_te = 0; unsigned long term_debug_ospf_te = 0;
unsigned long term_debug_ospf_ext = 0; unsigned long term_debug_ospf_ext = 0;
unsigned long term_debug_ospf_sr = 0; unsigned long term_debug_ospf_sr = 0;
unsigned long term_debug_ospf_ti_lfa = 0;
unsigned long term_debug_ospf_defaultinfo; unsigned long term_debug_ospf_defaultinfo;
unsigned long term_debug_ospf_ldp_sync; unsigned long term_debug_ospf_ldp_sync;
unsigned long term_debug_ospf_gr = 0; unsigned long term_debug_ospf_gr = 0;
@ -1470,6 +1472,24 @@ DEFUN (no_debug_ospf_sr,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN(debug_ospf_ti_lfa, debug_ospf_ti_lfa_cmd, "debug ospf ti-lfa",
DEBUG_STR OSPF_STR "OSPF-SR TI-LFA information\n")
{
if (vty->node == CONFIG_NODE)
CONF_DEBUG_ON(ti_lfa, TI_LFA);
TERM_DEBUG_ON(ti_lfa, TI_LFA);
return CMD_SUCCESS;
}
DEFUN(no_debug_ospf_ti_lfa, no_debug_ospf_ti_lfa_cmd, "no debug ospf ti-lfa",
NO_STR DEBUG_STR OSPF_STR "OSPF-SR TI-LFA information\n")
{
if (vty->node == CONFIG_NODE)
CONF_DEBUG_OFF(ti_lfa, TI_LFA);
TERM_DEBUG_OFF(ti_lfa, TI_LFA);
return CMD_SUCCESS;
}
DEFUN (debug_ospf_default_info, DEFUN (debug_ospf_default_info,
debug_ospf_default_info_cmd, debug_ospf_default_info_cmd,
"debug ospf default-information", "debug ospf default-information",
@ -1891,6 +1911,12 @@ static int config_write_debug(struct vty *vty)
write = 1; write = 1;
} }
/* debug ospf sr ti-lfa */
if (IS_CONF_DEBUG_OSPF(sr, TI_LFA) == OSPF_DEBUG_TI_LFA) {
vty_out(vty, "debug ospf%s ti-lfa\n", str);
write = 1;
}
/* debug ospf ldp-sync */ /* debug ospf ldp-sync */
if (IS_CONF_DEBUG_OSPF(ldp_sync, LDP_SYNC) == OSPF_DEBUG_LDP_SYNC) { if (IS_CONF_DEBUG_OSPF(ldp_sync, LDP_SYNC) == OSPF_DEBUG_LDP_SYNC) {
vty_out(vty, "debug ospf%s ldp-sync\n", str); vty_out(vty, "debug ospf%s ldp-sync\n", str);
@ -1920,6 +1946,7 @@ void ospf_debug_init(void)
install_element(ENABLE_NODE, &debug_ospf_nssa_cmd); install_element(ENABLE_NODE, &debug_ospf_nssa_cmd);
install_element(ENABLE_NODE, &debug_ospf_te_cmd); install_element(ENABLE_NODE, &debug_ospf_te_cmd);
install_element(ENABLE_NODE, &debug_ospf_sr_cmd); install_element(ENABLE_NODE, &debug_ospf_sr_cmd);
install_element(ENABLE_NODE, &debug_ospf_ti_lfa_cmd);
install_element(ENABLE_NODE, &debug_ospf_default_info_cmd); install_element(ENABLE_NODE, &debug_ospf_default_info_cmd);
install_element(ENABLE_NODE, &debug_ospf_ldp_sync_cmd); install_element(ENABLE_NODE, &debug_ospf_ldp_sync_cmd);
install_element(ENABLE_NODE, &no_debug_ospf_ism_cmd); install_element(ENABLE_NODE, &no_debug_ospf_ism_cmd);
@ -1930,6 +1957,7 @@ void ospf_debug_init(void)
install_element(ENABLE_NODE, &no_debug_ospf_nssa_cmd); install_element(ENABLE_NODE, &no_debug_ospf_nssa_cmd);
install_element(ENABLE_NODE, &no_debug_ospf_te_cmd); install_element(ENABLE_NODE, &no_debug_ospf_te_cmd);
install_element(ENABLE_NODE, &no_debug_ospf_sr_cmd); install_element(ENABLE_NODE, &no_debug_ospf_sr_cmd);
install_element(ENABLE_NODE, &no_debug_ospf_ti_lfa_cmd);
install_element(ENABLE_NODE, &no_debug_ospf_default_info_cmd); install_element(ENABLE_NODE, &no_debug_ospf_default_info_cmd);
install_element(ENABLE_NODE, &no_debug_ospf_ldp_sync_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_gr_cmd);
@ -1962,6 +1990,7 @@ void ospf_debug_init(void)
install_element(CONFIG_NODE, &debug_ospf_nssa_cmd); install_element(CONFIG_NODE, &debug_ospf_nssa_cmd);
install_element(CONFIG_NODE, &debug_ospf_te_cmd); install_element(CONFIG_NODE, &debug_ospf_te_cmd);
install_element(CONFIG_NODE, &debug_ospf_sr_cmd); install_element(CONFIG_NODE, &debug_ospf_sr_cmd);
install_element(CONFIG_NODE, &debug_ospf_ti_lfa_cmd);
install_element(CONFIG_NODE, &debug_ospf_default_info_cmd); install_element(CONFIG_NODE, &debug_ospf_default_info_cmd);
install_element(CONFIG_NODE, &debug_ospf_ldp_sync_cmd); install_element(CONFIG_NODE, &debug_ospf_ldp_sync_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_nsm_cmd); install_element(CONFIG_NODE, &no_debug_ospf_nsm_cmd);
@ -1971,6 +2000,7 @@ void ospf_debug_init(void)
install_element(CONFIG_NODE, &no_debug_ospf_nssa_cmd); install_element(CONFIG_NODE, &no_debug_ospf_nssa_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_te_cmd); install_element(CONFIG_NODE, &no_debug_ospf_te_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_sr_cmd); install_element(CONFIG_NODE, &no_debug_ospf_sr_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_ti_lfa_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_default_info_cmd); install_element(CONFIG_NODE, &no_debug_ospf_default_info_cmd);
install_element(CONFIG_NODE, &no_debug_ospf_ldp_sync_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_gr_cmd);

View File

@ -60,6 +60,7 @@
#define OSPF_DEBUG_TE 0x04 #define OSPF_DEBUG_TE 0x04
#define OSPF_DEBUG_EXT 0x08 #define OSPF_DEBUG_EXT 0x08
#define OSPF_DEBUG_SR 0x10 #define OSPF_DEBUG_SR 0x10
#define OSPF_DEBUG_TI_LFA 0x11
#define OSPF_DEBUG_DEFAULTINFO 0x20 #define OSPF_DEBUG_DEFAULTINFO 0x20
#define OSPF_DEBUG_LDP_SYNC 0x40 #define OSPF_DEBUG_LDP_SYNC 0x40
@ -110,6 +111,8 @@
#define IS_DEBUG_OSPF_SR IS_DEBUG_OSPF(sr, SR) #define IS_DEBUG_OSPF_SR IS_DEBUG_OSPF(sr, SR)
#define IS_DEBUG_OSPF_TI_LFA IS_DEBUG_OSPF(ti_lfa, TI_LFA)
#define IS_DEBUG_OSPF_DEFAULT_INFO IS_DEBUG_OSPF(defaultinfo, DEFAULTINFO) #define IS_DEBUG_OSPF_DEFAULT_INFO IS_DEBUG_OSPF(defaultinfo, DEFAULTINFO)
#define IS_DEBUG_OSPF_LDP_SYNC IS_DEBUG_OSPF(ldp_sync, LDP_SYNC) #define IS_DEBUG_OSPF_LDP_SYNC IS_DEBUG_OSPF(ldp_sync, LDP_SYNC)
@ -133,6 +136,7 @@ extern unsigned long term_debug_ospf_nssa;
extern unsigned long term_debug_ospf_te; extern unsigned long term_debug_ospf_te;
extern unsigned long term_debug_ospf_ext; extern unsigned long term_debug_ospf_ext;
extern unsigned long term_debug_ospf_sr; extern unsigned long term_debug_ospf_sr;
extern unsigned long term_debug_ospf_ti_lfa;
extern unsigned long term_debug_ospf_defaultinfo; extern unsigned long term_debug_ospf_defaultinfo;
extern unsigned long term_debug_ospf_ldp_sync; extern unsigned long term_debug_ospf_ldp_sync;
extern unsigned long term_debug_ospf_gr; extern unsigned long term_debug_ospf_gr;

View File

@ -33,6 +33,7 @@
#include "ospfd/ospf_sr.h" #include "ospfd/ospf_sr.h"
#include "ospfd/ospf_route.h" #include "ospfd/ospf_route.h"
#include "ospfd/ospf_ti_lfa.h" #include "ospfd/ospf_ti_lfa.h"
#include "ospfd/ospf_dump.h"
DECLARE_RBTREE_UNIQ(p_spaces, struct p_space, p_spaces_item, DECLARE_RBTREE_UNIQ(p_spaces, struct p_space, p_spaces_item,
@ -391,12 +392,15 @@ static void ospf_ti_lfa_generate_label_stack(struct ospf_area *area,
struct vertex *pc_node; struct vertex *pc_node;
struct ospf_ti_lfa_inner_backup_path_info inner_backup_path_info; struct ospf_ti_lfa_inner_backup_path_info inner_backup_path_info;
zlog_debug("%s: Generating Label stack for src %pI4 and dest %pI4.", if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug(
"%s: Generating Label stack for src %pI4 and dest %pI4.",
__func__, &p_space->root->id, &q_space->root->id); __func__, &p_space->root->id, &q_space->root->id);
pc_node = listnode_head(q_space->pc_path); pc_node = listnode_head(q_space->pc_path);
if (!pc_node) { if (!pc_node) {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: There seems to be no post convergence path (yet).", "%s: There seems to be no post convergence path (yet).",
__func__); __func__);
@ -405,6 +409,7 @@ static void ospf_ti_lfa_generate_label_stack(struct ospf_area *area,
ospf_ti_lfa_find_q_node(pc_node, p_space, q_space); ospf_ti_lfa_find_q_node(pc_node, p_space, q_space);
if (q_space->q_node_info->type == OSPF_TI_LFA_UNDEFINED_NODE) { if (q_space->q_node_info->type == OSPF_TI_LFA_UNDEFINED_NODE) {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug("%s: Q node not found!", __func__); zlog_debug("%s: Q node not found!", __func__);
return; return;
} }
@ -437,6 +442,7 @@ static void ospf_ti_lfa_generate_label_stack(struct ospf_area *area,
adjacency_result = ospf_ti_lfa_find_p_node(pc_node, p_space, q_space); adjacency_result = ospf_ti_lfa_find_p_node(pc_node, p_space, q_space);
if (q_space->p_node_info->type == OSPF_TI_LFA_UNDEFINED_NODE) { if (q_space->p_node_info->type == OSPF_TI_LFA_UNDEFINED_NODE) {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug("%s: P node not found!", __func__); zlog_debug("%s: P node not found!", __func__);
return; return;
} }
@ -598,6 +604,7 @@ ospf_ti_lfa_generate_post_convergence_path(struct list *pc_vertex_list,
current_vertex = ospf_spf_vertex_find(dest->id, pc_vertex_list); current_vertex = ospf_spf_vertex_find(dest->id, pc_vertex_list);
if (!current_vertex) { if (!current_vertex) {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: There seems to be no post convergence path (yet).", "%s: There seems to be no post convergence path (yet).",
__func__); __func__);
@ -981,6 +988,7 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area,
|| path->nexthop.s_addr == INADDR_ANY) || path->nexthop.s_addr == INADDR_ANY)
continue; continue;
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: attempting to insert backup path for prefix %pFX, router id %pI4 and nexthop %pI4.", "%s: attempting to insert backup path for prefix %pFX, router id %pI4 and nexthop %pI4.",
__func__, &rn->p, &path->adv_router, __func__, &rn->p, &path->adv_router,
@ -988,6 +996,7 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area,
p_space = ospf_ti_lfa_get_p_space_by_path(area, path); p_space = ospf_ti_lfa_get_p_space_by_path(area, path);
if (!p_space) { if (!p_space) {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: P space not found for router id %pI4 and nexthop %pI4.", "%s: P space not found for router id %pI4 and nexthop %pI4.",
__func__, &path->adv_router, __func__, &path->adv_router,
@ -1000,6 +1009,7 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area,
q_space = q_spaces_find(p_space->q_spaces, q_space = q_spaces_find(p_space->q_spaces,
&q_space_search); &q_space_search);
if (!q_space) { if (!q_space) {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: Q space not found for advertising router %pI4.", "%s: Q space not found for advertising router %pI4.",
__func__, &path->adv_router); __func__, &path->adv_router);
@ -1034,14 +1044,18 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area,
q_space->label_stack->label, q_space->label_stack->label,
label_buf, MPLS_LABEL_STRLEN, label_buf, MPLS_LABEL_STRLEN,
true); true);
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: inserted backup path %s for prefix %pFX, router id %pI4 and nexthop %pI4.", "%s: inserted backup path %s for prefix %pFX, router id %pI4 and nexthop %pI4.",
__func__, label_buf, &rn->p, __func__, label_buf, &rn->p,
&path->adv_router, &path->nexthop); &path->adv_router,
&path->nexthop);
} else { } else {
if (IS_DEBUG_OSPF_TI_LFA)
zlog_debug( zlog_debug(
"%s: inserted NO backup path for prefix %pFX, router id %pI4 and nexthop %pI4.", "%s: inserted NO backup path for prefix %pFX, router id %pI4 and nexthop %pI4.",
__func__, &rn->p, &path->adv_router, __func__, &rn->p,
&path->adv_router,
&path->nexthop); &path->nexthop);
} }
} }

View File

@ -288,7 +288,7 @@ int main(int argc, char **argv)
ospf_vty_init(); ospf_vty_init();
ospf_sr_init(); ospf_sr_init();
term_debug_ospf_event = 1; term_debug_ospf_ti_lfa = 1;
/* Read input from .in file. */ /* Read input from .in file. */
vty_stdio(vty_do_exit); vty_stdio(vty_do_exit);