Skip to content

Commit

Permalink
vtysh: return non-zero for configuration failures
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

This allows frr-reload.py (or anything else that scripts via vtysh)
to know if the vtysh command worked or hit an error.
  • Loading branch information
Daniel Walton committed Jul 13, 2017
1 parent 4b8197a commit f1a05de
Show file tree
Hide file tree
Showing 67 changed files with 898 additions and 872 deletions.
4 changes: 2 additions & 2 deletions babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ DEFUN (babel_network,
if (ret < 0) {
vty_outln (vty, "There is same network configuration %s",
argv[1]->arg);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

return CMD_SUCCESS;
Expand All @@ -319,7 +319,7 @@ DEFUN (no_babel_network,

if (ret < 0) {
vty_outln (vty, "can't find network %s",argv[2]->arg);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

return CMD_SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions babeld/babel_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ DEFUN (babel_redistribute_type,

if (type < 0) {
vty_outln (vty, "Invalid type %s", argv[1]->arg);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
Expand All @@ -244,7 +244,7 @@ DEFUN (no_babel_redistribute_type,

if (type < 0) {
vty_outln (vty, "Invalid type %s", argv[2]->arg);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
Expand Down Expand Up @@ -279,7 +279,7 @@ DEFUN (debug_babel,

vty_outln (vty, "Invalid type %s", argv[2]->arg);

return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

/* [Babel Command] */
Expand Down Expand Up @@ -309,7 +309,7 @@ DEFUN (no_debug_babel,

vty_outln (vty, "Invalid type %s", argv[3]->arg);

return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}
#endif /* NO_DEBUG */

Expand Down
12 changes: 6 additions & 6 deletions bgpd/bgp_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ DEFUN (neighbor_bfd,

peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;

ret = bgp_bfd_peer_param_set (peer, BFD_DEF_MIN_RX, BFD_DEF_MIN_TX,
BFD_DEF_DETECT_MULT, 1);
Expand Down Expand Up @@ -595,7 +595,7 @@ DEFUN (neighbor_bfd_param,

peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (!peer)
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;

if ((ret = bfd_validate_param (vty, argv[idx_number_1]->arg, argv[idx_number_2]->arg, argv[idx_number_3]->arg, &dm_val,
&rx_val, &tx_val)) != CMD_SUCCESS)
Expand Down Expand Up @@ -626,14 +626,14 @@ DEFUN_HIDDEN (neighbor_bfd_type,

peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (!peer)
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;

if (strmatch(argv[idx_hop]->text, "singlehop"))
type = BFD_TYPE_SINGLEHOP;
else if (strmatch(argv[idx_hop]->text, "multihop"))
type = BFD_TYPE_MULTIHOP;
else
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;

ret = bgp_bfd_peer_param_type_set (peer, type);
if (ret != 0)
Expand All @@ -659,7 +659,7 @@ DEFUN (no_neighbor_bfd,

peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;

ret = bgp_bfd_peer_param_unset(peer);
if (ret != 0)
Expand All @@ -685,7 +685,7 @@ DEFUN_HIDDEN (no_neighbor_bfd_type,

peer = peer_and_group_lookup_vty (vty, argv[idx_peer]->arg);
if (! peer)
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;

if (!peer->bfd_info)
return 0;
Expand Down
10 changes: 5 additions & 5 deletions bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ DEFUN (no_debug_bgp_bestpath_prefix,
{
prefix_free(argv_p);
vty_outln (vty, "%% Malformed Prefix");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

if (bgp_debug_bestpath_prefixes && !list_isempty(bgp_debug_bestpath_prefixes))
Expand Down Expand Up @@ -1338,7 +1338,7 @@ DEFUN (debug_bgp_update_prefix,
{
prefix_free(argv_p);
vty_outln (vty, "%% Malformed Prefix");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}


Expand Down Expand Up @@ -1391,7 +1391,7 @@ DEFUN (no_debug_bgp_update_prefix,
{
prefix_free(argv_p);
vty_outln (vty, "%% Malformed Prefix");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

if (bgp_debug_update_prefixes && !list_isempty(bgp_debug_update_prefixes))
Expand Down Expand Up @@ -1492,7 +1492,7 @@ DEFUN (debug_bgp_zebra_prefix,
{
prefix_free(argv_p);
vty_outln (vty, "%% Malformed Prefix");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

if (!bgp_debug_zebra_prefixes)
Expand Down Expand Up @@ -1562,7 +1562,7 @@ DEFUN (no_debug_bgp_zebra_prefix,
{
prefix_free(argv_p);
vty_outln (vty, "%% Malformed Prefix");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

if (bgp_debug_zebra_prefixes && !list_isempty(bgp_debug_zebra_prefixes))
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ bgp_dump_set (struct vty *vty, struct bgp_dump *bgp_dump,
if (interval == 0)
{
vty_outln (vty, "Malformed interval string");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

/* Setting interval string */
Expand Down
14 changes: 7 additions & 7 deletions bgpd/bgp_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ DEFUN (ip_as_path,
{
vty_outln (vty, "can't compile regexp %s", regstr);
XFREE (MTYPE_TMP, regstr);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

asfilter = as_filter_make (regex, regstr, type);
Expand Down Expand Up @@ -504,7 +504,7 @@ DEFUN (no_ip_as_path,
if (aslist == NULL)
{
vty_outln (vty, "ip as-path access-list %s doesn't exist",aslistname);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

/* Check the filter type. */
Expand All @@ -515,7 +515,7 @@ DEFUN (no_ip_as_path,
else
{
vty_outln (vty, "filter type must be [permit|deny]");
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

/* Compile AS path. */
Expand All @@ -527,7 +527,7 @@ DEFUN (no_ip_as_path,
{
vty_outln (vty, "can't compile regexp %s", regstr);
XFREE (MTYPE_TMP, regstr);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

/* Lookup asfilter. */
Expand All @@ -538,8 +538,8 @@ DEFUN (no_ip_as_path,

if (asfilter == NULL)
{
vty_out (vty, VTYNL);
return CMD_WARNING;
vty_outln (vty, "ip as-path access-list doesn't exist");
return CMD_WARNING_CONFIG_FAILED;
}

as_list_filter_delete (aslist, asfilter);
Expand All @@ -564,7 +564,7 @@ DEFUN (no_ip_as_path_all,
{
vty_outln (vty, "ip as-path access-list %s doesn't exist",
argv[idx_word]->arg);
return CMD_WARNING;
return CMD_WARNING_CONFIG_FAILED;
}

as_list_delete (aslist);
Expand Down
Loading

0 comments on commit f1a05de

Please sign in to comment.