mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 19:10:35 +00:00
Merge pull request #9331 from idryzhov/explicit-exit
*: explicitly print "exit" at the end of every node config
This commit is contained in:
commit
d448e2c5f9
@ -1362,7 +1362,7 @@ interface_config_write (struct vty *vty)
|
|||||||
write++;
|
write++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vty_endframe (vty, "!\n");
|
vty_endframe (vty, "exit\n!\n");
|
||||||
write++;
|
write++;
|
||||||
}
|
}
|
||||||
return write;
|
return write;
|
||||||
|
@ -132,6 +132,8 @@ babel_config_write (struct vty *vty)
|
|||||||
|
|
||||||
lines += config_write_distribute (vty, babel_routing_process->distribute_ctx);
|
lines += config_write_distribute (vty, babel_routing_process->distribute_ctx);
|
||||||
|
|
||||||
|
vty_out (vty, "exit\n");
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ void bfd_cli_show_header(struct vty *vty,
|
|||||||
void bfd_cli_show_header_end(struct vty *vty,
|
void bfd_cli_show_header_end(struct vty *vty,
|
||||||
struct lyd_node *dnode __attribute__((__unused__)))
|
struct lyd_node *dnode __attribute__((__unused__)))
|
||||||
{
|
{
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,6 +276,7 @@ void bfd_cli_show_multi_hop_peer(struct vty *vty,
|
|||||||
void bfd_cli_show_peer_end(struct vty *vty,
|
void bfd_cli_show_peer_end(struct vty *vty,
|
||||||
struct lyd_node *dnode __attribute__((__unused__)))
|
struct lyd_node *dnode __attribute__((__unused__)))
|
||||||
{
|
{
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
vty_out(vty, " !\n");
|
vty_out(vty, " !\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2400,6 +2400,8 @@ static int bmp_config_write(struct bgp *bgp, struct vty *vty)
|
|||||||
frr_each (bmp_actives, &bt->actives, ba)
|
frr_each (bmp_actives, &bt->actives, ba)
|
||||||
vty_out(vty, " bmp connect %s port %u min-retry %u max-retry %u\n",
|
vty_out(vty, " bmp connect %s port %u min-retry %u max-retry %u\n",
|
||||||
ba->hostname, ba->port, ba->minretry, ba->maxretry);
|
ba->hostname, ba->port, ba->minretry, ba->maxretry);
|
||||||
|
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -17213,6 +17213,7 @@ int bgp_config_write(struct vty *vty)
|
|||||||
bgp_rfapi_cfg_write(vty, bgp);
|
bgp_rfapi_cfg_write(vty, bgp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -96,6 +96,7 @@ void eigrp_cli_show_header(struct vty *vty, struct lyd_node *dnode,
|
|||||||
|
|
||||||
void eigrp_cli_show_end_header(struct vty *vty, struct lyd_node *dnode)
|
void eigrp_cli_show_end_header(struct vty *vty, struct lyd_node *dnode)
|
||||||
{
|
{
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,7 +1290,7 @@ static int isis_interface_config_write(struct vty *vty)
|
|||||||
write += hook_call(isis_circuit_config_write,
|
write += hook_call(isis_circuit_config_write,
|
||||||
circuit, vty);
|
circuit, vty);
|
||||||
}
|
}
|
||||||
vty_endframe(vty, "!\n");
|
vty_endframe(vty, "exit\n!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return write;
|
return write;
|
||||||
|
@ -146,6 +146,11 @@ void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
|
|||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cli_show_router_isis_end(struct vty *vty, struct lyd_node *dnode)
|
||||||
|
{
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath: /frr-interface:lib/interface/frr-isisd:isis/
|
* XPath: /frr-interface:lib/interface/frr-isisd:isis/
|
||||||
* XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing
|
* XPath: /frr-interface:lib/interface/frr-isisd:isis/ipv4-routing
|
||||||
|
@ -32,6 +32,7 @@ const struct frr_yang_module_info frr_isisd_info = {
|
|||||||
.xpath = "/frr-isisd:isis/instance",
|
.xpath = "/frr-isisd:isis/instance",
|
||||||
.cbs = {
|
.cbs = {
|
||||||
.cli_show = cli_show_router_isis,
|
.cli_show = cli_show_router_isis,
|
||||||
|
.cli_show_end = cli_show_router_isis_end,
|
||||||
.create = isis_instance_create,
|
.create = isis_instance_create,
|
||||||
.destroy = isis_instance_destroy,
|
.destroy = isis_instance_destroy,
|
||||||
},
|
},
|
||||||
|
@ -415,6 +415,7 @@ void isis_instance_segment_routing_prefix_sid_map_prefix_sid_apply_finish(
|
|||||||
/* Optional 'cli_show' callbacks. */
|
/* Optional 'cli_show' callbacks. */
|
||||||
void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
|
void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
|
void cli_show_router_isis_end(struct vty *vty, struct lyd_node *dnode);
|
||||||
void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
|
void cli_show_ip_isis_ipv4(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
|
void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
|
||||||
|
@ -3011,6 +3011,8 @@ static int isis_config_write(struct vty *vty)
|
|||||||
|
|
||||||
write += area_write_mt_settings(area, vty);
|
write += area_write_mt_settings(area, vty);
|
||||||
write += fabricd_write_settings(area, vty);
|
write += fabricd_write_settings(area, vty);
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,8 @@ ldp_af_iface_config_write(struct vty *vty, int af)
|
|||||||
ia->hello_interval != 0)
|
ia->hello_interval != 0)
|
||||||
vty_out (vty, " discovery hello interval %u\n",
|
vty_out (vty, " discovery hello interval %u\n",
|
||||||
ia->hello_interval);
|
ia->hello_interval);
|
||||||
|
|
||||||
|
vty_out (vty, " exit\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +316,7 @@ ldp_config_write(struct vty *vty)
|
|||||||
ldp_af_config_write(vty, AF_INET, ldpd_conf, &ldpd_conf->ipv4);
|
ldp_af_config_write(vty, AF_INET, ldpd_conf, &ldpd_conf->ipv4);
|
||||||
ldp_af_config_write(vty, AF_INET6, ldpd_conf, &ldpd_conf->ipv6);
|
ldp_af_config_write(vty, AF_INET6, ldpd_conf, &ldpd_conf->ipv6);
|
||||||
vty_out (vty, " !\n");
|
vty_out (vty, " !\n");
|
||||||
|
vty_out (vty, "exit\n");
|
||||||
vty_out (vty, "!\n");
|
vty_out (vty, "!\n");
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
@ -353,6 +356,8 @@ ldp_l2vpn_pw_config_write(struct vty *vty, struct l2vpn_pw *pw)
|
|||||||
" ! Incomplete config, specify a neighbor lsr-id\n");
|
" ! Incomplete config, specify a neighbor lsr-id\n");
|
||||||
if (missing_pwid)
|
if (missing_pwid)
|
||||||
vty_out (vty," ! Incomplete config, specify a pw-id\n");
|
vty_out (vty," ! Incomplete config, specify a pw-id\n");
|
||||||
|
|
||||||
|
vty_out (vty, " exit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -383,6 +388,7 @@ ldp_l2vpn_config_write(struct vty *vty)
|
|||||||
ldp_l2vpn_pw_config_write(vty, pw);
|
ldp_l2vpn_pw_config_write(vty, pw);
|
||||||
|
|
||||||
vty_out (vty, " !\n");
|
vty_out (vty, " !\n");
|
||||||
|
vty_out (vty, "exit\n");
|
||||||
vty_out (vty, "!\n");
|
vty_out (vty, "!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
lib/if.c
6
lib/if.c
@ -1291,6 +1291,11 @@ static void cli_show_interface(struct vty *vty, struct lyd_node *dnode,
|
|||||||
vty_out(vty, "\n");
|
vty_out(vty, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cli_show_interface_end(struct vty *vty, struct lyd_node *dnode)
|
||||||
|
{
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XPath: /frr-interface:lib/interface/description
|
* XPath: /frr-interface:lib/interface/description
|
||||||
*/
|
*/
|
||||||
@ -1652,6 +1657,7 @@ const struct frr_yang_module_info frr_interface_info = {
|
|||||||
.create = lib_interface_create,
|
.create = lib_interface_create,
|
||||||
.destroy = lib_interface_destroy,
|
.destroy = lib_interface_destroy,
|
||||||
.cli_show = cli_show_interface,
|
.cli_show = cli_show_interface,
|
||||||
|
.cli_show_end = cli_show_interface_end,
|
||||||
.get_next = lib_interface_get_next,
|
.get_next = lib_interface_get_next,
|
||||||
.get_keys = lib_interface_get_keys,
|
.get_keys = lib_interface_get_keys,
|
||||||
.lookup_entry = lib_interface_lookup_entry,
|
.lookup_entry = lib_interface_lookup_entry,
|
||||||
|
@ -1044,6 +1044,7 @@ static int keychain_config_write(struct vty *vty)
|
|||||||
|
|
||||||
vty_out(vty, " exit\n");
|
vty_out(vty, " exit\n");
|
||||||
}
|
}
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,6 +1156,7 @@ static int nexthop_group_write(struct vty *vty)
|
|||||||
nexthop_group_write_nexthop_internal(vty, nh);
|
nexthop_group_write_nexthop_internal(vty, nh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ void route_map_instance_show(struct vty *vty, struct lyd_node *dnode,
|
|||||||
|
|
||||||
void route_map_instance_show_end(struct vty *vty, struct lyd_node *dnode)
|
void route_map_instance_show_end(struct vty *vty, struct lyd_node *dnode)
|
||||||
{
|
{
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3040,7 +3040,7 @@ DEFPY (log_commands,
|
|||||||
/* Display current configuration. */
|
/* Display current configuration. */
|
||||||
static int vty_config_write(struct vty *vty)
|
static int vty_config_write(struct vty *vty)
|
||||||
{
|
{
|
||||||
vty_out(vty, "line vty\n");
|
vty_frame(vty, "line vty\n");
|
||||||
|
|
||||||
if (vty_accesslist_name)
|
if (vty_accesslist_name)
|
||||||
vty_out(vty, " access-class %s\n", vty_accesslist_name);
|
vty_out(vty, " access-class %s\n", vty_accesslist_name);
|
||||||
@ -3058,6 +3058,8 @@ static int vty_config_write(struct vty *vty)
|
|||||||
if (no_password_check)
|
if (no_password_check)
|
||||||
vty_out(vty, " no login\n");
|
vty_out(vty, " no login\n");
|
||||||
|
|
||||||
|
vty_endframe(vty, "exit\n");
|
||||||
|
|
||||||
if (do_log_commands)
|
if (do_log_commands)
|
||||||
vty_out(vty, "log commands\n");
|
vty_out(vty, "log commands\n");
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ static int interface_config_write(struct vty *vty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vty_endframe(vty, "!\n");
|
vty_endframe(vty, "exit\n!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2593,7 +2593,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)
|
|||||||
|
|
||||||
ospf6_bfd_write_config(vty, oi);
|
ospf6_bfd_write_config(vty, oi);
|
||||||
|
|
||||||
vty_endframe(vty, "!\n");
|
vty_endframe(vty, "exit\n!\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2237,6 +2237,8 @@ static int config_write_ospf6(struct vty *vty)
|
|||||||
ospf6_distribute_config_write(vty, ospf6);
|
ospf6_distribute_config_write(vty, ospf6);
|
||||||
ospf6_asbr_summary_config_write(vty, ospf6);
|
ospf6_asbr_summary_config_write(vty, ospf6);
|
||||||
config_write_ospf6_gr_helper(vty, ospf6);
|
config_write_ospf6_gr_helper(vty, ospf6);
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -11970,7 +11970,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)
|
|||||||
|
|
||||||
ospf_opaque_config_write_if(vty, ifp);
|
ospf_opaque_config_write_if(vty, ifp);
|
||||||
|
|
||||||
vty_endframe(vty, NULL);
|
vty_endframe(vty, "exit\n!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return write;
|
return write;
|
||||||
@ -12546,6 +12546,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
|
|||||||
/* LDP-Sync print */
|
/* LDP-Sync print */
|
||||||
ospf_ldp_sync_write_config(vty, ospf);
|
ospf_ldp_sync_write_config(vty, ospf);
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
|
|
||||||
write++;
|
write++;
|
||||||
return write;
|
return write;
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,6 @@
|
|||||||
|
|
||||||
|
|
||||||
static int config_write_segment_routing(struct vty *vty);
|
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(
|
static int segment_list_has_src_dst(
|
||||||
struct vty *vty, char *xpath, long index, const char *index_str,
|
struct vty *vty, char *xpath, long index, const char *index_str,
|
||||||
struct in_addr adj_src_ipv4, struct in_addr adj_dst_ipv4,
|
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_MTYPE_STATIC(PATHD, PATH_CLI, "Client");
|
||||||
|
|
||||||
|
DEFINE_HOOK(pathd_srte_config_write, (struct vty *vty), (vty));
|
||||||
|
|
||||||
/* Vty node structures. */
|
/* Vty node structures. */
|
||||||
static struct cmd_node segment_routing_node = {
|
static struct cmd_node segment_routing_node = {
|
||||||
.name = "segment-routing",
|
.name = "segment-routing",
|
||||||
@ -77,7 +76,6 @@ static struct cmd_node sr_traffic_eng_node = {
|
|||||||
.node = SR_TRAFFIC_ENG_NODE,
|
.node = SR_TRAFFIC_ENG_NODE,
|
||||||
.parent_node = SEGMENT_ROUTING_NODE,
|
.parent_node = SEGMENT_ROUTING_NODE,
|
||||||
.prompt = "%s(config-sr-te)# ",
|
.prompt = "%s(config-sr-te)# ",
|
||||||
.config_write = config_write_traffic_eng,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct cmd_node srte_segment_list_node = {
|
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,
|
.node = SR_SEGMENT_LIST_NODE,
|
||||||
.parent_node = SR_TRAFFIC_ENG_NODE,
|
.parent_node = SR_TRAFFIC_ENG_NODE,
|
||||||
.prompt = "%s(config-sr-te-segment-list)# ",
|
.prompt = "%s(config-sr-te-segment-list)# ",
|
||||||
.config_write = config_write_segment_lists,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct cmd_node srte_policy_node = {
|
static struct cmd_node srte_policy_node = {
|
||||||
@ -93,7 +90,6 @@ static struct cmd_node srte_policy_node = {
|
|||||||
.node = SR_POLICY_NODE,
|
.node = SR_POLICY_NODE,
|
||||||
.parent_node = SR_TRAFFIC_ENG_NODE,
|
.parent_node = SR_TRAFFIC_ENG_NODE,
|
||||||
.prompt = "%s(config-sr-te-policy)# ",
|
.prompt = "%s(config-sr-te-policy)# ",
|
||||||
.config_write = config_write_sr_policies,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct cmd_node srte_candidate_dyn_node = {
|
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"));
|
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(
|
static int segment_list_has_src_dst(
|
||||||
struct vty *vty, char *xpath, long index, const char *index_str,
|
struct vty *vty, char *xpath, long index, const char *index_str,
|
||||||
struct in_addr adj_src_ipv4, struct in_addr adj_dst_ipv4,
|
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"));
|
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
|
* 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)
|
static int config_write_dnode(const struct lyd_node *dnode, void *arg)
|
||||||
{
|
{
|
||||||
struct vty *vty = 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)
|
int config_write_segment_routing(struct vty *vty)
|
||||||
{
|
{
|
||||||
vty_out(vty, "segment-routing\n");
|
vty_out(vty, "segment-routing\n");
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_write_traffic_eng(struct vty *vty)
|
|
||||||
{
|
|
||||||
vty_out(vty, " traffic-eng\n");
|
vty_out(vty, " traffic-eng\n");
|
||||||
path_ted_config_write(vty);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int config_write_segment_lists(struct vty *vty)
|
path_ted_config_write(vty);
|
||||||
{
|
|
||||||
yang_dnode_iterate(config_write_dnode, vty, running_config->dnode,
|
yang_dnode_iterate(config_write_dnode, vty, running_config->dnode,
|
||||||
"/frr-pathd:pathd/srte/segment-list");
|
"/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,
|
yang_dnode_iterate(config_write_dnode, vty, running_config->dnode,
|
||||||
"/frr-pathd:pathd/srte/policy");
|
"/frr-pathd:pathd/srte/policy");
|
||||||
|
|
||||||
|
hook_call(pathd_srte_config_write, vty);
|
||||||
|
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ const struct frr_yang_module_info frr_pathd_info = {
|
|||||||
.cbs = {
|
.cbs = {
|
||||||
.create = pathd_srte_segment_list_create,
|
.create = pathd_srte_segment_list_create,
|
||||||
.cli_show = cli_show_srte_segment_list,
|
.cli_show = cli_show_srte_segment_list,
|
||||||
|
.cli_show_end = cli_show_srte_segment_list_end,
|
||||||
.destroy = pathd_srte_segment_list_destroy,
|
.destroy = pathd_srte_segment_list_destroy,
|
||||||
.get_next = pathd_srte_segment_list_get_next,
|
.get_next = pathd_srte_segment_list_get_next,
|
||||||
.get_keys = pathd_srte_segment_list_get_keys,
|
.get_keys = pathd_srte_segment_list_get_keys,
|
||||||
@ -136,6 +137,7 @@ const struct frr_yang_module_info frr_pathd_info = {
|
|||||||
.cbs = {
|
.cbs = {
|
||||||
.create = pathd_srte_policy_create,
|
.create = pathd_srte_policy_create,
|
||||||
.cli_show = cli_show_srte_policy,
|
.cli_show = cli_show_srte_policy,
|
||||||
|
.cli_show_end = cli_show_srte_policy_end,
|
||||||
.destroy = pathd_srte_policy_destroy,
|
.destroy = pathd_srte_policy_destroy,
|
||||||
.get_next = pathd_srte_policy_get_next,
|
.get_next = pathd_srte_policy_get_next,
|
||||||
.get_keys = pathd_srte_policy_get_keys,
|
.get_keys = pathd_srte_policy_get_keys,
|
||||||
@ -169,6 +171,7 @@ const struct frr_yang_module_info frr_pathd_info = {
|
|||||||
.cbs = {
|
.cbs = {
|
||||||
.create = pathd_srte_policy_candidate_path_create,
|
.create = pathd_srte_policy_candidate_path_create,
|
||||||
.cli_show = cli_show_srte_policy_candidate_path,
|
.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,
|
.destroy = pathd_srte_policy_candidate_path_destroy,
|
||||||
.get_next = pathd_srte_policy_candidate_path_get_next,
|
.get_next = pathd_srte_policy_candidate_path_get_next,
|
||||||
.get_keys = pathd_srte_policy_candidate_path_get_keys,
|
.get_keys = pathd_srte_policy_candidate_path_get_keys,
|
||||||
|
@ -112,10 +112,12 @@ void pathd_apply_finish(struct nb_cb_apply_finish_args *args);
|
|||||||
/* Optional 'cli_show' callbacks. */
|
/* Optional 'cli_show' callbacks. */
|
||||||
void cli_show_srte_segment_list(struct vty *vty, struct lyd_node *dnode,
|
void cli_show_srte_segment_list(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
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,
|
void cli_show_srte_segment_list_segment(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
void cli_show_srte_policy(struct vty *vty, struct lyd_node *dnode,
|
void cli_show_srte_policy(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
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,
|
void cli_show_srte_policy_name(struct vty *vty, struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
void cli_show_srte_policy_binding_sid(struct vty *vty, struct lyd_node *dnode,
|
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,
|
void cli_show_srte_policy_candidate_path(struct vty *vty,
|
||||||
struct lyd_node *dnode,
|
struct lyd_node *dnode,
|
||||||
bool show_defaults);
|
bool show_defaults);
|
||||||
|
void cli_show_srte_policy_candidate_path_end(struct vty *vty,
|
||||||
|
struct lyd_node *dnode);
|
||||||
|
|
||||||
/* Utility functions */
|
/* Utility functions */
|
||||||
typedef void (*of_pref_cp_t)(enum objfun_type type, void *arg);
|
typedef void (*of_pref_cp_t)(enum objfun_type type, void *arg);
|
||||||
|
@ -175,7 +175,6 @@ static struct cmd_node pcep_node = {
|
|||||||
.name = "srte pcep",
|
.name = "srte pcep",
|
||||||
.node = PCEP_NODE,
|
.node = PCEP_NODE,
|
||||||
.parent_node = SR_TRAFFIC_ENG_NODE,
|
.parent_node = SR_TRAFFIC_ENG_NODE,
|
||||||
.config_write = pcep_cli_pcep_config_write,
|
|
||||||
.prompt = "%s(config-sr-te-pcep)# "
|
.prompt = "%s(config-sr-te-pcep)# "
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -183,7 +182,6 @@ static struct cmd_node pcep_pcc_node = {
|
|||||||
.name = "srte pcep pcc",
|
.name = "srte pcep pcc",
|
||||||
.node = PCEP_PCC_NODE,
|
.node = PCEP_PCC_NODE,
|
||||||
.parent_node = PCEP_NODE,
|
.parent_node = PCEP_NODE,
|
||||||
.config_write = pcep_cli_pcc_config_write,
|
|
||||||
.prompt = "%s(config-sr-te-pcep-pcc)# "
|
.prompt = "%s(config-sr-te-pcep-pcc)# "
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -191,7 +189,6 @@ static struct cmd_node pcep_pce_node = {
|
|||||||
.name = "srte pcep pce",
|
.name = "srte pcep pce",
|
||||||
.node = PCEP_PCE_NODE,
|
.node = PCEP_PCE_NODE,
|
||||||
.parent_node = PCEP_NODE,
|
.parent_node = PCEP_NODE,
|
||||||
.config_write = pcep_cli_pce_config_write,
|
|
||||||
.prompt = "%s(config-sr-te-pcep-pce)# "
|
.prompt = "%s(config-sr-te-pcep-pce)# "
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -199,7 +196,6 @@ static struct cmd_node pcep_pce_config_node = {
|
|||||||
.name = "srte pcep pce-config",
|
.name = "srte pcep pce-config",
|
||||||
.node = PCEP_PCE_CONFIG_NODE,
|
.node = PCEP_PCE_CONFIG_NODE,
|
||||||
.parent_node = PCEP_NODE,
|
.parent_node = PCEP_NODE,
|
||||||
.config_write = pcep_cli_pcep_pce_config_write,
|
|
||||||
.prompt = "%s(pce-sr-te-pcep-pce-config)# "
|
.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)
|
int pcep_cli_pcep_config_write(struct vty *vty)
|
||||||
{
|
{
|
||||||
vty_out(vty, " pcep\n");
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1468,7 +1468,7 @@ int pcep_cli_pcc_config_write(struct vty *vty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pce_connections_g.num_connections == 0) {
|
if (pce_connections_g.num_connections == 0) {
|
||||||
return lines;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
@ -1495,6 +1495,8 @@ int pcep_cli_pcc_config_write(struct vty *vty)
|
|||||||
lines++;
|
lines++;
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
}
|
}
|
||||||
|
exit:
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
@ -1655,6 +1657,8 @@ int pcep_cli_pce_config_write(struct vty *vty)
|
|||||||
|
|
||||||
vty_out(vty, "%s", buf);
|
vty_out(vty, "%s", buf);
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
|
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines;
|
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));
|
pcep_cli_print_pce_config(group_opts, buf, sizeof(buf));
|
||||||
vty_out(vty, "%s", buf);
|
vty_out(vty, "%s", buf);
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
|
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
@ -1999,6 +2005,7 @@ DEFPY(pcep_cli_clear_srte_pcep_session,
|
|||||||
|
|
||||||
void pcep_cli_init(void)
|
void pcep_cli_init(void)
|
||||||
{
|
{
|
||||||
|
hook_register(pathd_srte_config_write, pcep_cli_pcep_config_write);
|
||||||
hook_register(nb_client_debug_config_write,
|
hook_register(nb_client_debug_config_write,
|
||||||
pcep_cli_debug_config_write);
|
pcep_cli_debug_config_write);
|
||||||
hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);
|
hook_register(nb_client_debug_set_all, pcep_cli_debug_set_all);
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
DECLARE_MGROUP(PATHD);
|
DECLARE_MGROUP(PATHD);
|
||||||
|
|
||||||
|
DECLARE_HOOK(pathd_srte_config_write, (struct vty *vty), (vty));
|
||||||
|
|
||||||
enum srte_protocol_origin {
|
enum srte_protocol_origin {
|
||||||
SRTE_ORIGIN_UNDEFINED = 0,
|
SRTE_ORIGIN_UNDEFINED = 0,
|
||||||
SRTE_ORIGIN_PCEP = 1,
|
SRTE_ORIGIN_PCEP = 1,
|
||||||
|
@ -1118,7 +1118,7 @@ static int pbr_interface_config_write(struct vty *vty)
|
|||||||
|
|
||||||
pbr_map_write_interfaces(vty, ifp);
|
pbr_map_write_interfaces(vty, ifp);
|
||||||
|
|
||||||
vty_endframe(vty, "!\n");
|
vty_endframe(vty, "exit\n!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1184,6 +1184,7 @@ static int pbr_vty_map_config_write_sequence(struct vty *vty,
|
|||||||
pbrms_nexthop_group_write_individual_nexthop(vty, pbrms);
|
pbrms_nexthop_group_write_individual_nexthop(vty, pbrms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ int pim_interface_config_write(struct vty *vty)
|
|||||||
pim_bfd_write_config(vty, ifp);
|
pim_bfd_write_config(vty, ifp);
|
||||||
++writes;
|
++writes;
|
||||||
}
|
}
|
||||||
vty_endframe(vty, "!\n");
|
vty_endframe(vty, "exit\n!\n");
|
||||||
++writes;
|
++writes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3281,6 +3281,8 @@ static int config_write_rip(struct vty *vty)
|
|||||||
/* Interface routemap configuration */
|
/* Interface routemap configuration */
|
||||||
config_write_if_rmap(vty, rip->if_rmap_ctx);
|
config_write_if_rmap(vty, rip->if_rmap_ctx);
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
|
|
||||||
write = 1;
|
write = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2270,6 +2270,8 @@ static int ripng_config_write(struct vty *vty)
|
|||||||
config_write_distribute(vty, ripng->distribute_ctx);
|
config_write_distribute(vty, ripng->distribute_ctx);
|
||||||
config_write_if_rmap(vty, ripng->if_rmap_ctx);
|
config_write_if_rmap(vty, ripng->if_rmap_ctx);
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
|
|
||||||
write = 1;
|
write = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +315,6 @@ domainname test.domain
|
|||||||
!
|
!
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
line vty
|
|
||||||
!
|
!
|
||||||
end
|
end
|
||||||
test# conf t
|
test# conf t
|
||||||
@ -332,7 +331,6 @@ domainname test.domain
|
|||||||
!
|
!
|
||||||
!
|
!
|
||||||
!
|
!
|
||||||
line vty
|
|
||||||
!
|
!
|
||||||
end
|
end
|
||||||
foohost(config)#
|
foohost(config)#
|
||||||
|
@ -513,9 +513,6 @@ class Config(object):
|
|||||||
Parse the configuration and create contexts for each appropriate block
|
Parse the configuration and create contexts for each appropriate block
|
||||||
"""
|
"""
|
||||||
|
|
||||||
current_context_lines = []
|
|
||||||
ctx_keys = []
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The end of a context is flagged via the 'end' keyword:
|
The end of a context is flagged via the 'end' keyword:
|
||||||
|
|
||||||
@ -574,43 +571,80 @@ end
|
|||||||
# key of the context. So "router bgp 10" is the key for the non-address
|
# key of the context. So "router bgp 10" is the key for the non-address
|
||||||
# family part of bgp, "router bgp 10, address-family ipv6 unicast" is
|
# family part of bgp, "router bgp 10, address-family ipv6 unicast" is
|
||||||
# the key for the subcontext and so on.
|
# the key for the subcontext and so on.
|
||||||
ctx_keys = []
|
|
||||||
main_ctx_key = []
|
|
||||||
new_ctx = True
|
|
||||||
|
|
||||||
# the keywords that we know are single line contexts. bgp in this case
|
# This dictionary contains a tree of all commands that we know start a
|
||||||
# is not the main router bgp block, but enabling multi-instance
|
# new multi-line context. All other commands are treated either as
|
||||||
oneline_ctx_keywords = (
|
# commands inside a multi-line context or as single-line contexts. This
|
||||||
"access-list ",
|
# dictionary should be updated whenever a new node is added to FRR.
|
||||||
"agentx",
|
ctx_keywords = {
|
||||||
"allow-external-route-update",
|
"router bgp ": {
|
||||||
"bgp ",
|
"address-family ": {
|
||||||
"debug ",
|
"vni ": {},
|
||||||
"domainname ",
|
},
|
||||||
"dump ",
|
"vnc ": {},
|
||||||
"enable ",
|
"vrf-policy ": {},
|
||||||
"evpn mh",
|
"bmp ": {},
|
||||||
"frr ",
|
"segment-routing srv6": {},
|
||||||
"fpm ",
|
},
|
||||||
"hostname ",
|
"router rip": {},
|
||||||
"ip ",
|
"router ripng": {},
|
||||||
"ipv6 ",
|
"router isis ": {},
|
||||||
"log ",
|
"router openfabric ": {},
|
||||||
"mac access-list ",
|
"router ospf": {},
|
||||||
"mpls lsp",
|
"router ospf6": {},
|
||||||
"mpls label",
|
"router eigrp ": {},
|
||||||
"no ",
|
"router babel": {},
|
||||||
"password ",
|
"mpls ldp": {
|
||||||
"pbr ",
|
"address-family ": {
|
||||||
"ptm-enable",
|
"interface ": {}
|
||||||
"router-id ",
|
}
|
||||||
"service ",
|
},
|
||||||
"table ",
|
"l2vpn ": {
|
||||||
"username ",
|
"member pseudowire ": {}
|
||||||
"vni ",
|
},
|
||||||
"vrrp autoconfigure",
|
"key chain ": {
|
||||||
"zebra "
|
"key ": {}
|
||||||
)
|
},
|
||||||
|
"vrf ": {},
|
||||||
|
"interface ": {
|
||||||
|
"link-params": {}
|
||||||
|
},
|
||||||
|
"pseudowire ": {},
|
||||||
|
"segment-routing": {
|
||||||
|
"traffic-eng": {
|
||||||
|
"segment-list ": {},
|
||||||
|
"policy ": {
|
||||||
|
"candidate-path ": {}
|
||||||
|
},
|
||||||
|
"pcep": {
|
||||||
|
"pcc": {},
|
||||||
|
"pce ": {},
|
||||||
|
"pce-config ": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"srv6": {
|
||||||
|
"locators": {
|
||||||
|
"locator ": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nexthop-group ": {},
|
||||||
|
"route-map ": {},
|
||||||
|
"pbr-map ": {},
|
||||||
|
"rpki": {},
|
||||||
|
"bfd": {
|
||||||
|
"peer ": {},
|
||||||
|
"profile ": {}
|
||||||
|
},
|
||||||
|
"line vty": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
# stack of context keys
|
||||||
|
ctx_keys = []
|
||||||
|
# stack of context keywords
|
||||||
|
cur_ctx_keywords = [ctx_keywords]
|
||||||
|
# list of stored commands
|
||||||
|
cur_ctx_lines = []
|
||||||
|
|
||||||
for line in self.lines:
|
for line in self.lines:
|
||||||
|
|
||||||
@ -620,357 +654,77 @@ end
|
|||||||
if line.startswith("!") or line.startswith("#"):
|
if line.startswith("!") or line.startswith("#"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (
|
if line.startswith("exit"):
|
||||||
len(ctx_keys) == 2
|
# ignore on top level
|
||||||
and ctx_keys[0].startswith("bfd")
|
if len(ctx_keys) == 0:
|
||||||
and ctx_keys[1].startswith("profile ")
|
|
||||||
and line == "end"
|
|
||||||
):
|
|
||||||
log.debug("LINE %-50s: popping from sub context, %-50s", line, ctx_keys)
|
|
||||||
|
|
||||||
if main_ctx_key:
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
ctx_keys = copy.deepcopy(main_ctx_key)
|
|
||||||
current_context_lines = []
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# one line contexts
|
# save current context
|
||||||
# there is one exception though: ldpd accepts a 'router-id' clause
|
self.save_contexts(ctx_keys, cur_ctx_lines)
|
||||||
# as part of its 'mpls ldp' config context. If we are processing
|
|
||||||
# ldp configuration and encounter a router-id we should NOT switch
|
|
||||||
# to a new context
|
|
||||||
if (
|
|
||||||
new_ctx is True
|
|
||||||
and any(line.startswith(keyword) for keyword in oneline_ctx_keywords)
|
|
||||||
and not (
|
|
||||||
ctx_keys
|
|
||||||
and ctx_keys[0].startswith("mpls ldp")
|
|
||||||
and line.startswith("router-id ")
|
|
||||||
)
|
|
||||||
):
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
|
|
||||||
# Start a new context
|
# exit current context
|
||||||
main_ctx_key = []
|
log.debug("LINE %-50s: exit context %-50s", line, ctx_keys)
|
||||||
ctx_keys = [
|
|
||||||
line,
|
|
||||||
]
|
|
||||||
current_context_lines = []
|
|
||||||
|
|
||||||
log.debug("LINE %-50s: entering new context, %-50s", line, ctx_keys)
|
ctx_keys.pop()
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
cur_ctx_keywords.pop()
|
||||||
new_ctx = True
|
cur_ctx_lines = []
|
||||||
|
|
||||||
elif line == "end":
|
continue
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
log.debug("LINE %-50s: exiting old context, %-50s", line, ctx_keys)
|
|
||||||
|
|
||||||
# Start a new context
|
if line.startswith("end"):
|
||||||
new_ctx = True
|
# exit all contexts
|
||||||
main_ctx_key = []
|
while len(ctx_keys) > 0:
|
||||||
ctx_keys = []
|
# save current context
|
||||||
current_context_lines = []
|
self.save_contexts(ctx_keys, cur_ctx_lines)
|
||||||
|
|
||||||
elif line == "exit" and ctx_keys[0].startswith("rpki"):
|
# exit current context
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
log.debug("LINE %-50s: exit context %-50s", line, ctx_keys)
|
||||||
log.debug("LINE %-50s: exiting old context, %-50s", line, ctx_keys)
|
|
||||||
|
|
||||||
# Start a new context
|
ctx_keys.pop()
|
||||||
new_ctx = True
|
cur_ctx_keywords.pop()
|
||||||
main_ctx_key = []
|
cur_ctx_lines = []
|
||||||
ctx_keys = []
|
|
||||||
current_context_lines = []
|
|
||||||
|
|
||||||
elif line == "exit-vrf":
|
continue
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines.append(line)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: append to current_context_lines, %-50s", line, ctx_keys
|
|
||||||
)
|
|
||||||
|
|
||||||
# Start a new context
|
|
||||||
new_ctx = True
|
|
||||||
main_ctx_key = []
|
|
||||||
ctx_keys = []
|
|
||||||
current_context_lines = []
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line == "exit"
|
|
||||||
and len(ctx_keys) > 1
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
):
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
|
|
||||||
# Start a new context
|
|
||||||
ctx_keys = ctx_keys[:-1]
|
|
||||||
current_context_lines = []
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: popping segment routing sub-context to ctx%-50s",
|
|
||||||
line,
|
|
||||||
ctx_keys,
|
|
||||||
)
|
|
||||||
|
|
||||||
elif line in ["exit-address-family", "exit", "exit-vnc"]:
|
|
||||||
# if this exit is for address-family ipv4 unicast, ignore the pop
|
|
||||||
if main_ctx_key:
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
|
|
||||||
# Start a new context
|
|
||||||
ctx_keys = copy.deepcopy(main_ctx_key)
|
|
||||||
current_context_lines = []
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: popping from subcontext to ctx%-50s",
|
|
||||||
line,
|
|
||||||
ctx_keys,
|
|
||||||
)
|
|
||||||
|
|
||||||
elif line in ["exit-vni", "exit-ldp-if"]:
|
|
||||||
if sub_main_ctx_key:
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
|
|
||||||
# Start a new context
|
|
||||||
ctx_keys = copy.deepcopy(sub_main_ctx_key)
|
|
||||||
current_context_lines = []
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: popping from sub-subcontext to ctx%-50s",
|
|
||||||
line,
|
|
||||||
ctx_keys,
|
|
||||||
)
|
|
||||||
|
|
||||||
elif new_ctx is True:
|
|
||||||
if not main_ctx_key:
|
|
||||||
ctx_keys = [
|
|
||||||
line,
|
|
||||||
]
|
|
||||||
else:
|
|
||||||
ctx_keys = copy.deepcopy(main_ctx_key)
|
|
||||||
main_ctx_key = []
|
|
||||||
|
|
||||||
current_context_lines = []
|
|
||||||
new_ctx = False
|
new_ctx = False
|
||||||
log.debug("LINE %-50s: entering new context, %-50s", line, ctx_keys)
|
|
||||||
|
|
||||||
elif (
|
# check if the line is a context-entering keyword
|
||||||
line.startswith("address-family ")
|
for k, v in cur_ctx_keywords[-1].items():
|
||||||
or line.startswith("vnc defaults")
|
if line.startswith(k):
|
||||||
or line.startswith("vnc l2-group")
|
# candidate-path is a special case. It may be a node and
|
||||||
or line.startswith("vnc nve-group")
|
# may be a single-line command. The distinguisher is the
|
||||||
or line.startswith("peer")
|
# word "dynamic" or "explicit" at the middle of the line.
|
||||||
or line.startswith("key ")
|
# It was perhaps not the best choice by the pathd authors
|
||||||
or line.startswith("member pseudowire")
|
# but we have what we have.
|
||||||
):
|
if k == "candidate-path " and "explicit" in line:
|
||||||
main_ctx_key = []
|
# this is a single-line command
|
||||||
|
break
|
||||||
|
|
||||||
# Save old context first
|
# save current context
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
self.save_contexts(ctx_keys, cur_ctx_lines)
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug("LINE %-50s: entering sub-context, append to ctx_keys", line)
|
|
||||||
|
|
||||||
if line == "address-family ipv6" and not ctx_keys[0].startswith(
|
# enter new context
|
||||||
"mpls ldp"
|
new_ctx = True
|
||||||
):
|
ctx_keys.append(line)
|
||||||
ctx_keys.append("address-family ipv6 unicast")
|
cur_ctx_keywords.append(v)
|
||||||
elif line == "address-family ipv4" and not ctx_keys[0].startswith(
|
cur_ctx_lines = []
|
||||||
"mpls ldp"
|
|
||||||
):
|
log.debug("LINE %-50s: enter context %-50s", line, ctx_keys)
|
||||||
ctx_keys.append("address-family ipv4 unicast")
|
break
|
||||||
elif line == "address-family evpn":
|
|
||||||
ctx_keys.append("address-family l2vpn evpn")
|
if new_ctx:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if len(ctx_keys) == 0:
|
||||||
|
log.debug("LINE %-50s: single-line context", line)
|
||||||
|
self.save_contexts([line], [])
|
||||||
else:
|
else:
|
||||||
ctx_keys.append(line)
|
log.debug("LINE %-50s: add to current context %-50s", line, ctx_keys)
|
||||||
|
cur_ctx_lines.append(line)
|
||||||
elif (
|
|
||||||
line.startswith("vni ")
|
|
||||||
and len(ctx_keys) == 2
|
|
||||||
and ctx_keys[0].startswith("router bgp")
|
|
||||||
and ctx_keys[1] == "address-family l2vpn evpn"
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
sub_main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering sub-sub-context, append to ctx_keys", line
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("interface ")
|
|
||||||
and len(ctx_keys) == 2
|
|
||||||
and ctx_keys[0].startswith("mpls ldp")
|
|
||||||
and ctx_keys[1].startswith("address-family")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
sub_main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering sub-sub-context, append to ctx_keys", line
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("traffic-eng")
|
|
||||||
and len(ctx_keys) == 1
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering segment routing sub-context, append to ctx_keys",
|
|
||||||
line,
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("segment-list ")
|
|
||||||
and len(ctx_keys) == 2
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering segment routing sub-context, append to ctx_keys",
|
|
||||||
line,
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("policy ")
|
|
||||||
and len(ctx_keys) == 2
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering segment routing sub-context, append to ctx_keys",
|
|
||||||
line,
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("candidate-path ")
|
|
||||||
and line.endswith(" dynamic")
|
|
||||||
and len(ctx_keys) == 3
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
and ctx_keys[2].startswith("policy")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering candidate-path sub-context, append to ctx_keys",
|
|
||||||
line,
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("pcep")
|
|
||||||
and len(ctx_keys) == 2
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering pcep sub-context, append to ctx_keys", line
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("pce-config ")
|
|
||||||
and len(ctx_keys) == 3
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
and ctx_keys[2].startswith("pcep")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering pce-config sub-context, append to ctx_keys",
|
|
||||||
line,
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("pce ")
|
|
||||||
and len(ctx_keys) == 3
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
and ctx_keys[2].startswith("pcep")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering pce sub-context, append to ctx_keys", line
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("pcc")
|
|
||||||
and len(ctx_keys) == 3
|
|
||||||
and ctx_keys[0].startswith("segment-routing")
|
|
||||||
and ctx_keys[1].startswith("traffic-eng")
|
|
||||||
and ctx_keys[2].startswith("pcep")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering pcc sub-context, append to ctx_keys", line
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
elif (
|
|
||||||
line.startswith("profile ")
|
|
||||||
and len(ctx_keys) == 1
|
|
||||||
and ctx_keys[0].startswith("bfd")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Save old context first
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
|
||||||
current_context_lines = []
|
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: entering BFD profile sub-context, append to ctx_keys",
|
|
||||||
line,
|
|
||||||
)
|
|
||||||
ctx_keys.append(line)
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Continuing in an existing context, add non-commented lines to it
|
|
||||||
current_context_lines.append(line)
|
|
||||||
log.debug(
|
|
||||||
"LINE %-50s: append to current_context_lines, %-50s", line, ctx_keys
|
|
||||||
)
|
|
||||||
|
|
||||||
# Save the context of the last one
|
# Save the context of the last one
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
if len(ctx_keys) > 0:
|
||||||
|
self.save_contexts(ctx_keys, cur_ctx_lines)
|
||||||
|
|
||||||
|
|
||||||
def lines_to_config(ctx_keys, line, delete):
|
def lines_to_config(ctx_keys, line, delete):
|
||||||
|
@ -277,11 +277,6 @@ void vtysh_config_parse_line(void *arg, const char *line)
|
|||||||
== 0) {
|
== 0) {
|
||||||
config_add_line(config->line, line);
|
config_add_line(config->line, line);
|
||||||
config->index = INTERFACE_NODE;
|
config->index = INTERFACE_NODE;
|
||||||
} else if (config->index == VRF_NODE
|
|
||||||
&& strncmp(line, " exit-vrf",
|
|
||||||
strlen(" exit-vrf"))
|
|
||||||
== 0) {
|
|
||||||
config_add_line_uniq_end(config->line, line);
|
|
||||||
} else if (!strncmp(line, " vrrp", strlen(" vrrp"))
|
} else if (!strncmp(line, " vrrp", strlen(" vrrp"))
|
||||||
|| !strncmp(line, " no vrrp",
|
|| !strncmp(line, " no vrrp",
|
||||||
strlen(" no vrrp"))) {
|
strlen(" no vrrp"))) {
|
||||||
@ -300,7 +295,10 @@ void vtysh_config_parse_line(void *arg, const char *line)
|
|||||||
config_add_line(config_top, line);
|
config_add_line(config_top, line);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (strncmp(line, "interface", strlen("interface")) == 0)
|
if (strncmp(line, "exit", strlen("exit")) == 0) {
|
||||||
|
if (config)
|
||||||
|
config_add_line_uniq_end(config->line, line);
|
||||||
|
} else if (strncmp(line, "interface", strlen("interface")) == 0)
|
||||||
config = config_get(INTERFACE_NODE, line);
|
config = config_get(INTERFACE_NODE, line);
|
||||||
else if (strncmp(line, "pseudowire", strlen("pseudowire")) == 0)
|
else if (strncmp(line, "pseudowire", strlen("pseudowire")) == 0)
|
||||||
config = config_get(PW_NODE, line);
|
config = config_get(PW_NODE, line);
|
||||||
@ -496,7 +494,9 @@ void vtysh_config_dump(void)
|
|||||||
* are not under the VRF node.
|
* are not under the VRF node.
|
||||||
*/
|
*/
|
||||||
if (config->index == INTERFACE_NODE
|
if (config->index == INTERFACE_NODE
|
||||||
&& list_isempty(config->line)) {
|
&& (listcount(config->line) == 1)
|
||||||
|
&& (line = listnode_head(config->line))
|
||||||
|
&& strmatch(line, "exit")) {
|
||||||
config_del(config);
|
config_del(config);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -4188,7 +4188,7 @@ static int if_config_write(struct vty *vty)
|
|||||||
zebra_evpn_mh_if_write(vty, ifp);
|
zebra_evpn_mh_if_write(vty, ifp);
|
||||||
link_params_config_write(vty, ifp);
|
link_params_config_write(vty, ifp);
|
||||||
|
|
||||||
vty_endframe(vty, "!\n");
|
vty_endframe(vty, "exit\n!\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -836,6 +836,7 @@ static int zebra_pw_config(struct vty *vty)
|
|||||||
if (!(pw->flags & F_PSEUDOWIRE_CWORD))
|
if (!(pw->flags & F_PSEUDOWIRE_CWORD))
|
||||||
vty_out(vty, " control-word exclude\n");
|
vty_out(vty, " control-word exclude\n");
|
||||||
|
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
write = 1;
|
write = 1;
|
||||||
}
|
}
|
||||||
|
@ -320,10 +320,14 @@ static int zebra_sr_config(struct vty *vty)
|
|||||||
vty_out(vty, " locator %s\n", locator->name);
|
vty_out(vty, " locator %s\n", locator->name);
|
||||||
vty_out(vty, " prefix %s/%u\n", str,
|
vty_out(vty, " prefix %s/%u\n", str,
|
||||||
locator->prefix.prefixlen);
|
locator->prefix.prefixlen);
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
vty_out(vty, " !\n");
|
vty_out(vty, " !\n");
|
||||||
}
|
}
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
vty_out(vty, " !\n");
|
vty_out(vty, " !\n");
|
||||||
|
vty_out(vty, " exit\n");
|
||||||
vty_out(vty, " !\n");
|
vty_out(vty, " !\n");
|
||||||
|
vty_out(vty, "exit\n");
|
||||||
vty_out(vty, "!\n");
|
vty_out(vty, "!\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user