Merge pull request #9438 from ranjanyash54/debug_comm

ospf6d: Add debug commands for lsa all and route all
This commit is contained in:
Mark Stapp 2021-09-14 11:38:21 -04:00 committed by GitHub
commit 5fbbd15d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 80 additions and 43 deletions

View File

@ -1021,6 +1021,30 @@ static char *ospf6_lsa_handler_name(const struct ospf6_lsa_handler *h)
return buf;
}
DEFPY (debug_ospf6_lsa_all,
debug_ospf6_lsa_all_cmd,
"[no$no] debug ospf6 lsa all",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug Link State Advertisements (LSAs)\n"
"Display for all types of LSAs\n")
{
unsigned int i;
struct ospf6_lsa_handler *handler = NULL;
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
handler = vector_slot(ospf6_lsa_handler_vector, i);
if (handler == NULL)
continue;
if (!no)
SET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
else
UNSET_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL);
}
return CMD_SUCCESS;
}
DEFPY (debug_ospf6_lsa_aggregation,
debug_ospf6_lsa_aggregation_cmd,
"[no] debug ospf6 lsa aggregation",
@ -1152,6 +1176,8 @@ DEFUN (no_debug_ospf6_lsa_type,
void install_element_ospf6_debug_lsa(void)
{
install_element(ENABLE_NODE, &debug_ospf6_lsa_all_cmd);
install_element(CONFIG_NODE, &debug_ospf6_lsa_all_cmd);
install_element(ENABLE_NODE, &debug_ospf6_lsa_hex_cmd);
install_element(ENABLE_NODE, &no_debug_ospf6_lsa_hex_cmd);
install_element(CONFIG_NODE, &debug_ospf6_lsa_hex_cmd);
@ -1165,6 +1191,23 @@ int config_write_ospf6_debug_lsa(struct vty *vty)
{
unsigned int i;
const struct ospf6_lsa_handler *handler;
bool debug_all = true;
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
handler = vector_slot(ospf6_lsa_handler_vector, i);
if (handler == NULL)
continue;
if (CHECK_FLAG(handler->lh_debug, OSPF6_LSA_DEBUG_ALL)
< OSPF6_LSA_DEBUG_ALL) {
debug_all = false;
break;
}
}
if (debug_all) {
vty_out(vty, "debug ospf6 lsa all\n");
return 0;
}
for (i = 0; i < vector_active(ospf6_lsa_handler_vector); i++) {
handler = vector_slot(ospf6_lsa_handler_vector, i);

View File

@ -28,6 +28,9 @@
#define OSPF6_LSA_DEBUG_ORIGINATE 0x02
#define OSPF6_LSA_DEBUG_EXAMIN 0x04
#define OSPF6_LSA_DEBUG_FLOOD 0x08
#define OSPF6_LSA_DEBUG_ALL \
(OSPF6_LSA_DEBUG | OSPF6_LSA_DEBUG_ORIGINATE | OSPF6_LSA_DEBUG_EXAMIN \
| OSPF6_LSA_DEBUG_FLOOD)
#define OSPF6_LSA_DEBUG_AGGR 0x10
/* OSPF LSA Default metric values */

View File

@ -37,6 +37,9 @@
#include "ospf6_interface.h"
#include "ospf6d.h"
#include "ospf6_zebra.h"
#ifndef VTYSH_EXTRACT_PL
#include "ospf6d/ospf6_route_clippy.c"
#endif
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_ROUTE, "OSPF6 route");
DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_ROUTE_TABLE, "OSPF6 route table");
@ -1837,22 +1840,27 @@ void ospf6_brouter_show(struct vty *vty, struct ospf6_route *route)
OSPF6_PATH_TYPE_NAME(route->path.type), area);
}
DEFUN (debug_ospf6_route,
debug_ospf6_route_cmd,
"debug ospf6 route <table|intra-area|inter-area|memory>",
DEBUG_STR
OSPF6_STR
"Debug routes\n"
"Debug route table calculation\n"
"Debug intra-area route calculation\n"
"Debug inter-area route calculation\n"
"Debug route memory use\n"
)
DEFPY(debug_ospf6_route,
debug_ospf6_route_cmd,
"[no$no] debug ospf6 route <all|table|intra-area|inter-area|memory>",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug routes\n"
"Debug for all types of route calculation\n"
"Debug route table calculation\n"
"Debug intra-area route calculation\n"
"Debug inter-area route calculation\n"
"Debug route memory use\n")
{
int idx_type = 3;
int idx_type;
unsigned char level = 0;
if (!strcmp(argv[idx_type]->text, "table"))
idx_type = ((no) ? 4 : 3);
if (!strcmp(argv[idx_type]->text, "all"))
level = OSPF6_DEBUG_ROUTE_ALL;
else if (!strcmp(argv[idx_type]->text, "table"))
level = OSPF6_DEBUG_ROUTE_TABLE;
else if (!strcmp(argv[idx_type]->text, "intra-area"))
level = OSPF6_DEBUG_ROUTE_INTRA;
@ -1860,39 +1868,20 @@ DEFUN (debug_ospf6_route,
level = OSPF6_DEBUG_ROUTE_INTER;
else if (!strcmp(argv[idx_type]->text, "memory"))
level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_ON(level);
return CMD_SUCCESS;
}
DEFUN (no_debug_ospf6_route,
no_debug_ospf6_route_cmd,
"no debug ospf6 route <table|intra-area|inter-area|memory>",
NO_STR
DEBUG_STR
OSPF6_STR
"Debug routes\n"
"Debug route table calculation\n"
"Debug intra-area route calculation\n"
"Debug inter-area route calculation\n"
"Debug route memory use\n")
{
int idx_type = 4;
unsigned char level = 0;
if (!strcmp(argv[idx_type]->text, "table"))
level = OSPF6_DEBUG_ROUTE_TABLE;
else if (!strcmp(argv[idx_type]->text, "intra-area"))
level = OSPF6_DEBUG_ROUTE_INTRA;
else if (!strcmp(argv[idx_type]->text, "inter-area"))
level = OSPF6_DEBUG_ROUTE_INTER;
else if (!strcmp(argv[idx_type]->text, "memory"))
level = OSPF6_DEBUG_ROUTE_MEMORY;
OSPF6_DEBUG_ROUTE_OFF(level);
if (no)
OSPF6_DEBUG_ROUTE_OFF(level);
else
OSPF6_DEBUG_ROUTE_ON(level);
return CMD_SUCCESS;
}
int config_write_ospf6_debug_route(struct vty *vty)
{
if (IS_OSPF6_DEBUG_ROUTE(ALL) == OSPF6_DEBUG_ROUTE_ALL) {
vty_out(vty, "debug ospf6 route all\n");
return 0;
}
if (IS_OSPF6_DEBUG_ROUTE(TABLE))
vty_out(vty, "debug ospf6 route table\n");
if (IS_OSPF6_DEBUG_ROUTE(INTRA))
@ -1908,7 +1897,5 @@ int config_write_ospf6_debug_route(struct vty *vty)
void install_element_ospf6_debug_route(void)
{
install_element(ENABLE_NODE, &debug_ospf6_route_cmd);
install_element(ENABLE_NODE, &no_debug_ospf6_route_cmd);
install_element(CONFIG_NODE, &debug_ospf6_route_cmd);
install_element(CONFIG_NODE, &no_debug_ospf6_route_cmd);
}

View File

@ -33,7 +33,10 @@ extern unsigned char conf_debug_ospf6_route;
#define OSPF6_DEBUG_ROUTE_TABLE 0x01
#define OSPF6_DEBUG_ROUTE_INTRA 0x02
#define OSPF6_DEBUG_ROUTE_INTER 0x04
#define OSPF6_DEBUG_ROUTE_MEMORY 0x80
#define OSPF6_DEBUG_ROUTE_MEMORY 0x08
#define OSPF6_DEBUG_ROUTE_ALL \
(OSPF6_DEBUG_ROUTE_TABLE | OSPF6_DEBUG_ROUTE_INTRA \
| OSPF6_DEBUG_ROUTE_INTER | OSPF6_DEBUG_ROUTE_MEMORY)
#define OSPF6_DEBUG_ROUTE_ON(level) (conf_debug_ospf6_route |= (level))
#define OSPF6_DEBUG_ROUTE_OFF(level) (conf_debug_ospf6_route &= ~(level))
#define IS_OSPF6_DEBUG_ROUTE(e) (conf_debug_ospf6_route & OSPF6_DEBUG_ROUTE_##e)

View File

@ -96,6 +96,7 @@ clippy_scan += \
ospf6d/ospf6_asbr.c \
ospf6d/ospf6_lsa.c \
ospf6d/ospf6_gr_helper.c \
ospf6d/ospf6_route.c \
# end
nodist_ospf6d_ospf6d_SOURCES = \