From: mitesh Date: Wed, 25 Oct 2017 23:13:32 +0000 (-0700) Subject: bgpd: move rd id bitfield to bgp_master X-Git-Tag: frr-4.0-dev~58^2~27 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=e9eb5f63edc8b243baf4881c7364d5e7c9c33043;p=mirror%2Ffrr.git 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 --- 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;