From 8c85ca283b93403d096db3b9dcbb3ed731c3de2b Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 9 Mar 2020 14:55:37 -0400 Subject: [PATCH] bgpd: fix 'no nexthop vpn export' ALIAS without parameters against DEFPY w/ required parameters doesn't work Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index fc841c6c1b..fc89881cae 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7304,7 +7304,7 @@ ALIAS (af_label_vpn_export, DEFPY (af_nexthop_vpn_export, af_nexthop_vpn_export_cmd, - "[no] nexthop vpn export $nexthop_str", + "[no] nexthop vpn export [$nexthop_su]", NO_STR "Specify next hop to use for VRF advertised prefixes\n" "Between current address-family and vpn\n" @@ -7315,14 +7315,14 @@ DEFPY (af_nexthop_vpn_export, VTY_DECLVAR_CONTEXT(bgp, bgp); afi_t afi; struct prefix p; - int idx = 0; - int yes = 1; - if (argv_find(argv, argc, "no", &idx)) - yes = 0; + if (!no) { + if (!nexthop_su) { + vty_out(vty, "%% Nexthop required\n"); + return CMD_WARNING_CONFIG_FAILED; + } - if (yes) { - if (!sockunion2hostprefix(nexthop_str, &p)) + if (!sockunion2hostprefix(nexthop_su, &p)) return CMD_WARNING_CONFIG_FAILED; } @@ -7336,7 +7336,7 @@ DEFPY (af_nexthop_vpn_export, vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, afi, bgp_get_default(), bgp); - if (yes) { + if (!no) { bgp->vpn_policy[afi].tovpn_nexthop = p; SET_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_NEXTHOP_SET); @@ -7352,14 +7352,6 @@ DEFPY (af_nexthop_vpn_export, return CMD_SUCCESS; } -ALIAS (af_nexthop_vpn_export, - af_no_nexthop_vpn_export_cmd, - "no nexthop vpn export", - NO_STR - "Specify next hop to use for VRF advertised prefixes\n" - "Between current address-family and vpn\n" - "For routes leaked from current address-family to vpn\n") - static int vpn_policy_getdirs(struct vty *vty, const char *dstr, int *dodir) { if (!strcmp(dstr, "import")) { @@ -16613,8 +16605,6 @@ void bgp_vty_init(void) install_element(BGP_IPV6_NODE, &af_no_rd_vpn_export_cmd); install_element(BGP_IPV4_NODE, &af_no_label_vpn_export_cmd); install_element(BGP_IPV6_NODE, &af_no_label_vpn_export_cmd); - install_element(BGP_IPV4_NODE, &af_no_nexthop_vpn_export_cmd); - install_element(BGP_IPV6_NODE, &af_no_nexthop_vpn_export_cmd); install_element(BGP_IPV4_NODE, &af_no_rt_vpn_imexport_cmd); install_element(BGP_IPV6_NODE, &af_no_rt_vpn_imexport_cmd); install_element(BGP_IPV4_NODE, &af_no_route_map_vpn_imexport_cmd); -- 2.39.5