summaryrefslogtreecommitdiffstats
path: root/pathd
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2021-08-26 17:57:33 +0200
committerGitHub <noreply@github.com>2021-08-26 17:57:33 +0200
commitd448e2c5f96b3430fd643f52b9264ca87a45c291 (patch)
treed38574fb0ce8c936a003287d107eebf6eb718a8c /pathd
parentMerge pull request #9492 from Jafaral/pim-cov (diff)
parent*: explicitly print "exit" at the end of every node config (diff)
downloadfrr-d448e2c5f96b3430fd643f52b9264ca87a45c291.tar.xz
frr-d448e2c5f96b3430fd643f52b9264ca87a45c291.zip
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
Diffstat (limited to 'pathd')
-rw-r--r--pathd/path_cli.c48
-rw-r--r--pathd/path_nb.c3
-rw-r--r--pathd/path_nb.h4
-rw-r--r--pathd/path_pcep_cli.c17
-rw-r--r--pathd/pathd.h2
5 files changed, 48 insertions, 26 deletions
diff --git a/pathd/path_cli.c b/pathd/path_cli.c
index d517d75e4..bd629a2b7 100644
--- a/pathd/path_cli.c
+++ b/pathd/path_cli.c
@@ -45,9 +45,6 @@
static int config_write_segment_routing(struct vty *vty);
-static int config_write_traffic_eng(struct vty *vty);
-static int config_write_segment_lists(struct vty *vty);
-static int config_write_sr_policies(struct vty *vty);
static int segment_list_has_src_dst(
struct vty *vty, char *xpath, long index, const char *index_str,
struct in_addr adj_src_ipv4, struct in_addr adj_dst_ipv4,
@@ -63,6 +60,8 @@ static int segment_list_has_prefix(
DEFINE_MTYPE_STATIC(PATHD, PATH_CLI, "Client");
+DEFINE_HOOK(pathd_srte_config_write, (struct vty *vty), (vty));
+
/* Vty node structures. */
static struct cmd_node segment_routing_node = {
.name = "segment-routing",
@@ -77,7 +76,6 @@ static struct cmd_node sr_traffic_eng_node = {
.node = SR_TRAFFIC_ENG_NODE,
.parent_node = SEGMENT_ROUTING_NODE,
.prompt = "%s(config-sr-te)# ",
- .config_write = config_write_traffic_eng,
};
static struct cmd_node srte_segment_list_node = {
@@ -85,7 +83,6 @@ static struct cmd_node srte_segment_list_node = {
.node = SR_SEGMENT_LIST_NODE,
.parent_node = SR_TRAFFIC_ENG_NODE,
.prompt = "%s(config-sr-te-segment-list)# ",
- .config_write = config_write_segment_lists,
};
static struct cmd_node srte_policy_node = {
@@ -93,7 +90,6 @@ static struct cmd_node srte_policy_node = {
.node = SR_POLICY_NODE,
.parent_node = SR_TRAFFIC_ENG_NODE,
.prompt = "%s(config-sr-te-policy)# ",
- .config_write = config_write_sr_policies,
};
static struct cmd_node srte_candidate_dyn_node = {
@@ -309,6 +305,11 @@ void cli_show_srte_segment_list(struct vty *vty, struct lyd_node *dnode,
yang_dnode_get_string(dnode, "./name"));
}
+void cli_show_srte_segment_list_end(struct vty *vty, struct lyd_node *dnode)
+{
+ vty_out(vty, " exit\n");
+}
+
static int segment_list_has_src_dst(
struct vty *vty, char *xpath, long index, const char *index_str,
struct in_addr adj_src_ipv4, struct in_addr adj_dst_ipv4,
@@ -666,6 +667,11 @@ void cli_show_srte_policy(struct vty *vty, struct lyd_node *dnode,
yang_dnode_get_string(dnode, "./endpoint"));
}
+void cli_show_srte_policy_end(struct vty *vty, struct lyd_node *dnode)
+{
+ vty_out(vty, " exit\n");
+}
+
/*
* XPath: /frr-pathd:pathd/srte/policy/name
*/
@@ -1237,6 +1243,15 @@ void cli_show_srte_policy_candidate_path(struct vty *vty,
}
}
+void cli_show_srte_policy_candidate_path_end(struct vty *vty,
+ struct lyd_node *dnode)
+{
+ const char *type = yang_dnode_get_string(dnode, "./type");
+
+ if (strmatch(type, "dynamic"))
+ vty_out(vty, " exit\n");
+}
+
static int config_write_dnode(const struct lyd_node *dnode, void *arg)
{
struct vty *vty = arg;
@@ -1249,29 +1264,20 @@ static int config_write_dnode(const struct lyd_node *dnode, void *arg)
int config_write_segment_routing(struct vty *vty)
{
vty_out(vty, "segment-routing\n");
- return 1;
-}
-
-int config_write_traffic_eng(struct vty *vty)
-{
vty_out(vty, " traffic-eng\n");
+
path_ted_config_write(vty);
- return 1;
-}
-int config_write_segment_lists(struct vty *vty)
-{
yang_dnode_iterate(config_write_dnode, vty, running_config->dnode,
"/frr-pathd:pathd/srte/segment-list");
-
- return 1;
-}
-
-int config_write_sr_policies(struct vty *vty)
-{
yang_dnode_iterate(config_write_dnode, vty, running_config->dnode,
"/frr-pathd:pathd/srte/policy");
+ hook_call(pathd_srte_config_write, vty);
+
+ vty_out(vty, " exit\n");
+ vty_out(vty, "exit\n");
+
return 1;
}
diff --git a/pathd/path_nb.c b/pathd/path_nb.c
index 9c622883b..1ab8b7f39 100644
--- a/pathd/path_nb.c
+++ b/pathd/path_nb.c
@@ -56,6 +56,7 @@ const struct frr_yang_module_info frr_pathd_info = {
.cbs = {
.create = pathd_srte_segment_list_create,
.cli_show = cli_show_srte_segment_list,
+ .cli_show_end = cli_show_srte_segment_list_end,
.destroy = pathd_srte_segment_list_destroy,
.get_next = pathd_srte_segment_list_get_next,
.get_keys = pathd_srte_segment_list_get_keys,
@@ -136,6 +137,7 @@ const struct frr_yang_module_info frr_pathd_info = {
.cbs = {
.create = pathd_srte_policy_create,
.cli_show = cli_show_srte_policy,
+ .cli_show_end = cli_show_srte_policy_end,
.destroy = pathd_srte_policy_destroy,
.get_next = pathd_srte_policy_get_next,
.get_keys = pathd_srte_policy_get_keys,
@@ -169,6 +171,7 @@ const struct frr_yang_module_info frr_pathd_info = {
.cbs = {
.create = pathd_srte_policy_candidate_path_create,
.cli_show = cli_show_srte_policy_candidate_path,
+ .cli_show_end = cli_show_srte_policy_candidate_path_end,
.destroy = pathd_srte_policy_candidate_path_destroy,
.get_next = pathd_srte_policy_candidate_path_get_next,
.get_keys = pathd_srte_policy_candidate_path_get_keys,
diff --git a/pathd/path_nb.h b/pathd/path_nb.h
index caeadd9cc..6a918b8b8 100644
--- a/pathd/path_nb.h
+++ b/pathd/path_nb.h
@@ -112,10 +112,12 @@ void pathd_apply_finish(struct nb_cb_apply_finish_args *args);
/* Optional 'cli_show' callbacks. */
void cli_show_srte_segment_list(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+void cli_show_srte_segment_list_end(struct vty *vty, struct lyd_node *dnode);
void cli_show_srte_segment_list_segment(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_srte_policy(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
+void cli_show_srte_policy_end(struct vty *vty, struct lyd_node *dnode);
void cli_show_srte_policy_name(struct vty *vty, struct lyd_node *dnode,
bool show_defaults);
void cli_show_srte_policy_binding_sid(struct vty *vty, struct lyd_node *dnode,
@@ -123,6 +125,8 @@ void cli_show_srte_policy_binding_sid(struct vty *vty, struct lyd_node *dnode,
void cli_show_srte_policy_candidate_path(struct vty *vty,
struct lyd_node *dnode,
bool show_defaults);
+void cli_show_srte_policy_candidate_path_end(struct vty *vty,
+ struct lyd_node *dnode);
/* Utility functions */
typedef void (*of_pref_cp_t)(enum objfun_type type, void *arg);
diff --git a/pathd/path_pcep_cli.c b/pathd/path_pcep_cli.c
index db5f256a8..829df3179 100644
--- a/pathd/path_pcep_cli.c
+++ b/pathd/path_pcep_cli.c
@@ -175,7 +175,6 @@ static struct cmd_node pcep_node = {
.name = "srte pcep",
.node = PCEP_NODE,
.parent_node = SR_TRAFFIC_ENG_NODE,
- .config_write = pcep_cli_pcep_config_write,
.prompt = "%s(config-sr-te-pcep)# "
};
@@ -183,7 +182,6 @@ static struct cmd_node pcep_pcc_node = {
.name = "srte pcep pcc",
.node = PCEP_PCC_NODE,
.parent_node = PCEP_NODE,
- .config_write = pcep_cli_pcc_config_write,
.prompt = "%s(config-sr-te-pcep-pcc)# "
};
@@ -191,7 +189,6 @@ static struct cmd_node pcep_pce_node = {
.name = "srte pcep pce",
.node = PCEP_PCE_NODE,
.parent_node = PCEP_NODE,
- .config_write = pcep_cli_pce_config_write,
.prompt = "%s(config-sr-te-pcep-pce)# "
};
@@ -199,7 +196,6 @@ static struct cmd_node pcep_pce_config_node = {
.name = "srte pcep pce-config",
.node = PCEP_PCE_CONFIG_NODE,
.parent_node = PCEP_NODE,
- .config_write = pcep_cli_pcep_pce_config_write,
.prompt = "%s(pce-sr-te-pcep-pce-config)# "
};
@@ -1444,6 +1440,10 @@ int pcep_cli_debug_set_all(uint32_t flags, bool set)
int pcep_cli_pcep_config_write(struct vty *vty)
{
vty_out(vty, " pcep\n");
+ pcep_cli_pcep_pce_config_write(vty);
+ pcep_cli_pce_config_write(vty);
+ pcep_cli_pcc_config_write(vty);
+ vty_out(vty, " exit\n");
return 1;
}
@@ -1468,7 +1468,7 @@ int pcep_cli_pcc_config_write(struct vty *vty)
}
if (pce_connections_g.num_connections == 0) {
- return lines;
+ goto exit;
}
buf[0] = 0;
@@ -1495,6 +1495,8 @@ int pcep_cli_pcc_config_write(struct vty *vty)
lines++;
buf[0] = 0;
}
+exit:
+ vty_out(vty, " exit\n");
return lines;
}
@@ -1655,6 +1657,8 @@ int pcep_cli_pce_config_write(struct vty *vty)
vty_out(vty, "%s", buf);
buf[0] = '\0';
+
+ vty_out(vty, " exit\n");
}
return lines;
@@ -1679,6 +1683,8 @@ int pcep_cli_pcep_pce_config_write(struct vty *vty)
pcep_cli_print_pce_config(group_opts, buf, sizeof(buf));
vty_out(vty, "%s", buf);
buf[0] = 0;
+
+ vty_out(vty, " exit\n");
}
return lines;
@@ -1999,6 +2005,7 @@ DEFPY(pcep_cli_clear_srte_pcep_session,
void pcep_cli_init(void)
{
+ hook_register(pathd_srte_config_write, pcep_cli_pcep_config_write);
hook_register(nb_client_debug_config_write,
pcep_cli_debug_config_write);
hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);
diff --git a/pathd/pathd.h b/pathd/pathd.h
index f790a0e3c..81d7aa910 100644
--- a/pathd/pathd.h
+++ b/pathd/pathd.h
@@ -34,6 +34,8 @@
DECLARE_MGROUP(PATHD);
+DECLARE_HOOK(pathd_srte_config_write, (struct vty *vty), (vty));
+
enum srte_protocol_origin {
SRTE_ORIGIN_UNDEFINED = 0,
SRTE_ORIGIN_PCEP = 1,