Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: explicitly print "exit" at the end of every node config #9331

Merged
merged 3 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
*: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
  • Loading branch information
idryzhov committed Aug 23, 2021
commit 07679ad98ab97a4b783f7ae54f88d4d70a5729de
2 changes: 1 addition & 1 deletion babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ interface_config_write (struct vty *vty)
write++;
}
}
vty_endframe (vty, "!\n");
vty_endframe (vty, "exit\n!\n");
write++;
}
return write;
Expand Down
2 changes: 2 additions & 0 deletions babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ babel_config_write (struct vty *vty)

lines += config_write_distribute (vty, babel_routing_process->distribute_ctx);

vty_out (vty, "exit\n");

return lines;
}

Expand Down
2 changes: 2 additions & 0 deletions bfdd/bfdd_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void bfd_cli_show_header(struct vty *vty,
void bfd_cli_show_header_end(struct vty *vty,
struct lyd_node *dnode __attribute__((__unused__)))
{
vty_out(vty, "exit\n");
vty_out(vty, "!\n");
}

Expand Down Expand Up @@ -275,6 +276,7 @@ void bfd_cli_show_multi_hop_peer(struct vty *vty,
void bfd_cli_show_peer_end(struct vty *vty,
struct lyd_node *dnode __attribute__((__unused__)))
{
vty_out(vty, " exit\n");
vty_out(vty, " !\n");
}

Expand Down
2 changes: 2 additions & 0 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,8 @@ static int bmp_config_write(struct bgp *bgp, struct vty *vty)
frr_each (bmp_actives, &bt->actives, ba)
vty_out(vty, " bmp connect %s port %u min-retry %u max-retry %u\n",
ba->hostname, ba->port, ba->minretry, ba->maxretry);

vty_out(vty, " exit\n");
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_rpki.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ static int config_write(struct vty *vty)

vty_out(vty, "preference %hhu\n", cache->preference);
}
vty_out(vty, " exit\n");
vty_out(vty, "exit\n");

return 1;
}
Expand Down
1 change: 1 addition & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -17213,6 +17213,7 @@ int bgp_config_write(struct vty *vty)
bgp_rfapi_cfg_write(vty, bgp);
#endif

vty_out(vty, "exit\n");
vty_out(vty, "!\n");
}
return 0;
Expand Down
8 changes: 4 additions & 4 deletions bgpd/rfapi/bgp_rfapi_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -4043,7 +4043,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
rfg->routemap_redist_name
[ZEBRA_ROUTE_BGP_DIRECT_EXT]);
}
vty_out(vty, " exit-vrf-policy\n");
vty_out(vty, " exit-vrf-policy\n");
vty_out(vty, "!\n");
}
if (hc->flags & BGP_VNC_CONFIG_ADV_UN_METHOD_ENCAP) {
Expand Down Expand Up @@ -4121,7 +4121,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty, bgp->rfapi->rfp,
RFAPI_RFP_CFG_GROUP_L2,
rfgc->name, rfgc->rfp_cfg);
vty_out(vty, " exit-vnc\n");
vty_out(vty, " exit-vnc\n");
vty_out(vty, "!\n");
}
}
Expand Down Expand Up @@ -4199,7 +4199,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty, bgp->rfapi->rfp,
RFAPI_RFP_CFG_GROUP_DEFAULT, NULL,
bgp->rfapi_cfg->default_rfp_cfg);
vty_out(vty, " exit-vnc\n");
vty_out(vty, " exit-vnc\n");
vty_out(vty, "!\n");
}

Expand Down Expand Up @@ -4364,7 +4364,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
vty, bgp->rfapi->rfp,
RFAPI_RFP_CFG_GROUP_NVE,
rfg->name, rfg->rfp_cfg);
vty_out(vty, " exit-vnc\n");
vty_out(vty, " exit-vnc\n");
vty_out(vty, "!\n");
}
} /* have listen ports */
Expand Down
1 change: 1 addition & 0 deletions eigrpd/eigrp_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
vty_out(vty, "exit\n");
vty_out(vty, "!\n");
}

Expand Down
2 changes: 1 addition & 1 deletion isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ static int isis_interface_config_write(struct vty *vty)
write += hook_call(isis_circuit_config_write,
circuit, vty);
}
vty_endframe(vty, "!\n");
vty_endframe(vty, "exit\n!\n");
}

return write;
Expand Down
5 changes: 5 additions & 0 deletions isisd/isis_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
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/ipv4-routing
Expand Down
1 change: 1 addition & 0 deletions isisd/isis_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const struct frr_yang_module_info frr_isisd_info = {
.xpath = "/frr-isisd:isis/instance",
.cbs = {
.cli_show = cli_show_router_isis,
.cli_show_end = cli_show_router_isis_end,
.create = isis_instance_create,
.destroy = isis_instance_destroy,
},
Expand Down
1 change: 1 addition & 0 deletions isisd/isis_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void isis_instance_segment_routing_prefix_sid_map_prefix_sid_apply_finish(
/* Optional 'cli_show' callbacks. */
void cli_show_router_isis(struct vty *vty, struct lyd_node *dnode,
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,
bool show_defaults);
void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode,
Expand Down
2 changes: 2 additions & 0 deletions isisd/isisd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3011,6 +3011,8 @@ static int isis_config_write(struct vty *vty)

write += area_write_mt_settings(area, vty);
write += fabricd_write_settings(area, vty);

vty_out(vty, "exit\n");
}
}

