zebra: rename vni to evpn where appropriate

The main zebra_vni_t hash structure has been renamed to zebra_evpn_t
to allow for other transport underlays. Rename functions and variables
to reflect this change.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
This commit is contained in:
Pat Ruddy 2020-07-23 14:51:10 -07:00
parent 2d706c4e25
commit 87d76d5403
5 changed files with 1299 additions and 1299 deletions

View file

@ -55,9 +55,9 @@ DEFINE_MTYPE_STATIC(ZEBRA, ZES_EVI, "ES info per-EVI");
DEFINE_MTYPE_STATIC(ZEBRA, ZMH_INFO, "MH global info");
DEFINE_MTYPE_STATIC(ZEBRA, ZES_VTEP, "VTEP attached to the ES");
static void zebra_evpn_es_get_one_base_vni(void);
static void zebra_evpn_es_get_one_base_evpn(void);
static int zebra_evpn_es_evi_send_to_client(struct zebra_evpn_es *es,
zebra_vni_t *vni, bool add);
zebra_evpn_t *zevpn, bool add);
static void zebra_evpn_local_es_del(struct zebra_evpn_es *es);
static int zebra_evpn_local_es_update(struct zebra_if *zif, uint32_t lid,
struct ethaddr *sysmac);
@ -67,7 +67,7 @@ esi_t zero_esi_buf, *zero_esi = &zero_esi_buf;
/*****************************************************************************/
/* Ethernet Segment to EVI association -
* 1. The ES-EVI entry is maintained as a RB tree per L2-VNI
* (zebra_vni_t.es_evi_rb_tree).
* (zebra_evpn_t.es_evi_rb_tree).
* 2. Each local ES-EVI entry is sent to BGP which advertises it as an
* EAD-EVI (Type-1 EVPN) route
* 3. Local ES-EVI setup is re-evaluated on the following triggers -
@ -81,7 +81,7 @@ esi_t zero_esi_buf, *zero_esi = &zero_esi_buf;
* is then sent to zebra which allocates a NHG for it.
*/
/* compare ES-IDs for the ES-EVI RB tree maintained per-VNI */
/* compare ES-IDs for the ES-EVI RB tree maintained per-EVPN */
static int zebra_es_evi_rb_cmp(const struct zebra_evpn_es_evi *es_evi1,
const struct zebra_evpn_es_evi *es_evi2)
{
@ -94,17 +94,17 @@ RB_GENERATE(zebra_es_evi_rb_head, zebra_evpn_es_evi,
* tables.
*/
static struct zebra_evpn_es_evi *zebra_evpn_es_evi_new(struct zebra_evpn_es *es,
zebra_vni_t *zvni)
zebra_evpn_t *zevpn)
{
struct zebra_evpn_es_evi *es_evi;
es_evi = XCALLOC(MTYPE_ZES_EVI, sizeof(struct zebra_evpn_es_evi));
es_evi->es = es;
es_evi->zvni = zvni;
es_evi->zevpn = zevpn;
/* insert into the VNI-ESI rb tree */
if (RB_INSERT(zebra_es_evi_rb_head, &zvni->es_evi_rb_tree, es_evi)) {
/* insert into the EVPN-ESI rb tree */
if (RB_INSERT(zebra_es_evi_rb_head, &zevpn->es_evi_rb_tree, es_evi)) {
XFREE(MTYPE_ZES_EVI, es_evi);
return NULL;
}
@ -115,15 +115,15 @@ static struct zebra_evpn_es_evi *zebra_evpn_es_evi_new(struct zebra_evpn_es *es,
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("es %s evi %d new",
es_evi->es->esi_str, es_evi->zvni->vni);
es_evi->es->esi_str, es_evi->zevpn->vni);
return es_evi;
}
/* returns TRUE if the VNI is ready to be sent to BGP */
static inline bool zebra_evpn_vni_send_to_client_ok(zebra_vni_t *zvni)
/* returns TRUE if the EVPN is ready to be sent to BGP */
static inline bool zebra_evpn_send_to_client_ok(zebra_evpn_t *zevpn)
{
return !!(zvni->flags & ZVNI_READY_FOR_BGP);
return !!(zevpn->flags & ZEVPN_READY_FOR_BGP);
}
/* Evaluate if the es_evi is ready to be sent BGP -
@ -142,7 +142,7 @@ static void zebra_evpn_es_evi_re_eval_send_to_client(
/* ES and L2-VNI have to be individually ready for BGP */
if ((es_evi->flags & ZEBRA_EVPNES_EVI_LOCAL) &&
(es_evi->es->flags & ZEBRA_EVPNES_READY_FOR_BGP) &&
zebra_evpn_vni_send_to_client_ok(es_evi->zvni))
zebra_evpn_send_to_client_ok(es_evi->zevpn))
es_evi->flags |= ZEBRA_EVPNES_EVI_READY_FOR_BGP;
else
es_evi->flags &= ~ZEBRA_EVPNES_EVI_READY_FOR_BGP;
@ -153,10 +153,10 @@ static void zebra_evpn_es_evi_re_eval_send_to_client(
return;
if (new_ready)
zebra_evpn_es_evi_send_to_client(es_evi->es, es_evi->zvni,
zebra_evpn_es_evi_send_to_client(es_evi->es, es_evi->zevpn,
true /* add */);
else
zebra_evpn_es_evi_send_to_client(es_evi->es, es_evi->zvni,
zebra_evpn_es_evi_send_to_client(es_evi->es, es_evi->zevpn,
false /* add */);
}
@ -166,17 +166,17 @@ static void zebra_evpn_es_evi_re_eval_send_to_client(
static void zebra_evpn_es_evi_free(struct zebra_evpn_es_evi *es_evi)
{
struct zebra_evpn_es *es = es_evi->es;
zebra_vni_t *zvni = es_evi->zvni;
zebra_evpn_t *zevpn = es_evi->zevpn;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("es %s evi %d free",
es_evi->es->esi_str, es_evi->zvni->vni);
es_evi->es->esi_str, es_evi->zevpn->vni);
/* remove from the ES's VNI list */
list_delete_node(es->es_evi_list, &es_evi->es_listnode);
/* remove from the VNI-ESI rb tree */
RB_REMOVE(zebra_es_evi_rb_head, &zvni->es_evi_rb_tree, es_evi);
RB_REMOVE(zebra_es_evi_rb_head, &zevpn->es_evi_rb_tree, es_evi);
/* remove from the VNI-ESI rb tree */
XFREE(MTYPE_ZES_EVI, es_evi);
@ -184,13 +184,13 @@ static void zebra_evpn_es_evi_free(struct zebra_evpn_es_evi *es_evi)
/* find the ES-EVI in the per-L2-VNI RB tree */
static struct zebra_evpn_es_evi *zebra_evpn_es_evi_find(
struct zebra_evpn_es *es, zebra_vni_t *zvni)
struct zebra_evpn_es *es, zebra_evpn_t *zevpn)
{
struct zebra_evpn_es_evi es_evi;
es_evi.es = es;
return RB_FIND(zebra_es_evi_rb_head, &zvni->es_evi_rb_tree, &es_evi);
return RB_FIND(zebra_es_evi_rb_head, &zevpn->es_evi_rb_tree, &es_evi);
}
/* Tell BGP about an ES-EVI deletion and then delete it */
@ -201,50 +201,50 @@ static void zebra_evpn_local_es_evi_do_del(struct zebra_evpn_es_evi *es_evi)
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("local es %s evi %d del",
es_evi->es->esi_str, es_evi->zvni->vni);
es_evi->es->esi_str, es_evi->zevpn->vni);
if (es_evi->flags & ZEBRA_EVPNES_EVI_READY_FOR_BGP) {
/* send a del only if add was sent for it earlier */
zebra_evpn_es_evi_send_to_client(es_evi->es,
es_evi->zvni, false /* add */);
es_evi->zevpn, false /* add */);
}
/* delete it from the VNI's local list */
list_delete_node(es_evi->zvni->local_es_evi_list,
/* delete it from the EVPN's local list */
list_delete_node(es_evi->zevpn->local_es_evi_list,
&es_evi->l2vni_listnode);
es_evi->flags &= ~ZEBRA_EVPNES_EVI_LOCAL;
zebra_evpn_es_evi_free(es_evi);
}
static void zebra_evpn_local_es_evi_del(struct zebra_evpn_es *es,
zebra_vni_t *zvni)
zebra_evpn_t *zevpn)
{
struct zebra_evpn_es_evi *es_evi;
es_evi = zebra_evpn_es_evi_find(es, zvni);
es_evi = zebra_evpn_es_evi_find(es, zevpn);
if (es_evi)
zebra_evpn_local_es_evi_do_del(es_evi);
}
/* Create an ES-EVI if it doesn't already exist and tell BGP */
static void zebra_evpn_local_es_evi_add(struct zebra_evpn_es *es,
zebra_vni_t *zvni)
zebra_evpn_t *zevpn)
{
struct zebra_evpn_es_evi *es_evi;
es_evi = zebra_evpn_es_evi_find(es, zvni);
es_evi = zebra_evpn_es_evi_find(es, zevpn);
if (!es_evi) {
es_evi = zebra_evpn_es_evi_new(es, zvni);
es_evi = zebra_evpn_es_evi_new(es, zevpn);
if (!es_evi)
return;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("local es %s evi %d add",
es_evi->es->esi_str, es_evi->zvni->vni);
es_evi->es->esi_str, es_evi->zevpn->vni);
es_evi->flags |= ZEBRA_EVPNES_EVI_LOCAL;
/* add to the VNI's local list */
/* add to the EVPN's local list */
listnode_init(&es_evi->l2vni_listnode, es_evi);
listnode_add(zvni->local_es_evi_list, &es_evi->l2vni_listnode);
listnode_add(zevpn->local_es_evi_list, &es_evi->l2vni_listnode);
zebra_evpn_es_evi_re_eval_send_to_client(es_evi);
}
@ -263,7 +263,7 @@ static void zebra_evpn_es_evi_show_entry(struct vty *vty,
strlcat(type_str, "L", sizeof(type_str));
vty_out(vty, "%-8d %-30s %-4s\n",
es_evi->zvni->vni, es_evi->es->esi_str,
es_evi->zevpn->vni, es_evi->es->esi_str,
type_str);
}
}
@ -281,7 +281,7 @@ static void zebra_evpn_es_evi_show_entry_detail(struct vty *vty,
strlcat(type_str, "L", sizeof(type_str));
vty_out(vty, "VNI %d ESI: %s\n",
es_evi->zvni->vni, es_evi->es->esi_str);
es_evi->zevpn->vni, es_evi->es->esi_str);
vty_out(vty, " Type: %s\n", type_str);
vty_out(vty, " Ready for BGP: %s\n",
(es_evi->flags &
@ -291,12 +291,12 @@ static void zebra_evpn_es_evi_show_entry_detail(struct vty *vty,
}
}
static void zebra_evpn_es_evi_show_one_vni(zebra_vni_t *zvni,
static void zebra_evpn_es_evi_show_one_evpn(zebra_evpn_t *zevpn,
struct vty *vty, json_object *json, int detail)
{
struct zebra_evpn_es_evi *es_evi;
RB_FOREACH(es_evi, zebra_es_evi_rb_head, &zvni->es_evi_rb_tree) {
RB_FOREACH(es_evi, zebra_es_evi_rb_head, &zevpn->es_evi_rb_tree) {
if (detail)
zebra_evpn_es_evi_show_entry_detail(vty, es_evi, json);
else
@ -310,13 +310,13 @@ struct evpn_mh_show_ctx {
int detail;
};
static void zebra_evpn_es_evi_show_one_vni_hash_cb(struct hash_bucket *bucket,
static void zebra_evpn_es_evi_show_one_evpn_hash_cb(struct hash_bucket *bucket,
void *ctxt)
{
zebra_vni_t *zvni = (zebra_vni_t *)bucket->data;
zebra_evpn_t *zevpn = (zebra_evpn_t *)bucket->data;
struct evpn_mh_show_ctx *wctx = (struct evpn_mh_show_ctx *)ctxt;
zebra_evpn_es_evi_show_one_vni(zvni, wctx->vty,
zebra_evpn_es_evi_show_one_evpn(zevpn, wctx->vty,
wctx->json, wctx->detail);
}
@ -338,71 +338,71 @@ void zebra_evpn_es_evi_show(struct vty *vty, bool uj, int detail)
vty_out(vty, "%-8s %-30s %-4s\n", "VNI", "ESI", "Type");
}
/* Display all L2-VNIs */
hash_iterate(zvrf->vni_table, zebra_evpn_es_evi_show_one_vni_hash_cb,
hash_iterate(zvrf->evpn_table, zebra_evpn_es_evi_show_one_evpn_hash_cb,
&wctx);
}
void zebra_evpn_es_evi_show_vni(struct vty *vty, bool uj, vni_t vni, int detail)
{
json_object *json = NULL;
zebra_vni_t *zvni;
zebra_evpn_t *zevpn;
zvni = zvni_lookup(vni);
if (zvni) {
zevpn = zevpn_lookup(vni);
if (zevpn) {
if (!detail && !json) {
vty_out(vty, "Type: L local, R remote\n");
vty_out(vty, "%-8s %-30s %-4s\n", "VNI", "ESI", "Type");
}
} else {
if (!uj)
vty_out(vty, "VNI %d doesn't exist\n", vni);
vty_out(vty, "VNI %d doesn't exist\n", zevpn->vni);
}
zebra_evpn_es_evi_show_one_vni(zvni, vty, json, detail);
zebra_evpn_es_evi_show_one_evpn(zevpn, vty, json, detail);
}
/* Initialize the ES tables maintained per-L2_VNI */
void zebra_evpn_vni_es_init(zebra_vni_t *zvni)
void zebra_evpn_evpn_es_init(zebra_evpn_t *zevpn)
{
/* Initialize the ES-EVI RB tree */
RB_INIT(zebra_es_evi_rb_head, &zvni->es_evi_rb_tree);
RB_INIT(zebra_es_evi_rb_head, &zevpn->es_evi_rb_tree);
/* Initialize the local and remote ES lists maintained for quick
* walks by type
*/
zvni->local_es_evi_list = list_new();
listset_app_node_mem(zvni->local_es_evi_list);
zevpn->local_es_evi_list = list_new();
listset_app_node_mem(zevpn->local_es_evi_list);
}
/* Cleanup the ES info maintained per-L2_VNI */
void zebra_evpn_vni_es_cleanup(zebra_vni_t *zvni)
/* Cleanup the ES info maintained per- EVPN */
void zebra_evpn_evpn_es_cleanup(zebra_evpn_t *zevpn)
{
struct zebra_evpn_es_evi *es_evi;
struct zebra_evpn_es_evi *es_evi_next;
RB_FOREACH_SAFE(es_evi, zebra_es_evi_rb_head,
&zvni->es_evi_rb_tree, es_evi_next) {
&zevpn->es_evi_rb_tree, es_evi_next) {
zebra_evpn_local_es_evi_do_del(es_evi);
}
list_delete(&zvni->local_es_evi_list);
zebra_evpn_es_clear_base_vni(zvni);
list_delete(&zevpn->local_es_evi_list);
zebra_evpn_es_clear_base_evpn(zevpn);
}
/* called when the oper state or bridge membership changes for the
* vxlan device
*/
void zebra_evpn_vni_update_all_es(zebra_vni_t *zvni)
void zebra_evpn_update_all_es(zebra_evpn_t *zevpn)
{
struct zebra_evpn_es_evi *es_evi;
struct listnode *node;
/* the VNI is now elgible as a base for EVPN-MH */
if (zebra_evpn_vni_send_to_client_ok(zvni))
zebra_evpn_es_set_base_vni(zvni);
/* the EVPN is now elgible as a base for EVPN-MH */
if (zebra_evpn_send_to_client_ok(zevpn))
zebra_evpn_es_set_base_evpn(zevpn);
else
zebra_evpn_es_clear_base_vni(zvni);
zebra_evpn_es_clear_base_evpn(zevpn);
for (ALL_LIST_ELEMENTS_RO(zvni->local_es_evi_list, node, es_evi))
for (ALL_LIST_ELEMENTS_RO(zevpn->local_es_evi_list, node, es_evi))
zebra_evpn_es_evi_re_eval_send_to_client(es_evi);
}
@ -514,24 +514,24 @@ static void zebra_evpn_acc_bd_free_on_deref(struct zebra_evpn_access_bd *acc_bd)
}
/* called when a EVPN-L2VNI is set or cleared against a BD */
static void zebra_evpn_acc_bd_vni_set(struct zebra_evpn_access_bd *acc_bd,
zebra_vni_t *zvni, zebra_vni_t *old_zvni)
static void zebra_evpn_acc_bd_evpn_set(struct zebra_evpn_access_bd *acc_bd,
zebra_evpn_t *zevpn, zebra_evpn_t *old_zevpn)
{
struct zebra_if *zif;
struct listnode *node;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("access vlan %d l2-vni %u set",
acc_bd->vid, zvni ? zvni->vni : 0);
acc_bd->vid, zevpn ? zevpn->vni : 0);
for (ALL_LIST_ELEMENTS_RO(acc_bd->mbr_zifs, node, zif)) {
if (!zif->es_info.es)
continue;
if (zvni)
zebra_evpn_local_es_evi_add(zif->es_info.es, zvni);
else if (old_zvni)
zebra_evpn_local_es_evi_del(zif->es_info.es, old_zvni);
if (zevpn)
zebra_evpn_local_es_evi_add(zif->es_info.es, zevpn);
else if (old_zevpn)
zebra_evpn_local_es_evi_del(zif->es_info.es, old_zevpn);
}
}
@ -540,7 +540,7 @@ void zebra_evpn_vl_vxl_ref(uint16_t vid, struct zebra_if *vxlan_zif)
{
struct zebra_evpn_access_bd *acc_bd;
struct zebra_if *old_vxlan_zif;
zebra_vni_t *old_zvni;
zebra_evpn_t *old_zevpn;
if (!vid)
return;
@ -554,20 +554,20 @@ void zebra_evpn_vl_vxl_ref(uint16_t vid, struct zebra_if *vxlan_zif)
if (vxlan_zif == old_vxlan_zif)
return;
old_zvni = acc_bd->zvni;
acc_bd->zvni = zvni_lookup(vxlan_zif->l2info.vxl.vni);
if (acc_bd->zvni == old_zvni)
old_zevpn = acc_bd->zevpn;
acc_bd->zevpn = zevpn_lookup(vxlan_zif->l2info.vxl.vni);
if (acc_bd->zevpn == old_zevpn)
return;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("access vlan %d vni %u ref",
acc_bd->vid, vxlan_zif->l2info.vxl.vni);
if (old_zvni)
zebra_evpn_acc_bd_vni_set(acc_bd, NULL, old_zvni);
if (old_zevpn)
zebra_evpn_acc_bd_evpn_set(acc_bd, NULL, old_zevpn);
if (acc_bd->zvni)
zebra_evpn_acc_bd_vni_set(acc_bd, acc_bd->zvni, NULL);
if (acc_bd->zevpn)
zebra_evpn_acc_bd_evpn_set(acc_bd, acc_bd->zevpn, NULL);
}
/* handle VLAN->VxLAN_IF deref */
@ -590,18 +590,18 @@ void zebra_evpn_vl_vxl_deref(uint16_t vid, struct zebra_if *vxlan_zif)
zlog_debug("access vlan %d vni %u deref",
acc_bd->vid, vxlan_zif->l2info.vxl.vni);
if (acc_bd->zvni)
zebra_evpn_acc_bd_vni_set(acc_bd, NULL, acc_bd->zvni);
if (acc_bd->zevpn)
zebra_evpn_acc_bd_evpn_set(acc_bd, NULL, acc_bd->zevpn);
acc_bd->zvni = NULL;
acc_bd->zevpn = NULL;
acc_bd->vxlan_zif = NULL;
/* if there are no other references the access_bd can be freed */
zebra_evpn_acc_bd_free_on_deref(acc_bd);
}
/* handle EVPN L2VNI add/del */
void zebra_evpn_vxl_vni_set(struct zebra_if *zif, zebra_vni_t *zvni,
/* handle EVPN add/del */
void zebra_evpn_vxl_evpn_set(struct zebra_if *zif, zebra_evpn_t *zevpn,
bool set)
{
struct zebra_l2info_vxlan *vxl;
@ -617,16 +617,16 @@ void zebra_evpn_vxl_vni_set(struct zebra_if *zif, zebra_vni_t *zvni,
return;
if (set) {
zebra_evpn_es_set_base_vni(zvni);
if (acc_bd->zvni != zvni) {
acc_bd->zvni = zvni;
zebra_evpn_acc_bd_vni_set(acc_bd, zvni, NULL);
zebra_evpn_es_set_base_evpn(zevpn);
if (acc_bd->zevpn != zevpn) {
acc_bd->zevpn = zevpn;
zebra_evpn_acc_bd_evpn_set(acc_bd, zevpn, NULL);
}
} else {
if (acc_bd->zvni) {
zebra_vni_t *old_zvni = acc_bd->zvni;
acc_bd->zvni = NULL;
zebra_evpn_acc_bd_vni_set(acc_bd, NULL, old_zvni);
if (acc_bd->zevpn) {
zebra_evpn_t *old_zevpn = acc_bd->zevpn;
acc_bd->zevpn = NULL;
zebra_evpn_acc_bd_evpn_set(acc_bd, NULL, old_zevpn);
}
}
}
@ -651,8 +651,8 @@ void zebra_evpn_vl_mbr_ref(uint16_t vid, struct zebra_if *zif)
vid, zif->ifp->name);
listnode_add(acc_bd->mbr_zifs, zif);
if (acc_bd->zvni && zif->es_info.es)
zebra_evpn_local_es_evi_add(zif->es_info.es, acc_bd->zvni);
if (acc_bd->zevpn && zif->es_info.es)
zebra_evpn_local_es_evi_add(zif->es_info.es, acc_bd->zevpn);
}
/* handle deletion of VLAN members */
@ -678,8 +678,8 @@ void zebra_evpn_vl_mbr_deref(uint16_t vid, struct zebra_if *zif)
list_delete_node(acc_bd->mbr_zifs, node);
if (acc_bd->zvni && zif->es_info.es)
zebra_evpn_local_es_evi_del(zif->es_info.es, acc_bd->zvni);
if (acc_bd->zevpn && zif->es_info.es)
zebra_evpn_local_es_evi_del(zif->es_info.es, acc_bd->zevpn);
/* if there are no other references the access_bd can be freed */
zebra_evpn_acc_bd_free_on_deref(acc_bd);
@ -699,7 +699,7 @@ static void zebra_evpn_acc_vl_show_entry_detail(struct vty *vty,
acc_bd->vxlan_zif ?
acc_bd->vxlan_zif->ifp->name : "-");
vty_out(vty, " L2-VNI: %d\n",
acc_bd->zvni ? acc_bd->zvni->vni : 0);
acc_bd->zevpn ? acc_bd->zevpn->vni : 0);
vty_out(vty, " Member Count: %d\n",
listcount(acc_bd->mbr_zifs));
vty_out(vty, " Members: \n");
@ -717,7 +717,7 @@ static void zebra_evpn_acc_vl_show_entry(struct vty *vty,
acc_bd->vid,
acc_bd->vxlan_zif ?
acc_bd->vxlan_zif->ifp->name : "-",
acc_bd->zvni ? acc_bd->zvni->vni : 0,
acc_bd->zevpn ? acc_bd->zevpn->vni : 0,
listcount(acc_bd->mbr_zifs));
}
@ -961,7 +961,7 @@ static void zebra_evpn_nh_del(struct zebra_evpn_es_vtep *es_vtep)
/* A list of remote VTEPs is maintained for each ES. This list includes -
* 1. VTEPs for which we have imported the ESR i.e. ES-peers
* 2. VTEPs that have an "active" ES-EVI VTEP i.e. EAD-per-ES and EAD-per-EVI
* have been imported into one or more VNIs
* have been imported into one or more EVPNs
*/
static int zebra_evpn_es_vtep_cmp(void *p1, void *p2)
{
@ -1257,11 +1257,11 @@ void zebra_evpn_es_send_all_to_client(bool add)
if (add)
zebra_evpn_es_evi_send_to_client(
es, es_evi->zvni,
es, es_evi->zevpn,
true /* add */);
else
zebra_evpn_es_evi_send_to_client(
es, es_evi->zvni,
es, es_evi->zevpn,
false /* add */);
}
if (!add)
@ -1283,8 +1283,8 @@ static void zebra_evpn_es_setup_evis(struct zebra_evpn_es *es)
bf_for_each_set_bit(zif->vlan_bitmap, vid, IF_VLAN_BITMAP_MAX) {
acc_bd = zebra_evpn_acc_vl_find(vid);
if (acc_bd->zvni)
zebra_evpn_local_es_evi_add(es, acc_bd->zvni);
if (acc_bd->zevpn)
zebra_evpn_local_es_evi_add(es, acc_bd->zevpn);
}
}
@ -1328,8 +1328,8 @@ static void zebra_evpn_es_local_info_set(struct zebra_evpn_es *es,
/* setup base-vni if one doesn't already exist; the ES will get sent
* to BGP as a part of that process
*/
if (!zmh_info->es_base_vni)
zebra_evpn_es_get_one_base_vni();
if (!zmh_info->es_base_evpn)
zebra_evpn_es_get_one_base_evpn();
else
/* send notification to bgp */
zebra_evpn_es_re_eval_send_to_client(es,
@ -1621,7 +1621,7 @@ bool zebra_evpn_es_mac_ref(zebra_mac_t *mac, esi_t *esi)
/* Inform BGP about local ES-EVI add or del */
static int zebra_evpn_es_evi_send_to_client(struct zebra_evpn_es *es,
zebra_vni_t *zvni, bool add)
zebra_evpn_t *zevpn, bool add)
{
struct zserv *client;
struct stream *s;
@ -1637,7 +1637,7 @@ static int zebra_evpn_es_evi_send_to_client(struct zebra_evpn_es *es,
add ? ZEBRA_LOCAL_ES_EVI_ADD : ZEBRA_LOCAL_ES_EVI_DEL,
zebra_vrf_get_evpn_id());
stream_put(s, &es->esi, sizeof(esi_t));
stream_putl(s, zvni->vni);
stream_putl(s, zevpn->vni);
/* Write packet size. */
stream_putw_at(s, 0, stream_get_endp(s));
@ -1645,7 +1645,7 @@ static int zebra_evpn_es_evi_send_to_client(struct zebra_evpn_es *es,
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("send %s local es %s evi %u to %s",
add ? "add" : "del",
es->esi_str, zvni->vni,
es->esi_str, zevpn->vni,
zebra_route_string(client->proto));
client->local_es_add_cnt++;
@ -1979,39 +1979,39 @@ DEFPY(zebra_evpn_es_id,
* necessary
*/
/* called when a new vni is added or becomes oper up or becomes a bridge port */
void zebra_evpn_es_set_base_vni(zebra_vni_t *zvni)
void zebra_evpn_es_set_base_evpn(zebra_evpn_t *zevpn)
{
struct listnode *node;
struct zebra_evpn_es *es;
if (zmh_info->es_base_vni) {
if (zmh_info->es_base_vni != zvni) {
/* unrelated VNI; ignore it */
if (zmh_info->es_base_evpn) {
if (zmh_info->es_base_evpn != zevpn) {
/* unrelated EVPN; ignore it */
return;
}
/* check if the local vtep-ip has changed */
} else {
/* check if the VNI can be used as base VNI */
if (!zebra_evpn_vni_send_to_client_ok(zvni))
/* check if the EVPN can be used as base EVPN */
if (!zebra_evpn_send_to_client_ok(zevpn))
return;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("es base vni set to %d",
zvni->vni);
zmh_info->es_base_vni = zvni;
zevpn->vni);
zmh_info->es_base_evpn = zevpn;
}
/* update local VTEP-IP */
if (zmh_info->es_originator_ip.s_addr ==
zmh_info->es_base_vni->local_vtep_ip.s_addr)
zmh_info->es_base_evpn->local_vtep_ip.s_addr)
return;
zmh_info->es_originator_ip.s_addr =
zmh_info->es_base_vni->local_vtep_ip.s_addr;
zmh_info->es_base_evpn->local_vtep_ip.s_addr;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("es originator ip set to %s",
inet_ntoa(zmh_info->es_base_vni->local_vtep_ip));
inet_ntoa(zmh_info->es_base_evpn->local_vtep_ip));
/* if originator ip changes we need to update bgp */
for (ALL_LIST_ELEMENTS_RO(zmh_info->local_es_list, node, es)) {
@ -2026,20 +2026,20 @@ void zebra_evpn_es_set_base_vni(zebra_vni_t *zvni)
/* called when a vni is removed or becomes oper down or is removed from a
* bridge
*/
void zebra_evpn_es_clear_base_vni(zebra_vni_t *zvni)
void zebra_evpn_es_clear_base_evpn(zebra_evpn_t *zevpn)
{
struct listnode *node;
struct zebra_evpn_es *es;
if (zmh_info->es_base_vni != zvni)
if (zmh_info->es_base_evpn != zevpn)
return;
zmh_info->es_base_vni = NULL;
/* lost current base VNI; try to find a new one */
zebra_evpn_es_get_one_base_vni();
zmh_info->es_base_evpn = NULL;
/* lost current base EVPN; try to find a new one */
zebra_evpn_es_get_one_base_evpn();
/* couldn't locate an eligible base vni */
if (!zmh_info->es_base_vni && zmh_info->es_originator_ip.s_addr) {
/* couldn't locate an eligible base evpn */
if (!zmh_info->es_base_evpn && zmh_info->es_originator_ip.s_addr) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES)
zlog_debug("es originator ip cleared");
@ -2053,27 +2053,27 @@ void zebra_evpn_es_clear_base_vni(zebra_vni_t *zvni)
}
/* Locate an "eligible" L2-VNI to follow */
static int zebra_evpn_es_get_one_base_vni_cb(struct hash_bucket *b, void *data)
static int zebra_evpn_es_get_one_base_evpn_cb(struct hash_bucket *b, void *data)
{
zebra_vni_t *zvni = b->data;
zebra_evpn_t *zevpn = b->data;
zebra_evpn_es_set_base_vni(zvni);
zebra_evpn_es_set_base_evpn(zevpn);
if (zmh_info->es_base_vni)
if (zmh_info->es_base_evpn)
return HASHWALK_ABORT;
return HASHWALK_CONTINUE;
}
/* locate a base_vni to follow for the purposes of common params like
/* locate a base_evpn to follow for the purposes of common params like
* originator IP
*/
static void zebra_evpn_es_get_one_base_vni(void)
static void zebra_evpn_es_get_one_base_evpn(void)
{
struct zebra_vrf *zvrf;
zvrf = zebra_vrf_get_evpn();
hash_walk(zvrf->vni_table, zebra_evpn_es_get_one_base_vni_cb, NULL);
hash_walk(zvrf->evpn_table, zebra_evpn_es_get_one_base_evpn_cb, NULL);
}
/*****************************************************************************/

View file

@ -79,8 +79,8 @@ RB_HEAD(zebra_es_rb_head, zebra_evpn_es);
RB_PROTOTYPE(zebra_es_rb_head, zebra_evpn_es, rb_node, zebra_es_rb_cmp);
/* ES per-EVI info
* - ES-EVIs are maintained per-VNI (vni->es_evi_rb_tree)
* - Local ES-EVIs are linked to per-VNI list for quick access
* - ES-EVIs are maintained per-EVPN (vni->es_evi_rb_tree)
* - Local ES-EVIs are linked to per-EVPN list for quick access
* - Although some infrastucture is present for remote ES-EVIs, currently
* BGP does NOT send remote ES-EVIs to zebra. This may change in the
* future (but must be changed thoughtfully and only if needed as ES-EVI
@ -88,7 +88,7 @@ RB_PROTOTYPE(zebra_es_rb_head, zebra_evpn_es, rb_node, zebra_es_rb_cmp);
*/
struct zebra_evpn_es_evi {
struct zebra_evpn_es *es;
zebra_vni_t *zvni;
zebra_evpn_t *zevpn;
/* ES-EVI flags */
uint32_t flags;
@ -97,11 +97,11 @@ struct zebra_evpn_es_evi {
#define ZEBRA_EVPNES_EVI_READY_FOR_BGP (1 << 1) /* ready to be sent to BGP */
/* memory used for adding the es_evi to
* es_evi->zvni->es_evi_rb_tree
* es_evi->zevpn->es_evi_rb_tree
*/
RB_ENTRY(zebra_evpn_es_evi) rb_node;
/* memory used for linking the es_evi to
* es_evi->zvni->local_es_evi_list
* es_evi->zevpn->local_es_evi_list
*/
struct listnode l2vni_listnode;
/* memory used for linking the es_evi to
@ -135,8 +135,8 @@ struct zebra_evpn_access_bd {
struct zebra_if *vxlan_zif; /* vxlan device */
/* list of members associated with the BD i.e. (potential) ESs */
struct list *mbr_zifs;
/* presence of zvni activates the EVI on all the ESs in mbr_zifs */
zebra_vni_t *zvni;
/* presence of zevpn activates the EVI on all the ESs in mbr_zifs */
zebra_evpn_t *zevpn;
};
/* multihoming information stored in zrouter */
@ -155,7 +155,7 @@ struct zebra_evpn_mh_info {
* XXX: once single vxlan device model becomes available this will
* not be necessary
*/
zebra_vni_t *es_base_vni;
zebra_evpn_t *es_base_evpn;
struct in_addr es_originator_ip;
/* L2 NH and NHG ids -
@ -198,12 +198,12 @@ extern void zebra_evpn_mh_terminate(void);
extern bool zebra_evpn_is_if_es_capable(struct zebra_if *zif);
extern void zebra_evpn_if_init(struct zebra_if *zif);
extern void zebra_evpn_if_cleanup(struct zebra_if *zif);
extern void zebra_evpn_vni_es_init(zebra_vni_t *zvni);
extern void zebra_evpn_vni_es_cleanup(zebra_vni_t *zvni);
extern void zebra_evpn_vxl_vni_set(struct zebra_if *zif, zebra_vni_t *zvni,
extern void zebra_evpn_evpn_es_init(zebra_evpn_t *zevpn);
extern void zebra_evpn_evpn_es_cleanup(zebra_evpn_t *zevpn);
extern void zebra_evpn_vxl_evpn_set(struct zebra_if *zif, zebra_evpn_t *zevpn,
bool set);
extern void zebra_evpn_es_set_base_vni(zebra_vni_t *zvni);
extern void zebra_evpn_es_clear_base_vni(zebra_vni_t *zvni);
extern void zebra_evpn_es_set_base_evpn(zebra_evpn_t *zevpn);
extern void zebra_evpn_es_clear_base_evpn(zebra_evpn_t *zevpn);
extern void zebra_evpn_vl_vxl_ref(uint16_t vid, struct zebra_if *vxlan_zif);
extern void zebra_evpn_vl_vxl_deref(uint16_t vid, struct zebra_if *vxlan_zif);
extern void zebra_evpn_vl_mbr_ref(uint16_t vid, struct zebra_if *zif);
@ -213,7 +213,7 @@ extern void zebra_evpn_es_if_oper_state_change(struct zebra_if *zif, bool up);
extern void zebra_evpn_es_show(struct vty *vty, bool uj);
extern void zebra_evpn_es_show_detail(struct vty *vty, bool uj);
extern void zebra_evpn_es_show_esi(struct vty *vty, bool uj, esi_t *esi);
extern void zebra_evpn_vni_update_all_es(zebra_vni_t *zvni);
extern void zebra_evpn_update_all_es(zebra_evpn_t *zevpn);
extern void zebra_evpn_proc_remote_es(ZAPI_HANDLER_ARGS);
extern void zebra_evpn_es_evi_show(struct vty *vty, bool uj, int detail);
extern void zebra_evpn_es_evi_show_vni(struct vty *vty, bool uj,

View file

@ -130,9 +130,9 @@ struct zebra_vrf {
#define MPLS_FLAG_SCHEDULE_LSPS (1 << 0)
/*
* VNI hash table (for EVPN). Only in the EVPN instance.
* EVPN hash table. Only in the EVPN instance.
*/
struct hash *vni_table;
struct hash *evpn_table;
/*
* Whether EVPN is enabled or not. Only in the EVPN instance.

File diff suppressed because it is too large Load diff

View file

@ -37,7 +37,7 @@ extern "C" {
#define ERR_STR_SZ 256
/* definitions */
typedef struct zebra_vni_t_ zebra_vni_t;
typedef struct zebra_evpn_t_ zebra_evpn_t;
typedef struct zebra_vtep_t_ zebra_vtep_t;
typedef struct zebra_mac_t_ zebra_mac_t;
typedef struct zebra_neigh_t_ zebra_neigh_t;
@ -72,13 +72,13 @@ RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
* Contains information pertaining to a VNI:
* - the list of remote VTEPs (with this VNI)
*/
struct zebra_vni_t_ {
struct zebra_evpn_t_ {
/* VNI - key */
vni_t vni;
/* ES flags */
uint32_t flags;
#define ZVNI_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
#define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
/* Flag for advertising gw macip */
uint8_t advertise_gw_macip;
@ -333,8 +333,8 @@ struct zebra_mac_t_ {
#define ZEBRA_MAC_ALL_PEER_FLAGS (ZEBRA_MAC_ES_PEER_PROXY |\
ZEBRA_MAC_ES_PEER_ACTIVE)
/* back pointer to zvni */
zebra_vni_t *zvni;
/* back pointer to zevpn */
zebra_evpn_t *zevpn;
/* Local or remote info. */
union {
@ -383,7 +383,7 @@ struct zebra_mac_t_ {
* Context for MAC hash walk - used by callbacks.
*/
struct mac_walk_ctx {
zebra_vni_t *zvni; /* VNI hash */
zebra_evpn_t *zevpn; /* EVPN hash */
struct zebra_vrf *zvrf; /* VRF - for client notification. */
int uninstall; /* uninstall from kernel? */
int upd_client; /* uninstall from client? */
@ -451,7 +451,7 @@ struct zebra_neigh_t_ {
/* Underlying interface. */
ifindex_t ifindex;
zebra_vni_t *zvni;
zebra_evpn_t *zevpn;
uint32_t flags;
#define ZEBRA_NEIGH_LOCAL 0x01
@ -509,7 +509,7 @@ struct zebra_neigh_t_ {
* Context for neighbor hash walk - used by callbacks.
*/
struct neigh_walk_ctx {
zebra_vni_t *zvni; /* VNI hash */
zebra_evpn_t *zevpn; /* VNI hash */
struct zebra_vrf *zvrf; /* VRF - for client notification. */
int uninstall; /* uninstall from kernel? */
int upd_client; /* uninstall from client? */
@ -532,7 +532,7 @@ struct neigh_walk_ctx {
/* context for neigh hash walk - update l3vni and rmac */
struct neigh_l3info_walk_ctx {
zebra_vni_t *zvni;
zebra_evpn_t *zevpn;
zebra_l3vni_t *zl3vni;
int add;
};
@ -579,7 +579,7 @@ typedef struct zebra_vxlan_sg_ {
uint32_t ref_cnt;
} zebra_vxlan_sg_t;
extern zebra_vni_t *zvni_lookup(vni_t vni);
extern zebra_evpn_t *zevpn_lookup(vni_t vni);
extern void zebra_vxlan_sync_mac_dp_install(zebra_mac_t *mac, bool set_inactive,
bool force_clear_static, const char *caller);