diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index e15c9c42c7..b98852eeee 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -56,6 +56,7 @@ unsigned long conf_debug_ospf_nssa = 0; unsigned long conf_debug_ospf_te = 0; unsigned long conf_debug_ospf_ext = 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_ldp_sync = 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_ext = 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_ldp_sync; unsigned long term_debug_ospf_gr = 0; @@ -1470,6 +1472,24 @@ DEFUN (no_debug_ospf_sr, 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, debug_ospf_default_info_cmd, "debug ospf default-information", @@ -1891,6 +1911,12 @@ static int config_write_debug(struct vty *vty) 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 */ if (IS_CONF_DEBUG_OSPF(ldp_sync, LDP_SYNC) == OSPF_DEBUG_LDP_SYNC) { 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_te_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_ldp_sync_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_te_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_ldp_sync_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_te_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_ldp_sync_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_te_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_ldp_sync_cmd); install_element(CONFIG_NODE, &debug_ospf_gr_cmd); diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h index ea607fef7c..c4c5606663 100644 --- a/ospfd/ospf_dump.h +++ b/ospfd/ospf_dump.h @@ -60,6 +60,7 @@ #define OSPF_DEBUG_TE 0x04 #define OSPF_DEBUG_EXT 0x08 #define OSPF_DEBUG_SR 0x10 +#define OSPF_DEBUG_TI_LFA 0x11 #define OSPF_DEBUG_DEFAULTINFO 0x20 #define OSPF_DEBUG_LDP_SYNC 0x40 @@ -110,6 +111,8 @@ #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_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_ext; 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_ldp_sync; extern unsigned long term_debug_ospf_gr; diff --git a/ospfd/ospf_ti_lfa.c b/ospfd/ospf_ti_lfa.c index 885fe10a08..e75922df14 100644 --- a/ospfd/ospf_ti_lfa.c +++ b/ospfd/ospf_ti_lfa.c @@ -33,6 +33,7 @@ #include "ospfd/ospf_sr.h" #include "ospfd/ospf_route.h" #include "ospfd/ospf_ti_lfa.h" +#include "ospfd/ospf_dump.h" DECLARE_RBTREE_UNIQ(p_spaces, struct p_space, p_spaces_item, @@ -391,21 +392,25 @@ static void ospf_ti_lfa_generate_label_stack(struct ospf_area *area, struct vertex *pc_node; struct ospf_ti_lfa_inner_backup_path_info inner_backup_path_info; - zlog_debug("%s: Generating Label stack for src %pI4 and dest %pI4.", - __func__, &p_space->root->id, &q_space->root->id); + 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); pc_node = listnode_head(q_space->pc_path); if (!pc_node) { - zlog_debug( - "%s: There seems to be no post convergence path (yet).", - __func__); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: There seems to be no post convergence path (yet).", + __func__); return; } ospf_ti_lfa_find_q_node(pc_node, p_space, q_space); if (q_space->q_node_info->type == OSPF_TI_LFA_UNDEFINED_NODE) { - zlog_debug("%s: Q node not found!", __func__); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug("%s: Q node not found!", __func__); return; } @@ -437,7 +442,8 @@ 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); if (q_space->p_node_info->type == OSPF_TI_LFA_UNDEFINED_NODE) { - zlog_debug("%s: P node not found!", __func__); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug("%s: P node not found!", __func__); return; } @@ -598,9 +604,10 @@ ospf_ti_lfa_generate_post_convergence_path(struct list *pc_vertex_list, current_vertex = ospf_spf_vertex_find(dest->id, pc_vertex_list); if (!current_vertex) { - zlog_debug( - "%s: There seems to be no post convergence path (yet).", - __func__); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: There seems to be no post convergence path (yet).", + __func__); return NULL; } @@ -981,17 +988,19 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area, || path->nexthop.s_addr == INADDR_ANY) continue; - zlog_debug( - "%s: attempting to insert backup path for prefix %pFX, router id %pI4 and nexthop %pI4.", - __func__, &rn->p, &path->adv_router, - &path->nexthop); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: attempting to insert backup path for prefix %pFX, router id %pI4 and nexthop %pI4.", + __func__, &rn->p, &path->adv_router, + &path->nexthop); p_space = ospf_ti_lfa_get_p_space_by_path(area, path); if (!p_space) { - zlog_debug( - "%s: P space not found for router id %pI4 and nexthop %pI4.", - __func__, &path->adv_router, - &path->nexthop); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: P space not found for router id %pI4 and nexthop %pI4.", + __func__, &path->adv_router, + &path->nexthop); continue; } @@ -1000,9 +1009,10 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area, q_space = q_spaces_find(p_space->q_spaces, &q_space_search); if (!q_space) { - zlog_debug( - "%s: Q space not found for advertising router %pI4.", - __func__, &path->adv_router); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: Q space not found for advertising router %pI4.", + __func__, &path->adv_router); continue; } @@ -1034,15 +1044,19 @@ void ospf_ti_lfa_insert_backup_paths(struct ospf_area *area, q_space->label_stack->label, label_buf, MPLS_LABEL_STRLEN, true); - zlog_debug( - "%s: inserted backup path %s for prefix %pFX, router id %pI4 and nexthop %pI4.", - __func__, label_buf, &rn->p, - &path->adv_router, &path->nexthop); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: inserted backup path %s for prefix %pFX, router id %pI4 and nexthop %pI4.", + __func__, label_buf, &rn->p, + &path->adv_router, + &path->nexthop); } else { - zlog_debug( - "%s: inserted NO backup path for prefix %pFX, router id %pI4 and nexthop %pI4.", - __func__, &rn->p, &path->adv_router, - &path->nexthop); + if (IS_DEBUG_OSPF_TI_LFA) + zlog_debug( + "%s: inserted NO backup path for prefix %pFX, router id %pI4 and nexthop %pI4.", + __func__, &rn->p, + &path->adv_router, + &path->nexthop); } } } diff --git a/tests/ospfd/test_ospf_spf.c b/tests/ospfd/test_ospf_spf.c index b5a4337586..4b7e5f7e70 100644 --- a/tests/ospfd/test_ospf_spf.c +++ b/tests/ospfd/test_ospf_spf.c @@ -288,7 +288,7 @@ int main(int argc, char **argv) ospf_vty_init(); ospf_sr_init(); - term_debug_ospf_event = 1; + term_debug_ospf_ti_lfa = 1; /* Read input from .in file. */ vty_stdio(vty_do_exit);