[frr] [PATCH 06/11] bgpd: vty command for vrf maximum path configuration
Philippe Guibert
philippe.guibert at 6wind.com
Wed Dec 21 09:13:51 EST 2016
From: Julien Courtat <julien.courtat at 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 under bgp vrf sub node
maximum-path <1-64>
no 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.courtat at 6wind.com>
---
bgpd/bgp_vrf.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
bgpd/bgp_vrf.h | 7 +++++++
2 files changed, 52 insertions(+)
diff --git a/bgpd/bgp_vrf.c b/bgpd/bgp_vrf.c
index dbd9bc9d32f4..90f372b02c6e 100644
--- a/bgpd/bgp_vrf.c
+++ b/bgpd/bgp_vrf.c
@@ -349,6 +349,7 @@ bgp_vrf_lookup_per_name (struct bgp *bgp, const char *name, int create)
return NULL;
QOBJ_REG (vrf, bgp_vrf);
vrf->bgp = bgp;
+ vrf->max_mpath = bgp->maxpaths[AFI_IP][SAFI_MPLS_VPN].maxpaths_ibgp;
vrf->name = strdup (name);
vrf->flag |= BGP_VRF_RD_UNSET;
@@ -1081,6 +1082,46 @@ DEFUN (no_debug_bgp_vrf,
return CMD_SUCCESS;
}
+DEFUN (bgp_vrf_maximum_path,
+ bgp_vrf_maximum_path_cmd,
+ "maximum-path [1-64]",
+ "Maximum number of multipath routes\n"
+ "Maximum number of multipath routes\n"
+)
+{
+ VTY_DECLVAR_CONTEXT_SUB (bgp_vrf, vrf);
+ VTY_DECLVAR_CONTEXT(bgp, bgp);
+ int max_mpath;
+
+ max_mpath = atoi(argv[1]->arg);
+
+ /* some values for maximum path aren't acceptable */
+ if ( BGP_VRF_MINIMUM_PATH > max_mpath || max_mpath > BGP_VRF_MAXIMUM_PATH)
+ {
+ vty_out (vty, "%% Invalid maximum multipath '%d'%s", max_mpath, 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_maximum_path,
+ no_bgp_vrf_maximum_path_cmd,
+ "no maximum-path",
+ NO_STR
+ "maximum path\n"
+)
+{
+ VTY_DECLVAR_CONTEXT_SUB (bgp_vrf, vrf);
+
+ /* reset maximum mpath to default value */
+ vrf->max_mpath = BGP_VRF_MINIMUM_PATH;
+
+ return CMD_SUCCESS;
+}
+
/* BGP VRF init/delete/ show running */
void
bgp_bgpvrf_init (struct bgp *bgp)
@@ -1106,6 +1147,8 @@ void bgp_bgpvrf_vty (void)
install_element (BGP_VRF_NODE, &no_bgp_vrf_rt_import_cmd);
install_element (BGP_VRF_NODE, &no_bgp_vrf_rt_export_cmd);
install_element (BGP_VRF_NODE, &no_bgp_vrf_rt_both_cmd);
+ install_element (BGP_VRF_NODE, &bgp_vrf_maximum_path_cmd);
+ install_element (BGP_VRF_NODE, &no_bgp_vrf_maximum_path_cmd);
install_element (BGP_VRF_NODE, &exit_bgp_vrf_cmd);
install_element (VIEW_NODE, &show_ip_bgp_vrf_cmd);
@@ -1166,6 +1209,8 @@ void bgp_config_write_bgpvrf (struct vty *vty, struct bgp *bgp)
XFREE (MTYPE_ECOMMUNITY_STR, str2_p);
}
}
+ if (vrf->max_mpath != BGP_VRF_MINIMUM_PATH)
+ vty_out (vty, " maximum-path %u%s", vrf->max_mpath, VTY_NEWLINE);
vty_out (vty, " exit%s", VTY_NEWLINE);
}
}
diff --git a/bgpd/bgp_vrf.h b/bgpd/bgp_vrf.h
index 3cae3e1cbc3e..c483c9ca39dd 100644
--- a/bgpd/bgp_vrf.h
+++ b/bgpd/bgp_vrf.h
@@ -38,6 +38,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
/* for debugging */
#define BGP_DEBUG_BGPVRF 0x01
+/* for vrf multipath */
+#define BGP_VRF_MAXIMUM_PATH 64
+#define BGP_VRF_MINIMUM_PATH 1
+
struct bgp_rt_sub
{
@@ -65,6 +69,9 @@ struct bgp_vrf
/* Static route configuration. */
struct bgp_table *route[AFI_MAX];
+ /* maximum multipath entries for the VRF */
+ uint32_t max_mpath;
+
/* internal flag */
#define BGP_VRF_RD_UNSET 1
uint16_t flag;
--
2.1.4
More information about the dev
mailing list