From 7fb21a9f987c06edd11a23fed0999ef36d7fe685 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 14 Jul 2016 13:04:47 +0000 Subject: [PATCH] bgpd: Make ASN optional for `no router bgp` When there is one BGP router instance, `no router bgp` may be used to deconfigure it without specifying its ASN Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b1a3116be3..e62a225b0f 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -745,17 +745,39 @@ DEFUN (no_router_bgp, struct bgp *bgp; const char *name = NULL; - VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); - if (argc == 3) - name = argv[2]; + // "no router bgp" without an ASN + if (argc < 1) + { + //Pending: Make VRF option available for ASN less config + bgp = bgp_get_default(); - /* Lookup bgp structure. */ - bgp = bgp_lookup (as, name); - if (! bgp) + if (bgp == NULL) + { + vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (listcount(bm->bgp) > 1) + { + vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + else { - vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); - return CMD_WARNING; + VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); + + if (argc == 3) + name = argv[2]; + + /* Lookup bgp structure. */ + bgp = bgp_lookup (as, name); + if (! bgp) + { + vty_out (vty, "%% Can't find BGP instance%s", VTY_NEWLINE); + return CMD_WARNING; + } } bgp_delete (bgp); @@ -773,6 +795,13 @@ ALIAS (no_router_bgp, "BGP view\nBGP VRF\n" "View/VRF name\n") +ALIAS (no_router_bgp, + no_router_bgp_noasn_cmd, + "no router bgp", + NO_STR + ROUTER_STR + BGP_STR) + /* BGP router-id. */ DEFUN (bgp_router_id, @@ -14382,6 +14411,7 @@ bgp_vty_init (void) /* "no router bgp" commands. */ install_element (CONFIG_NODE, &no_router_bgp_cmd); install_element (CONFIG_NODE, &no_router_bgp_instance_cmd); + install_element (CONFIG_NODE, &no_router_bgp_noasn_cmd); /* "bgp router-id" commands. */ install_element (BGP_NODE, &bgp_router_id_cmd); -- 2.39.5