From 72f2674a9526572b243026b8e809688ae814d5a8 Mon Sep 17 00:00:00 2001 From: Anuradha Karuppiah Date: Tue, 14 Apr 2020 08:30:09 -0700 Subject: [PATCH] zebra: handle local-es bridge port association A local ES can be added or removed to a bridge after it is created. When it becomes a bridge port member the dataplane attributes need to be programmed. Signed-off-by: Anuradha Karuppiah --- zebra/zebra_evpn_mh.c | 41 ++++++++++++++++++++++++++++++++++++++--- zebra/zebra_evpn_mh.h | 1 + zebra/zebra_l2.c | 4 ++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c index 3c457bdfa5..02c0736767 100644 --- a/zebra/zebra_evpn_mh.c +++ b/zebra/zebra_evpn_mh.c @@ -1505,6 +1505,30 @@ static void zebra_evpn_es_local_mac_update(struct zebra_evpn_es *es, } } +void zebra_evpn_es_local_br_port_update(struct zebra_if *zif) +{ + struct zebra_evpn_es *es = zif->es_info.es; + bool old_br_port = !!(es->flags & ZEBRA_EVPNES_BR_PORT); + bool new_br_port; + + if (zif->brslave_info.bridge_ifindex != IFINDEX_INTERNAL) + es->flags |= ZEBRA_EVPNES_BR_PORT; + else + es->flags &= ~ZEBRA_EVPNES_BR_PORT; + + new_br_port = !!(es->flags & ZEBRA_EVPNES_BR_PORT); + if (old_br_port == new_br_port) + return; + + if (IS_ZEBRA_DEBUG_EVPN_MH_ES) + zlog_debug("es %s br_port change old %u new %u", es->esi_str, + old_br_port, new_br_port); + + /* update the dataplane br_port attrs */ + if (new_br_port && zebra_evpn_es_br_port_dplane_update_needed(es)) + zebra_evpn_es_br_port_dplane_update(es, __func__); +} + static void zebra_evpn_es_local_info_set(struct zebra_evpn_es *es, struct zebra_if *zif) { @@ -1529,6 +1553,9 @@ static void zebra_evpn_es_local_info_set(struct zebra_evpn_es *es, if (if_is_operative(zif->ifp)) es->flags |= ZEBRA_EVPNES_OPER_UP; + if (zif->brslave_info.bridge_ifindex != IFINDEX_INTERNAL) + es->flags |= ZEBRA_EVPNES_BR_PORT; + /* setup base-vni if one doesn't already exist; the ES will get sent * to BGP as a part of that process */ @@ -1590,6 +1617,9 @@ static void zebra_evpn_es_local_info_clear(struct zebra_evpn_es **esp) zif->es_info.es = NULL; es->zif = NULL; + /* clear all local flags associated with the ES */ + es->flags &= ~(ZEBRA_EVPNES_OPER_UP | ZEBRA_EVPNES_BR_PORT); + /* remove from the ES list */ list_delete_node(zmh_info->local_es_list, &es->local_es_listnode); @@ -2094,9 +2124,14 @@ static void zebra_evpn_es_show_entry_detail(struct vty *vty, vty_out(vty, " Interface: %s\n", (es->zif) ? es->zif->ifp->name : "-"); - vty_out(vty, " State: %s\n", - (es->flags & ZEBRA_EVPNES_OPER_UP) ? - "up" : "down"); + if (es->flags & ZEBRA_EVPNES_LOCAL) { + vty_out(vty, " State: %s\n", + (es->flags & ZEBRA_EVPNES_OPER_UP) ? "up" + : "down"); + vty_out(vty, " Bridge port: %s\n", + (es->flags & ZEBRA_EVPNES_BR_PORT) ? "yes" + : "no"); + } vty_out(vty, " Ready for BGP: %s\n", (es->flags & ZEBRA_EVPNES_READY_FOR_BGP) ? "yes" : "no"); diff --git a/zebra/zebra_evpn_mh.h b/zebra/zebra_evpn_mh.h index da3c31df95..ee162ad486 100644 --- a/zebra/zebra_evpn_mh.h +++ b/zebra/zebra_evpn_mh.h @@ -257,5 +257,6 @@ extern int zebra_evpn_mh_mac_holdtime_update(struct vty *vty, void zebra_evpn_mh_config_write(struct vty *vty); int zebra_evpn_mh_neigh_holdtime_update(struct vty *vty, uint32_t duration, bool set_default); +void zebra_evpn_es_local_br_port_update(struct zebra_if *zif); #endif /* _ZEBRA_EVPN_MH_H */ diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c index 417056ecb0..19d8bfd733 100644 --- a/zebra/zebra_l2.c +++ b/zebra/zebra_l2.c @@ -286,6 +286,8 @@ void zebra_l2if_update_bridge_slave(struct interface *ifp, /* In the case of VxLAN, invoke the handler for EVPN. */ if (zif->zif_type == ZEBRA_IF_VXLAN) zebra_vxlan_if_update(ifp, ZEBRA_VXLIF_MASTER_CHANGE); + if (zif->es_info.es) + zebra_evpn_es_local_br_port_update(zif); } else if (old_bridge_ifindex != IFINDEX_INTERNAL) { /* * In the case of VxLAN, invoke the handler for EVPN. @@ -294,6 +296,8 @@ void zebra_l2if_update_bridge_slave(struct interface *ifp, */ if (zif->zif_type == ZEBRA_IF_VXLAN) zebra_vxlan_if_update(ifp, ZEBRA_VXLIF_MASTER_CHANGE); + if (zif->es_info.es) + zebra_evpn_es_local_br_port_update(zif); zebra_l2_unmap_slave_from_bridge(&zif->brslave_info); } } -- 2.39.5