summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitesh <mitesh@cumulusnetworks.com>2017-10-25 16:13:32 -0700
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>2017-12-14 10:57:07 -0800
commite9eb5f63edc8b243baf4881c7364d5e7c9c33043 (patch)
tree2bc063a8572b50d15f54ab6fed40bf165ed6fffe
parent90384b2471e6b2c4f4a665ddbcce57d2c53b4be6 (diff)
bgpd: move rd id bitfield to bgp_master
currently, we have a rd_id bitfield to assign an unique index for auto RD. This bitfield currently resides under struct bgp which seems wrong. We need to shift this to a global space as this ID space is really global per box. One more reason to keep it at a global data structure is, the ID space could be used by both VNIs and VRFs. Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_evpn.c8
-rw-r--r--bgpd/bgpd.c6
-rw-r--r--bgpd/bgpd.h6
3 files changed, 11 insertions, 9 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 090663beb7..a17e3bea79 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -3443,7 +3443,7 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
vpn->import_rtl->cmp = (int (*)(void *, void *))evpn_route_target_cmp;
vpn->export_rtl = list_new();
vpn->export_rtl->cmp = (int (*)(void *, void *))evpn_route_target_cmp;
- bf_assign_index(bgp->rd_idspace, vpn->rd_id);
+ bf_assign_index(bm->rd_idspace, vpn->rd_id);
derive_rd_rt_for_vni(bgp, vpn);
/* Initialize EVPN route table. */
@@ -3475,7 +3475,7 @@ void bgp_evpn_free(struct bgp *bgp, struct bgpevpn *vpn)
bgp_evpn_unmap_vni_from_its_rts(bgp, vpn);
list_delete_and_null(&vpn->import_rtl);
list_delete_and_null(&vpn->export_rtl);
- bf_release_index(bgp->rd_idspace, vpn->rd_id);
+ bf_release_index(bm->rd_idspace, vpn->rd_id);
hash_release(bgp->vnihash, vpn);
QOBJ_UNREG(vpn);
XFREE(MTYPE_BGP_EVPN, vpn);
@@ -3937,7 +3937,6 @@ void bgp_evpn_cleanup(struct bgp *bgp)
if (bgp->l2vnis)
list_delete_and_null(&bgp->l2vnis);
bgp->l2vnis = NULL;
- bf_free(bgp->rd_idspace);
}
/*
@@ -3967,9 +3966,6 @@ void bgp_evpn_init(struct bgp *bgp)
bgp->l2vnis = list_new();
bgp->l2vnis->cmp =
(int (*)(void *, void *))vni_hash_cmp;
- bf_init(bgp->rd_idspace, UINT16_MAX);
- /*assign 0th index in the bitfield, so that we start with id 1*/
- bf_assign_zero_index(bgp->rd_idspace);
}
void bgp_evpn_vrf_delete(struct bgp *bgp_vrf)
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index c7161c5862..bfca1d729d 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -7401,6 +7401,12 @@ void bgp_master_init(struct thread_master *master)
bgp_process_queue_init();
+ /* init the rd id space.
+ assign 0th index in the bitfield,
+ so that we start with id 1 */
+ bf_init(bm->rd_idspace, UINT16_MAX);
+ bf_assign_zero_index(bm->rd_idspace);
+
/* Enable multiple instances by default. */
bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE);
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 927056bd48..d456d66933 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -137,6 +137,9 @@ struct bgp_master {
/* clang-format off */
#define RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */
+ /* Id space for automatic RD derivation for an EVI/VRF */
+ bitfield_t rd_idspace;
+
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(bgp_master)
@@ -409,9 +412,6 @@ struct bgp {
/* Hash table of VRF import RTs to VRFs */
struct hash *vrf_import_rt_hash;
- /* Id space for automatic RD derivation for an EVI */
- bitfield_t rd_idspace;
-
/* L3-VNI corresponding to this vrf */
vni_t l3vni;