]> git.puffer.fish Git - mirror/frr.git/commitdiff
BGP: vtysh should accept just "router bgp" if the AS is already defined
authorDaniel Walton <dwalton@cumulusnetworks.com>
Tue, 3 Nov 2015 18:59:57 +0000 (10:59 -0800)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Tue, 3 Nov 2015 18:59:57 +0000 (10:59 -0800)
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-5674

bgpd/bgp_vty.c
vtysh/extract.pl.in
vtysh/vtysh.c

index 17b3b2fdbc7c5a0559837062bdeef0c8f224fed9..3b4ae3db700705fcd4a247134333538ec1f759f2 100644 (file)
@@ -643,26 +643,48 @@ DEFUN (router_bgp,
   struct bgp *bgp;
   const char *name = NULL;
 
-  VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
+  // "router bgp" without an ASN
+  if (argc < 1)
+    {
+      bgp = bgp_get_default();
 
-  if (argc == 2)
-    name = argv[1];
+      if (bgp == NULL)
+        {
+          vty_out (vty, "%% No BGP process is configured%s", VTY_NEWLINE);
+          return CMD_WARNING;
+        }
 
-  ret = bgp_get (&bgp, &as, name);
-  switch (ret)
+      if (listcount(bm->bgp) > 1)
+        {
+          vty_out (vty, "%% Multiple BGP processes are configured%s", VTY_NEWLINE);
+          return CMD_WARNING;
+        }
+    }
+
+  // "router bgp X"
+  else
     {
-    case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
-      vty_out (vty, "Please specify 'bgp multiple-instance' first%s", 
-              VTY_NEWLINE);
-      return CMD_WARNING;
-    case BGP_ERR_AS_MISMATCH:
-      vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
-      return CMD_WARNING;
-    case BGP_ERR_INSTANCE_MISMATCH:
-      vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
-      vty_out (vty, "BGP instance is already running; AS is %u%s",
-              as, VTY_NEWLINE);
-      return CMD_WARNING;
+      VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX);
+
+      if (argc == 2)
+        name = argv[1];
+
+      ret = bgp_get (&bgp, &as, name);
+      switch (ret)
+        {
+        case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
+          vty_out (vty, "Please specify 'bgp multiple-instance' first%s",
+                   VTY_NEWLINE);
+          return CMD_WARNING;
+        case BGP_ERR_AS_MISMATCH:
+          vty_out (vty, "BGP is already running; AS is %u%s", as, VTY_NEWLINE);
+          return CMD_WARNING;
+        case BGP_ERR_INSTANCE_MISMATCH:
+          vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
+          vty_out (vty, "BGP instance is already running; AS is %u%s",
+                   as, VTY_NEWLINE);
+          return CMD_WARNING;
+        }
     }
 
   vty->node = BGP_NODE;
@@ -680,6 +702,12 @@ ALIAS (router_bgp,
        "BGP view\n"
        "view name\n")
 
+ALIAS (router_bgp,
+       router_bgp_noasn_cmd,
+       "router bgp",
+       ROUTER_STR
+       BGP_STR)
+
 /* "no router bgp" commands. */
 DEFUN (no_router_bgp,
        no_router_bgp_cmd,
@@ -12590,6 +12618,7 @@ bgp_vty_init (void)
   /* "router bgp" commands. */
   install_element (CONFIG_NODE, &router_bgp_cmd);
   install_element (CONFIG_NODE, &router_bgp_view_cmd);
+  install_element (CONFIG_NODE, &router_bgp_noasn_cmd);
 
   /* "no router bgp" commands. */
   install_element (CONFIG_NODE, &no_router_bgp_cmd);
index 56e711592518cadb92e9dccfafab13ed4fa507ce..da0e4563e1165f80bde89de405a67bbd6b2d31af 100755 (executable)
@@ -39,6 +39,7 @@ $ignore{'"router ospf"'} = "ignore";
 $ignore{'"router ospf <1-65535>"'} = "ignore";
 $ignore{'"router ospf6"'} = "ignore";
 $ignore{'"router babel"'} = "ignore";
+$ignore{'"router bgp"'} = "ignore";
 $ignore{'"router bgp " "<1-4294967295>"'} = "ignore";
 $ignore{'"router bgp " "<1-4294967295>" " view WORD"'} = "ignore";
 $ignore{'"router isis WORD"'} = "ignore";
index 58014c2e0d1af26a5516124195ac6cd7d92bd8c1..5786c68c9bdb18fb2bcf022f440645dc4a8f3ee9 100644 (file)
@@ -1041,6 +1041,13 @@ DEFUNSH (VTYSH_BGPD,
   return CMD_SUCCESS;
 }
 
+ALIAS_SH (VTYSH_BGPD,
+         router_bgp,
+         router_bgp_asn_cmd,
+        "router bgp",
+         ROUTER_STR
+         BGP_STR)
+
 ALIAS_SH (VTYSH_BGPD,
          router_bgp,
          router_bgp_view_cmd,
@@ -2817,6 +2824,7 @@ vtysh_init_vty (void)
   install_element (CONFIG_NODE, &router_babel_cmd);
   install_element (CONFIG_NODE, &router_isis_cmd);
   install_element (CONFIG_NODE, &router_bgp_cmd);
+  install_element (CONFIG_NODE, &router_bgp_asn_cmd);
   install_element (CONFIG_NODE, &router_bgp_view_cmd);
   install_element (BGP_NODE, &address_family_vpnv4_cmd);
   install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd);