]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: move rd id bitfield to bgp_master
authormitesh <mitesh@cumulusnetworks.com>
Wed, 25 Oct 2017 23:13:32 +0000 (16:13 -0700)
committerMitesh Kanjariya <mitesh@marvel-07.cumulusnetworks.com>
Thu, 14 Dec 2017 18:57:07 +0000 (10:57 -0800)
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>
bgpd/bgp_evpn.c
bgpd/bgpd.c
bgpd/bgpd.h

index 090663beb7d334c3b7dd3ad22310339d4a41bd0c..a17e3bea79ad634373fbaaf616ac1b47ffbaf069 100644 (file)
@@ -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)
index c7161c58625c49995dbab7334674bbccf105c2fb..bfca1d729d30c977f42fe947acd57b9e4b42decc 100644 (file)
@@ -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);
 
index 927056bd484938ca0cddccc2357ba29adbcd9a27..d456d669332a62327699cab24cc34a728beea141 100644 (file)
@@ -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;