From: Julien Courtat <julien.cour...@6wind.com>

Enhancement of new vty command to configure the maximum number of
multipath entries that are possible within a VRF RIB table.

The following command is available:
- vrf rd <RD> maximum-path <1-64>
- no vrf rd <RD> maximum-path <1-64>

Vrfs with a maximum-path of 1 don't display such info in show
running-config.

Signed-off-by: Julien Courtat <julien.cour...@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guib...@6wind.com>
---
 bgpd/bgp_mpath.h |  2 ++
 bgpd/bgp_vty.c   | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 bgpd/bgpd.c      |  5 ++++
 bgpd/bgpd.h      |  3 +++
 4 files changed, 86 insertions(+)

diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h
index 2b3eaf51901f..3fcdf5a0f9ab 100644
--- a/bgpd/bgp_mpath.h
+++ b/bgpd/bgp_mpath.h
@@ -51,6 +51,8 @@ struct bgp_info_mpath
 /* Functions to support maximum-paths configuration */
 extern int bgp_maximum_paths_set (struct bgp *, afi_t, safi_t, int, u_int16_t);
 extern int bgp_maximum_paths_unset (struct bgp *, afi_t, safi_t, int);
+extern int bgp_maxpaths_default_set (struct bgp *, u_int32_t);
+extern int bgp_maxpaths_default_unset (struct bgp *);
 bool bgp_mpath_is_configured_sort (struct bgp *, bgp_peer_sort_t, afi_t, 
safi_t);
 bool bgp_mpath_is_configured (struct bgp *, afi_t, safi_t);
 
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 63a7b5bfdcf6..5fbec0f1a85b 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -10034,6 +10034,50 @@ DEFUN (bgp_vrf_imports,
   return CMD_SUCCESS;
 }
 
+DEFUN (bgp_vrf_maximum_path,
+       bgp_vrf_maximum_path_cmd,
+       "vrf rd WORD maximum-path [1-64]",
+       "BGP VPN VRF\n"
+       "Route Distinguisher\n"
+       "Route Distinguisher\n"
+       "Maximum number of multipath routes\n"
+       "Maximum number of multipath routes\n"
+)
+{
+  struct bgp *bgp = vty->index;
+  struct bgp_vrf *vrf;
+  struct prefix_rd prd;
+  int max_mpath;
+
+  if (! str2prefix_rd (argv[0], &prd))
+    {
+      vty_out (vty, "%% Invalid RD '%s'%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  max_mpath = atoi(argv[1]);
+
+  /* some values for maximum path aren't acceptable */
+  if (1 > max_mpath || max_mpath > 64)
+    {
+      vty_out (vty, "%% Invalid maximum multipath '%d'%s", max_mpath, 
VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  /* look for VRF */
+  vrf = bgp_vrf_lookup (bgp, &prd);
+  if (! vrf)
+    {
+      vty_out (vty, "%% No VRF with RD '%s'%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  /* update max_mpath field in struct bgp_vrf */
+  vrf->max_mpath = max_mpath;
+
+  return CMD_SUCCESS;
+}
+
 DEFUN (no_bgp_vrf,
        no_bgp_vrf_cmd,
        "no vrf rd WORD",
@@ -10063,6 +10107,36 @@ DEFUN (no_bgp_vrf,
   return CMD_SUCCESS;
 }
 
+DEFUN (no_bgp_vrf_maximum_path,
+       no_bgp_vrf_maximum_path_cmd,
+       "no vrf rd WORD maximum-path",
+       NO_STR
+       "BGP VPN VRF\n"
+       "Route Distinguisher\n"
+       "Route Distinguisher\n"
+)
+{
+  struct bgp *bgp = vty->index;
+  struct bgp_vrf *vrf;
+  struct prefix_rd prd;
+
+  if (! str2prefix_rd (argv[0], &prd))
+    {
+      vty_out (vty, "%% Invalid RD '%s'%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+
+  vrf = bgp_vrf_lookup (bgp, &prd);
+  if (! vrf)
+    {
+      vty_out (vty, "%% No VRF with RD '%s'%s", argv[0], VTY_NEWLINE);
+      return CMD_WARNING;
+    }
+  /* reset maximum mpath to default value */
+  vrf->max_mpath = BGP_DEFAULT_MAXPATHS;
+
+  return CMD_SUCCESS;
+}
 /* BGP node structure. */
 static struct cmd_node bgp_node =
 {
@@ -10157,7 +10231,9 @@ bgp_vty_init (void)
   install_element (BGP_NODE, &bgp_vrf_cmd);
   install_element (BGP_NODE, &bgp_vrf_exports_cmd);
   install_element (BGP_NODE, &bgp_vrf_imports_cmd);
+  install_element (BGP_NODE, &bgp_vrf_maximum_path_cmd);
   install_element (BGP_NODE, &no_bgp_vrf_cmd);
+  install_element (BGP_NODE, &no_bgp_vrf_maximum_path_cmd);
 
   /* "bgp multiple-instance" commands. */
   install_element (CONFIG_NODE, &bgp_multiple_instance_cmd);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index a0fe4de390fb..9e091dd2e04b 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2129,6 +2129,7 @@ bgp_vrf_create (struct bgp *bgp, struct prefix_rd 
*outbound_rd)
 
   vrf->bgp = bgp;
   vrf->outbound_rd = *outbound_rd;
+  vrf->max_mpath = bgp->maxpaths[AFI_IP][SAFI_MPLS_VPN].maxpaths_ibgp;
 
   for (afi = AFI_IP; afi < AFI_MAX; afi++)
     {
@@ -5826,6 +5827,10 @@ bgp_config_write (struct vty *vty)
                     XFREE (MTYPE_ECOMMUNITY_STR, str2_p);
                   }
               }
+            if (vrf->max_mpath != BGP_DEFAULT_MAXPATHS)
+              vty_out(vty,
+                      " vrf rd %s maximum-path %d%s", str_p == 
NULL?"<err>":str_p,
+                      vrf->max_mpath, VTY_NEWLINE);
           }
       }
       /* maximum-paths */
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index acf59c5aaf04..505c1389a087 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -225,6 +225,9 @@ struct bgp_vrf
   /* Static route configuration.  */
   struct bgp_table *route[AFI_MAX];
 
+  /* maximum multipath entries for the VRF */
+  uint32_t max_mpath;
+
 };
 
 /* BGP peer-group support. */
-- 
2.1.4


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to