+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2020 NetDEF, Inc.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
#include "pathd/pathd.h"
#include "pathd/path_nb.h"
-#ifndef VTYSH_EXTRACT_PL
#include "pathd/path_cli_clippy.c"
-#endif
#include "pathd/path_ted.h"
#define XPATH_MAXATTRSIZE 64
ttable_rowseps(tt, 0, BOTTOM, true, '-');
RB_FOREACH (policy, srte_policy_head, &srte_policies) {
- char endpoint[46];
+ char endpoint[ENDPOINT_STR_LENGTH];
char binding_sid[16] = "-";
ipaddr2str(&policy->endpoint, endpoint, sizeof(endpoint));
vty_out(vty, "\n");
RB_FOREACH (policy, srte_policy_head, &srte_policies) {
struct srte_candidate *candidate;
- char endpoint[46];
+ char endpoint[ENDPOINT_STR_LENGTH];
char binding_sid[16] = "-";
char *segment_list_info;
static char undefined_info[] = "(undefined)";
adj_src_ipv4, adj_dst_ipv4,
adj_src_ipv6, adj_dst_ipv6,
adj_src_ipv4_str, adj_dst_ipv4_str,
- adj_dst_ipv6_str, adj_src_ipv6_str);
+ adj_src_ipv6_str, adj_dst_ipv6_str);
if (status != CMD_SUCCESS)
return status;
} else {
return "mss";
case OBJFUN_MSN:
return "msn";
- default:
+ case OBJFUN_UNDEFINED:
return NULL;
}
+
+ assert(!"Reached end of function we should never hit");
}
DEFPY_NOSH(show_debugging_pathd, show_debugging_pathd_cmd,
"State of each debugging option\n"
"pathd module debugging\n")
{
+
+ vty_out(vty, "Path debugging status:\n");
+
+ cmd_show_lib_debugs(vty);
/* nothing to do here */
+ path_ted_show_debugging(vty);
+ path_policy_show_debugging(vty);
+ return CMD_SUCCESS;
+}
+
+DEFPY(debug_path_policy, debug_path_policy_cmd, "[no] debug pathd policy",
+ NO_STR DEBUG_STR
+ "path debugging\n"
+ "policy debugging\n")
+{
+ uint32_t mode = DEBUG_NODE2MODE(vty->node);
+ bool no_debug = no;
+
+ DEBUG_MODE_SET(&path_policy_debug, mode, !no);
+ DEBUG_FLAGS_SET(&path_policy_debug, PATH_POLICY_DEBUG_BASIC, !no_debug);
return CMD_SUCCESS;
}
return 1;
}
+static int path_policy_cli_debug_config_write(struct vty *vty)
+{
+ if (DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_CONF)) {
+ if (DEBUG_FLAGS_CHECK(&path_policy_debug,
+ PATH_POLICY_DEBUG_BASIC))
+ vty_out(vty, "debug pathd policy\n");
+ return 1;
+ }
+ return 0;
+}
+
+static int path_policy_cli_debug_set_all(uint32_t flags, bool set)
+{
+ DEBUG_FLAGS_SET(&path_policy_debug, flags, set);
+
+ /* If all modes have been turned off, don't preserve options. */
+ if (!DEBUG_MODE_CHECK(&path_policy_debug, DEBUG_MODE_ALL))
+ DEBUG_CLEAR(&path_policy_debug);
+
+ return 0;
+}
+
void path_cli_init(void)
{
+ hook_register(nb_client_debug_config_write,
+ path_policy_cli_debug_config_write);
+ hook_register(nb_client_debug_set_all, path_policy_cli_debug_set_all);
+
install_node(&segment_routing_node);
install_node(&sr_traffic_eng_node);
install_node(&srte_segment_list_node);
install_element(ENABLE_NODE, &show_srte_policy_cmd);
install_element(ENABLE_NODE, &show_srte_policy_detail_cmd);
+ install_element(ENABLE_NODE, &debug_path_policy_cmd);
+ install_element(CONFIG_NODE, &debug_path_policy_cmd);
+
install_element(CONFIG_NODE, &segment_routing_cmd);
install_element(SEGMENT_ROUTING_NODE, &sr_traffic_eng_cmd);
install_element(SR_TRAFFIC_ENG_NODE, &srte_segment_list_cmd);