summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-11-04 00:59:19 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-03-01 13:58:32 +0100
commit37fe77317cecd662eafaeab67aad02fed949b388 (patch)
tree30c22ca2369a697a07d9a00457460515ea4935e5 /bgpd
parentMerge pull request #226 from donaldsharp/evpn_fix (diff)
downloadfrr-37fe77317cecd662eafaeab67aad02fed949b388.tar.xz
frr-37fe77317cecd662eafaeab67aad02fed949b388.zip
bgpd, zebra: Allow setting ecmp from daemon cli
When starting up bgp and zebra now, you can specify -e <number> or --ecmp <number> and that number will be used as the maximum ecmp that can be used. The <number specified must be >= 1 and <= MULTIPATH_NUM that Quagga is compiled with. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_main.c10
-rw-r--r--bgpd/bgp_mpath.c6
-rw-r--r--bgpd/bgp_vty.c7
-rw-r--r--bgpd/bgp_zebra.c4
-rw-r--r--bgpd/bgpd.c6
-rw-r--r--bgpd/bgpd.h1
6 files changed, 27 insertions, 7 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 9607d381d..fbbcda591 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -75,6 +75,7 @@ static const struct option longopts[] =
{ "vty_socket", required_argument, NULL, OPTION_VTYSOCK },
{ "retain", no_argument, NULL, 'r'},
{ "no_kernel", no_argument, NULL, 'n'},
+ { "ecmp", required_argument, NULL, 'e'},
{ "user", required_argument, NULL, 'u'},
{ "group", required_argument, NULL, 'g'},
{ "skip_runas", no_argument, NULL, 'S'},
@@ -176,6 +177,7 @@ redistribution between different routing protocols.\n\n\
--vty_socket Override vty socket path\n\
-r, --retain When program terminates, retain added route by bgpd.\n\
-n, --no_kernel Do not install route to kernel.\n\
+-e, --ecmp Specify ECMP to use.\n\
-u, --user User to run as\n\
-g, --group Group to run as\n\
-S, --skip_runas Skip user and group run as\n\
@@ -468,6 +470,14 @@ main (int argc, char **argv)
case 'A':
vty_addr = optarg;
break;
+ case 'e':
+ multipath_num = atoi (optarg);
+ if (multipath_num > MULTIPATH_NUM || multipath_num <= 0)
+ {
+ zlog_err ("Multipath Number specified must be less than %d and greater than 0", MULTIPATH_NUM);
+ return 1;
+ }
+ break;
case 'P':
/* Deal with atoi() returning 0 on failure, and bgpd not
listening on bgp port... */
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index f564ff169..a95c4a008 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -84,11 +84,11 @@ bgp_maximum_paths_unset (struct bgp *bgp, afi_t afi, safi_t safi,
switch (peertype)
{
case BGP_PEER_IBGP:
- bgp->maxpaths[afi][safi].maxpaths_ibgp = MULTIPATH_NUM;
+ bgp->maxpaths[afi][safi].maxpaths_ibgp = multipath_num;
bgp->maxpaths[afi][safi].ibgp_flags = 0;
break;
case BGP_PEER_EBGP:
- bgp->maxpaths[afi][safi].maxpaths_ebgp = MULTIPATH_NUM;
+ bgp->maxpaths[afi][safi].maxpaths_ebgp = multipath_num;
break;
default:
return -1;
@@ -436,7 +436,7 @@ bgp_info_mpath_update (struct bgp_node *rn, struct bgp_info *new_best,
char path_buf[PATH_ADDPATH_STR_BUFFER];
mpath_changed = 0;
- maxpaths = MULTIPATH_NUM;
+ maxpaths = multipath_num;
mpath_count = 0;
cur_mpath = NULL;
old_mpath_count = 0;
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index aa8c3145f..07f2d5945 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -1144,6 +1144,13 @@ bgp_maxpaths_config_vty (struct vty *vty, int peer_type, const char *mpaths,
if (set)
{
maxpaths = strtol(mpaths, NULL, 10);
+ if (maxpaths > multipath_num)
+ {
+ vty_out (vty,
+ "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
+ maxpaths, multipath_num);
+ return CMD_WARNING;
+ }
ret = bgp_maximum_paths_set (bgp, afi, safi, peer_type, maxpaths, options);
}
else
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 822f459c2..2a513dda2 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -69,7 +69,7 @@ struct stream *bgp_ifindices_buf = NULL;
Number of supported next-hops are finite, use of arrays should be ok. */
struct attr attr_cp[MULTIPATH_NUM];
struct attr_extra attr_extra_cp[MULTIPATH_NUM];
-int attr_index = 0;
+unsigned int attr_index = 0;
/* Once per address-family initialization of the attribute array */
#define BGP_INFO_ATTR_BUF_INIT()\
@@ -82,7 +82,7 @@ do {\
#define BGP_INFO_ATTR_BUF_COPY(info_src, info_dst)\
do { \
*info_dst = *info_src; \
- assert(attr_index != MULTIPATH_NUM);\
+ assert(attr_index != multipath_num);\
attr_cp[attr_index].extra = &attr_extra_cp[attr_index]; \
bgp_attr_dup (&attr_cp[attr_index], info_src->attr); \
bgp_attr_deep_dup (&attr_cp[attr_index], info_src->attr); \
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 3512167b0..9b779e5d3 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -93,6 +93,8 @@ struct bgp_master *bm;
/* BGP community-list. */
struct community_list_handler *bgp_clist;
+unsigned int multipath_num = MULTIPATH_NUM;
+
static void bgp_if_init (struct bgp *bgp);
static void bgp_if_finish (struct bgp *bgp);
@@ -2918,8 +2920,8 @@ bgp_create (as_t *as, const char *name, enum bgp_instance_type inst_type)
bgp->rib[afi][safi] = bgp_table_init (afi, safi);
/* Enable maximum-paths */
- bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_EBGP, MULTIPATH_NUM, 0);
- bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_IBGP, MULTIPATH_NUM, 0);
+ bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_EBGP, multipath_num, 0);
+ bgp_maximum_paths_set (bgp, afi, safi, BGP_PEER_IBGP, multipath_num, 0);
}
bgp->v_update_delay = BGP_UPDATE_DELAY_DEF;
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 09c64aa33..f0f2ed87b 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1161,6 +1161,7 @@ typedef enum
} bgp_policy_type_e;
extern struct bgp_master *bm;
+extern unsigned int multipath_num;
/* Prototypes. */
extern void bgp_terminate (void);