Skip to content

Commit

Permalink
Merge pull request #1993 from vivek-cumulus/evpn-fixes
Browse files Browse the repository at this point in the history
Evpn fixes
  • Loading branch information
louberger authored Apr 4, 2018
2 parents 78f0e7d + 8849307 commit ce7b915
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
5 changes: 5 additions & 0 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4336,6 +4336,7 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id)
struct bgp *bgp_vrf = NULL; /* bgp vrf instance */
struct bgp *bgp_def = NULL; /* default bgp instance */
struct listnode *node = NULL;
struct listnode *next = NULL;
struct bgpevpn *vpn = NULL;

bgp_vrf = bgp_lookup_by_vrf_id(vrf_id);
Expand Down Expand Up @@ -4386,6 +4387,10 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni, vrf_id_t vrf_id)
}
}

/* If any L2VNIs point to this instance, unlink them. */
for (ALL_LIST_ELEMENTS(bgp_vrf->l2vnis, node, next, vpn))
bgpevpn_unlink_from_l3vni(vpn);

/* Delete the instance if it was autocreated */
if (CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_AUTO))
bgp_delete(bgp_vrf);
Expand Down
26 changes: 26 additions & 0 deletions bgpd/bgp_evpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,32 @@ static inline int advertise_type5_routes(struct bgp *bgp_vrf,
return 0;
}

/* Flag if the route's parent is a EVPN route. */
static inline int is_route_parent_evpn(struct bgp_info *ri)
{
struct bgp_info *parent_ri;
struct bgp_table *table;
struct bgp_node *rn;

/* If not imported (or doesn't have a parent), bail. */
if (ri->sub_type != BGP_ROUTE_IMPORTED ||
!ri->extra ||
!ri->extra->parent)
return 0;

/* See if the parent is of family L2VPN/EVPN */
parent_ri = (struct bgp_info *)ri->extra->parent;
rn = parent_ri->net;
if (!rn)
return 0;
table = bgp_node_table(rn);
if (table &&
table->afi == AFI_L2VPN &&
table->safi == SAFI_EVPN)
return 1;
return 0;
}

extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
struct prefix *p,
struct attr *src_attr, afi_t afi,
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ static int bgp_info_cmp(struct bgp *bgp, struct bgp_info *new,
}

if (!(exist->sub_type == BGP_ROUTE_NORMAL ||
new->sub_type == BGP_ROUTE_IMPORTED)) {
exist->sub_type == BGP_ROUTE_IMPORTED)) {
if (debug)
zlog_debug(
"%s: %s loses to %s due to preferred BGP_ROUTE type",
Expand Down
14 changes: 4 additions & 10 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,11 +1097,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p,
if (info->sub_type == BGP_ROUTE_AGGREGATE)
zapi_route_set_blackhole(&api, BLACKHOLE_NULL);

/* If it is an EVPN route mark as such.
* Currently presence of rmac in attr denotes
* this is an EVPN type-2 route
*/
if (info->sub_type == BGP_ROUTE_IMPORTED)
/* If the route's source is EVPN, flag as such. */
if (is_route_parent_evpn(info))
SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);

if (peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED
Expand Down Expand Up @@ -1403,11 +1400,8 @@ void bgp_zebra_withdraw(struct prefix *p, struct bgp_info *info,
api.safi = safi;
api.prefix = *p;

/* If it is an EVPN route mark as such.
* Currently presence of rmac in attr denotes
* this is an EVPN type-2 route
*/
if (info->sub_type == BGP_ROUTE_IMPORTED)
/* If the route's source is EVPN, flag as such. */
if (is_route_parent_evpn(info))
SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);

if (peer->sort == BGP_PEER_IBGP) {
Expand Down

0 comments on commit ce7b915

Please sign in to comment.