static void delete_withdraw_vrf_routes(struct bgp *bgp_vrf)
{
/* delete all ipv4 routes and withdraw from peers */
- bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
+ if (advertise_type5_routes(bgp_vrf, AFI_IP))
+ bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
/* delete all ipv6 routes and withdraw from peers */
- bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
+ if (advertise_type5_routes(bgp_vrf, AFI_IP6))
+ bgp_evpn_withdraw_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
}
/* update and advertise all ipv4 and ipv6 routes in thr vrf table as type-5
static void update_advertise_vrf_routes(struct bgp *bgp_vrf)
{
/* update all ipv4 routes */
- bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
+ if (advertise_type5_routes(bgp_vrf, AFI_IP))
+ bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP, SAFI_UNICAST);
/* update all ipv6 routes */
- bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
+ if (advertise_type5_routes(bgp_vrf, AFI_IP6))
+ bgp_evpn_advertise_type5_routes(bgp_vrf, AFI_IP6, SAFI_UNICAST);
}
/*
struct prefix_evpn evp;
char buf[PREFIX_STRLEN];
- /* NOTE: Check needed as this is called per-route also. */
- if (!advertise_type5_routes(bgp_vrf, afi))
- return;
-
build_type5_prefix_from_ip_prefix(&evp, p);
ret = delete_evpn_type5_route(bgp_vrf, &evp);
if (ret) {
struct bgp_table *table = NULL;
struct bgp_node *rn = NULL;
- /* Bail out early if we don't have to advertise type-5 routes. */
- if (!advertise_type5_routes(bgp_vrf, afi))
- return;
-
table = bgp_vrf->rib[afi][safi];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn))
bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p, afi, safi);
struct prefix_evpn evp;
char buf[PREFIX_STRLEN];
- /* NOTE: Check needed as this is called per-route also. */
- if (!advertise_type5_routes(bgp_vrf, afi))
- return;
-
/* only advertise subnet routes as type-5 */
if (is_host_route(p))
return;
struct bgp_node *rn = NULL;
struct bgp_info *ri;
- /* Bail out early if we don't have to advertise type-5 routes. */
- if (!advertise_type5_routes(bgp_vrf, afi))
- return;
-
table = bgp_vrf->rib[afi][safi];
for (rn = bgp_table_top(table); rn; rn = bgp_route_next(rn)) {
/* Need to identify the "selected" route entry to use its
p->prefix.ip.ipaddr_v4 = originator_ip;
}
-static inline int advertise_type5_routes(struct bgp *bgp_vrf,
- afi_t afi)
-{
- if (!bgp_vrf->l3vni)
- return 0;
-
- if (afi == AFI_IP &&
- CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV4_IN_EVPN))
- return 1;
-
- if (afi == AFI_IP6 &&
- CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_ADVERTISE_IPV6_IN_EVPN))
- return 1;
-
- return 0;
-}
-
extern void evpn_rt_delete_auto(struct bgp*, vni_t, struct list*);
extern void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,
struct ecommunity *ecomadd);
if (!bgp_vrf)
return CMD_WARNING;
- if (!(advertise_type5_routes(bgp_vrf, AFI_IP) ||
- advertise_type5_routes(bgp_vrf, AFI_IP6))) {
- vty_out(vty,
- "%%Please enable ip prefix advertisement under l2vpn evpn in %s",
- vrf_id_to_name(bgp_vrf->vrf_id));
- return CMD_WARNING;
- }
-
evpn_set_advertise_subnet(bgp, vpn);
return CMD_SUCCESS;
}
if (afi == AFI_IP) {
- /* if we are already advertising ipv4 prefix as type-5
+ /* if we are not advertising ipv4 prefix as type-5
* nothing to do
*/
if (CHECK_FLAG(bgp_vrf->vrf_flags,
}
} else {
- /* if we are already advertising ipv6 prefix as type-5
+ /* if we are not advertising ipv6 prefix as type-5
* nothing to do
*/
if (CHECK_FLAG(bgp_vrf->vrf_flags,
/* advertise/withdraw type-5 routes */
if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) {
- if (new_select)
+ if (advertise_type5_routes(bgp, afi) && new_select)
bgp_evpn_advertise_type5_route(
bgp, &rn->p, new_select->attr, afi, safi);
- else if (old_select)
+ else if (advertise_type5_routes(bgp, afi) && old_select)
bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi);
}