From ad36d216b10e1c53b692131f5a5bc1d4537ec10a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 7 May 2020 10:03:31 -0400 Subject: [PATCH] bgpd: `bgp bestpath bandwidth` should not be a legal command The `bgp bestpath bandwidth` command should not be a legal command. Pull out the `no` form to allow this. Allow `no bgp bestpath bandwidth` to work as we would expect. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 56 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0f09369860..8266b76111 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -2987,8 +2987,7 @@ DEFUN (no_bgp_bestpath_med, /* "bgp bestpath bandwidth" configuration. */ DEFPY (bgp_bestpath_bw, bgp_bestpath_bw_cmd, - "[no$no] bgp bestpath bandwidth [$bw_cfg]", - NO_STR + "bgp bestpath bandwidth $bw_cfg", "BGP specific commands\n" "Change the default bestpath selection\n" "Link Bandwidth attribute\n" @@ -3000,22 +2999,18 @@ DEFPY (bgp_bestpath_bw, afi_t afi; safi_t safi; - if (no) { - bgp->lb_handling = BGP_LINK_BW_ECMP; - } else { - if (!bw_cfg) { - vty_out(vty, "%% Bandwidth configuration must be specified\n"); - return CMD_ERR_INCOMPLETE; - } - if (!strcmp(bw_cfg, "ignore")) - bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; - else if (!strcmp(bw_cfg, "skip-missing")) - bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; - else if (!strcmp(bw_cfg, "default-weight-for-missing")) - bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; - else - return CMD_ERR_NO_MATCH; + if (!bw_cfg) { + vty_out(vty, "%% Bandwidth configuration must be specified\n"); + return CMD_ERR_INCOMPLETE; } + if (!strcmp(bw_cfg, "ignore")) + bgp->lb_handling = BGP_LINK_BW_IGNORE_BW; + else if (!strcmp(bw_cfg, "skip-missing")) + bgp->lb_handling = BGP_LINK_BW_SKIP_MISSING; + else if (!strcmp(bw_cfg, "default-weight-for-missing")) + bgp->lb_handling = BGP_LINK_BW_DEFWT_4_MISSING; + else + return CMD_ERR_NO_MATCH; /* This config is used in route install, so redo that. */ FOREACH_AFI_SAFI (afi, safi) { @@ -3027,6 +3022,32 @@ DEFPY (bgp_bestpath_bw, return CMD_SUCCESS; } +DEFPY (no_bgp_bestpath_bw, + no_bgp_bestpath_bw_cmd, + "no bgp bestpath bandwidth [$bw_cfg]", + NO_STR + "BGP specific commands\n" + "Change the default bestpath selection\n" + "Link Bandwidth attribute\n" + "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n" + "Ignore paths without link bandwidth for ECMP (if other paths have it)\n" + "Assign a low default weight (value 1) to paths not having link bandwidth\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + afi_t afi; + safi_t safi; + + bgp->lb_handling = BGP_LINK_BW_ECMP; + + /* This config is used in route install, so redo that. */ + FOREACH_AFI_SAFI (afi, safi) { + if (!bgp_fibupd_safi(safi)) + continue; + bgp_zebra_announce_table(bgp, afi, safi); + } + return CMD_SUCCESS; +} + /* "no bgp default ipv4-unicast". */ DEFUN (no_bgp_default_ipv4_unicast, no_bgp_default_ipv4_unicast_cmd, @@ -15757,6 +15778,7 @@ void bgp_vty_init(void) /* "bgp bestpath bandwidth" commands */ install_element(BGP_NODE, &bgp_bestpath_bw_cmd); + install_element(BGP_NODE, &no_bgp_bestpath_bw_cmd); /* "no bgp default ipv4-unicast" commands. */ install_element(BGP_NODE, &no_bgp_default_ipv4_unicast_cmd); -- 2.39.5