]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgpd.c
bgpd: Auto RD definitions and encoding
[mirror_frr.git] / bgpd / bgpd.c
index e18138584753aaa0e531ad73120428a51b429ff6..53ddbf61cce7a553cebd3dc50242d039f5063179 100644 (file)
@@ -44,6 +44,7 @@
 #include "table.h"
 #include "lib/json.h"
 #include "frr_pthread.h"
+#include "bitfield.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_table.h"
@@ -3000,6 +3001,10 @@ static struct bgp *bgp_create(as_t *as, const char *name,
        QOBJ_REG(bgp, bgp);
 
        update_bgp_group_init(bgp);
+
+       /* assign a unique rd id for auto derivation of vrf's RD */
+       bf_assign_index(bm->rd_idspace, bgp->vrf_rd_id);
+
        bgp_evpn_init(bgp);
        return bgp;
 }
@@ -3381,6 +3386,9 @@ void bgp_free(struct bgp *bgp)
        bgp_address_destroy(bgp);
        bgp_tip_hash_destroy(bgp);
 
+       /* release the auto RD id */
+       bf_release_index(bm->rd_idspace, bgp->vrf_rd_id);
+
        bgp_evpn_cleanup(bgp);
 
        if (bgp->name)