]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Make ASN optional for `no router bgp`
authorQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 14 Jul 2016 13:04:47 +0000 (13:04 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Thu, 14 Jul 2016 13:04:47 +0000 (13:04 +0000)
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 <qlyoung@cumulusnetworks.com>
bgpd/bgp_vty.c

index b1a3116be360b1b6a40ebc75a7e468563ae84a4a..e62a225b0f9a96f59c963c24d7d4a4122d88bd4e 100644 (file)
@@ -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);