Expand Down
6 changes: 6 additions & 0 deletions ldpd/ldp_vty_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ ldp_af_iface_config_write(struct vty *vty, int af)
ia->hello_interval != 0)
vty_out (vty, " discovery hello interval %u\n",
ia->hello_interval);

vty_out (vty, " exit\n");
}
}

Expand Down Expand Up @@ -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_INET6, ldpd_conf, &ldpd_conf->ipv6);
vty_out (vty, " !\n");
vty_out (vty, "exit\n");
vty_out (vty, "!\n");

return (1);
Expand Down Expand Up @@ -353,6 +356,8 @@ ldp_l2vpn_pw_config_write(struct vty *vty, struct l2vpn_pw *pw)
" ! Incomplete config, specify a neighbor lsr-id\n");
if (missing_pwid)
vty_out (vty," ! Incomplete config, specify a pw-id\n");

vty_out (vty, " exit\n");
}

static int
Expand Down Expand Up @@ -383,6 +388,7 @@ ldp_l2vpn_config_write(struct vty *vty)
ldp_l2vpn_pw_config_write(vty, pw);

vty_out (vty, " !\n");
vty_out (vty, "exit\n");
vty_out (vty, "!\n");
}

Expand Down
6 changes: 6 additions & 0 deletions lib/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,11 @@ static void cli_show_interface(struct vty *vty, struct lyd_node *dnode,
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
*/
Expand Down Expand Up @@ -1652,6 +1657,7 @@ const struct frr_yang_module_info frr_interface_info = {
.create = lib_interface_create,
.destroy = lib_interface_destroy,
.cli_show = cli_show_interface,
.cli_show_end = cli_show_interface_end,
.get_next = lib_interface_get_next,
.get_keys = lib_interface_get_keys,
.lookup_entry = lib_interface_lookup_entry,
Expand Down
1 change: 1 addition & 0 deletions lib/keychain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, "!\n");
}

Expand Down
1 change: 1 addition & 0 deletions lib/nexthop_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,7 @@ static int nexthop_group_write(struct vty *vty)
nexthop_group_write_nexthop_internal(vty, nh);
}

vty_out(vty, "exit\n");
vty_out(vty, "!\n");
}

Expand Down
1 change: 1 addition & 0 deletions lib/routemap_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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)
{
vty_out(vty, "exit\n");
vty_out(vty, "!\n");
}

Expand Down
4 changes: 3 additions & 1 deletion lib/vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -3040,7 +3040,7 @@ DEFPY (log_commands,
/* Display current configuration. */
static int vty_config_write(struct vty *vty)
{
vty_out(vty, "line vty\n");
vty_frame(vty, "line vty\n");

if (vty_accesslist_name)
vty_out(vty, " access-class %s\n", vty_accesslist_name);
Expand All @@ -3058,6 +3058,8 @@ static int vty_config_write(struct vty *vty)
if (no_password_check)
vty_out(vty, " no login\n");

vty_endframe(vty, "exit\n");

if (do_log_commands)
vty_out(vty, "log commands\n");

Expand Down
2 changes: 1 addition & 1 deletion nhrpd/nhrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ static int interface_config_write(struct vty *vty)
}
}

vty_endframe(vty, "!\n");
vty_endframe(vty, "exit\n!\n");
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,7 @@ static int config_write_ospf6_interface(struct vty *vty, struct vrf *vrf)

ospf6_bfd_write_config(vty, oi);

vty_endframe(vty, "!\n");
vty_endframe(vty, "exit\n!\n");
}
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions ospf6d/ospf6_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,8 @@ static int config_write_ospf6(struct vty *vty)
ospf6_distribute_config_write(vty, ospf6);
ospf6_asbr_summary_config_write(vty, ospf6);
config_write_ospf6_gr_helper(vty, ospf6);

vty_out(vty, "exit\n");
vty_out(vty, "!\n");
}
return 0;
Expand Down
4 changes: 3 additions & 1 deletion ospfd/ospf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -11970,7 +11970,7 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf)

ospf_opaque_config_write_if(vty, ifp);

vty_endframe(vty, NULL);
vty_endframe(vty, "exit\n!\n");
}

return write;
Expand Down Expand Up @@ -12546,6 +12546,8 @@ static int ospf_config_write_one(struct vty *vty, struct ospf *ospf)
/* LDP-Sync print */
ospf_ldp_sync_write_config(vty, ospf);

vty_out(vty, "exit\n");

write++;
return write;
}
Expand Down
22 changes: 22 additions & 0 deletions pathd/path_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,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,
Expand Down Expand Up @@ -662,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
*/
Expand Down Expand Up @@ -1233,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;
Expand All @@ -1256,6 +1275,9 @@ int config_write_segment_routing(struct vty *vty)

hook_call(pathd_srte_config_write, vty);

vty_out(vty, " exit\n");
vty_out(vty, "exit\n");

return 1;
}

Expand Down
3 changes: 3 additions & 0 deletions pathd/path_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions pathd/path_nb.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,21 @@ 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,
bool show_defaults);
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);
Expand Down
Loading