attr->ecommunity = ecommunity_merge(attr->ecommunity, ecom);
/* Add the export RTs for L3VNI - currently only supported for IPV4 host
- * routes */
+ * routes
+ */
if (afi == AFI_IP) {
vrf_export_rtl = bgpevpn_get_vrf_export_rtl(vpn);
if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {
}
/* create a new route entry if one doesnt exist.
- Otherwise see if route attr has changed */
+ Otherwise see if route attr has changed
+ */
if (!local_ri) {
/* route has changed as this is the first entry */
attr.mp_nexthop_global_in = vpn->originator_ip;
attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
attr.sticky = CHECK_FLAG(flags, ZEBRA_MAC_TYPE_STICKY) ? 1 : 0;
+ attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL);
bgpevpn_get_rmac(vpn, &attr.rmac);
+ vni2label(vpn->vni, &(attr.label));
/* Set up RT and ENCAP extended community. */
build_evpn_route_extcomm(vpn, &attr,
memset(pp, 0, sizeof(struct prefix));
if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
ip_prefix_from_type2_prefix(evp, pp);
- else if(evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
+ else if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
ip_prefix_from_type5_prefix(evp, pp);
if (bgp_debug_zebra(NULL)) {
char buf1[PREFIX_STRLEN];
memset(pp, 0, sizeof(struct prefix));
- ip_prefix_from_type2_prefix(evp, pp);
+ if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
+ ip_prefix_from_type2_prefix(evp, pp);
+ else if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)
+ ip_prefix_from_type5_prefix(evp, pp);
if (bgp_debug_zebra(NULL)) {
zlog_debug("uninstalling evpn prefix %s as ip prefix %s in vrf %s",
struct prefix_evpn *evp = (struct prefix_evpn *)&rn->p;
/* if not mac-ip route skip this route */
- if (evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE)
+ if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE ||
+ evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE))
continue;
/* if not a mac+ip route skip this route */
for (ri = rn->info; ri; ri = ri->next) {
/* Consider "valid" remote routes applicable for
- * this VRF. */
+ * this VRF.
+ */
if (!(CHECK_FLAG(ri->flags, BGP_INFO_VALID)
&& ri->type == ZEBRA_ROUTE_BGP
&& ri->sub_type == BGP_ROUTE_NORMAL))
}
/* Install any existing remote routes applicable for this VRF into VRF RIB. This
- * is invoked upon l3vni-add or l3vni import rt change */
+ * is invoked upon l3vni-add or l3vni import rt change
+ */
static int install_routes_for_vrf(struct bgp *bgp_vrf)
{
install_uninstall_routes_for_vrf(bgp_vrf, 1);
continue;
/* Import route into matching l2-vnis (type-2/type-3 routes go
- * into l2vni table) */
+ * into l2vni table)
+ */
irt = lookup_import_rt(bgp, eval);
if (irt && irt->vnis)
install_uninstall_route_in_vnis(bgp, afi, safi, evp, ri,
irt->vnis, import);
/* Import route into matching l3-vnis (type-2/type-5 routes go
- * into l3vni/vrf table) */
+ * into l3vni/vrf table)
+ */
vrf_irt = lookup_vrf_import_rt(eval);
if (vrf_irt && vrf_irt->vrfs)
install_uninstall_route_in_vrfs(bgp, afi, safi, evp, ri,
p_evpn_p = &(p->u.prefix_evpn);
/* len denites the total len of IP and GW-IP in the route
- IP and GW-IP have to be both ipv4 or ipv6 */
+ IP and GW-IP have to be both ipv4 or ipv6
+ */
if (IS_IPADDR_V4(&p_evpn_p->ip))
len = 8; /* IP and GWIP are both ipv4 */
else
list_delete_node(bgp_vrf->vrf_export_rtl, node_to_del);
/* fall back to auto-generated RT if this was the last RT */
- if (list_isempty(bgp_vrf->vrf_export_rtl)) {
+ if (bgp_vrf->vrf_export_rtl && list_isempty(bgp_vrf->vrf_export_rtl)) {
UNSET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_EXPORT_RT_CFGD);
evpn_auto_rt_export_add_for_vrf(bgp_vrf);
}
if (withdraw) {
/* delete and withdraw all the type-5 routes
- stored in the global table for this vrf */
+ stored in the global table for this vrf
+ */
withdraw_router_id_vrf(bgp);
/* delete all the VNI routes (type-2/type-3) routes for all the
- * L2-VNIs */
+ * L2-VNIs
+ */
hash_iterate(bgp->vnihash,
(void (*)(struct hash_backet *,
void *))withdraw_router_id_vni,
} else {
/* advertise all routes in the vrf as type-5 routes with the new
- * RD */
+ * RD
+ */
update_router_id_vrf(bgp);
/* advertise all the VNI routes (type-2/type-3) routes with the
- * new RD*/
+ * new RD
+ */
hash_iterate(bgp->vnihash,
(void (*)(struct hash_backet *,
void *))update_router_id_vni,
as_t as = 0;
/* get the default instamce - required to get the AS number for VRF
- * auto-creation*/
+ * auto-creatio
+ */
bgp_def = bgp_get_default();
if (!bgp_def) {
zlog_err("Cannot process L3VNI %u ADD - default BGP instance not yet created",
}
/* unimport remote routes from VRF, if it is AUTO vrf bgp_delete will
- * take care of uninstalling the routes from zebra */
+ * take care of uninstalling the routes from zebra
+ */
if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_AUTO))
uninstall_routes_for_vrf(bgp_vrf);
bgp->vnihash = NULL;
if (bgp->vrf_import_rtl)
list_delete_and_null(&bgp->vrf_import_rtl);
- bgp->vrf_import_rtl = NULL;
if (bgp->vrf_export_rtl)
list_delete_and_null(&bgp->vrf_export_rtl);
- bgp->vrf_export_rtl = NULL;
if (bgp->l2vnis)
list_delete_and_null(&bgp->l2vnis);
- bgp->l2vnis = NULL;
bf_release_index(bm->rd_idspace, bgp->vrf_rd_id);
}