summaryrefslogtreecommitdiff
path: root/bgpd/bgp_evpn.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_evpn.c')
-rw-r--r--bgpd/bgp_evpn.c318
1 files changed, 146 insertions, 172 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index 9a62c525bd..a5ce53da45 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -193,8 +193,7 @@ static struct vrf_irt_node *lookup_vrf_import_rt(struct ecommunity_val *rt)
/*
* Is specified VRF present on the RT's list of "importing" VRFs?
*/
-static int is_vrf_present_in_irt_vrfs(struct list *vrfs,
- struct bgp *bgp_vrf)
+static int is_vrf_present_in_irt_vrfs(struct list *vrfs, struct bgp *bgp_vrf)
{
struct listnode *node = NULL, *nnode = NULL;
struct bgp *tmp_bgp_vrf = NULL;
@@ -353,8 +352,7 @@ static inline void mask_ecom_global_admin(struct ecommunity_val *dst,
* Map one RT to specified VRF.
* bgp_vrf = BGP vrf instance
*/
-static void map_vrf_to_rt(struct bgp *bgp_vrf,
- struct ecommunity_val *eval)
+static void map_vrf_to_rt(struct bgp *bgp_vrf, struct ecommunity_val *eval)
{
struct vrf_irt_node *irt = NULL;
struct ecommunity_val eval_tmp;
@@ -365,8 +363,7 @@ static void map_vrf_to_rt(struct bgp *bgp_vrf,
* as the RT for EBGP peering too.
*/
memcpy(&eval_tmp, eval, ECOMMUNITY_SIZE);
- if (!CHECK_FLAG(bgp_vrf->vrf_flags,
- BGP_VRF_IMPORT_RT_CFGD))
+ if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_IMPORT_RT_CFGD))
mask_ecom_global_admin(&eval_tmp, eval);
irt = lookup_vrf_import_rt(&eval_tmp);
@@ -389,8 +386,7 @@ static void map_vrf_to_rt(struct bgp *bgp_vrf,
* VRFs for this RT, then the RT hash is deleted.
* bgp_vrf: BGP VRF specific instance
*/
-static void unmap_vrf_from_rt(struct bgp *bgp_vrf,
- struct vrf_irt_node *irt)
+static void unmap_vrf_from_rt(struct bgp *bgp_vrf, struct vrf_irt_node *irt)
{
/* Delete VRF from list for this RT. */
listnode_delete(irt->vrfs, bgp_vrf);
@@ -514,9 +510,9 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
s = zclient->obuf;
stream_reset(s);
- zclient_create_header(s, add ? ZEBRA_REMOTE_MACIP_ADD
- : ZEBRA_REMOTE_MACIP_DEL,
- bgp->vrf_id);
+ zclient_create_header(
+ s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL,
+ bgp->vrf_id);
stream_putl(s, vpn->vni);
stream_put(s, &p->prefix.mac.octet, ETH_ALEN); /* Mac Addr */
/* IP address length and IP address, if any. */
@@ -537,13 +533,13 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
stream_putw_at(s, 0, stream_get_endp(s));
if (bgp_debug_zebra(NULL))
- zlog_debug("Tx %s MACIP, VNI %u MAC %s IP %s (flags: 0x%x) remote VTEP %s",
- add ? "ADD" : "DEL", vpn->vni,
- prefix_mac2str(&p->prefix.mac, buf1, sizeof(buf1)),
- ipaddr2str(&p->prefix.ip, buf3, sizeof(buf3)),
- flags,
- inet_ntop(AF_INET, &remote_vtep_ip, buf2,
- sizeof(buf2)));
+ zlog_debug(
+ "Tx %s MACIP, VNI %u MAC %s IP %s (flags: 0x%x) remote VTEP %s",
+ add ? "ADD" : "DEL", vpn->vni,
+ prefix_mac2str(&p->prefix.mac, buf1, sizeof(buf1)),
+ ipaddr2str(&p->prefix.ip, buf3, sizeof(buf3)), flags,
+ inet_ntop(AF_INET, &remote_vtep_ip, buf2,
+ sizeof(buf2)));
return zclient_send_message(zclient);
}
@@ -567,9 +563,9 @@ static int bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
s = zclient->obuf;
stream_reset(s);
- zclient_create_header(s, add ? ZEBRA_REMOTE_VTEP_ADD
- : ZEBRA_REMOTE_VTEP_DEL,
- bgp->vrf_id);
+ zclient_create_header(
+ s, add ? ZEBRA_REMOTE_VTEP_ADD : ZEBRA_REMOTE_VTEP_DEL,
+ bgp->vrf_id);
stream_putl(s, vpn->vni);
if (IS_EVPN_PREFIX_IPADDR_V4(p))
stream_put_in_addr(s, &p->prefix.ip.ipaddr_v4);
@@ -619,8 +615,8 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
vrf_export_rtl = bgp_vrf->vrf_export_rtl;
if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {
for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode, ecom))
- attr->ecommunity = ecommunity_merge(attr->ecommunity,
- ecom);
+ attr->ecommunity =
+ ecommunity_merge(attr->ecommunity, ecom);
}
/* add the router mac extended community */
@@ -629,8 +625,8 @@ static void build_evpn_type5_route_extcomm(struct bgp *bgp_vrf,
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
ecom_rmac.size = 1;
ecom_rmac.val = (uint8_t *)eval_rmac.val;
- attr->ecommunity = ecommunity_merge(attr->ecommunity,
- &ecom_rmac);
+ attr->ecommunity =
+ ecommunity_merge(attr->ecommunity, &ecom_rmac);
}
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
@@ -685,9 +681,8 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
if (vrf_export_rtl && !list_isempty(vrf_export_rtl)) {
for (ALL_LIST_ELEMENTS(vrf_export_rtl, node, nnode,
ecom))
- attr->ecommunity =
- ecommunity_merge(attr->ecommunity,
- ecom);
+ attr->ecommunity = ecommunity_merge(
+ attr->ecommunity, ecom);
}
}
@@ -708,8 +703,8 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
encode_rmac_extcomm(&eval_rmac, &attr->rmac);
ecom_rmac.size = 1;
ecom_rmac.val = (uint8_t *)eval_rmac.val;
- attr->ecommunity = ecommunity_merge(attr->ecommunity,
- &ecom_rmac);
+ attr->ecommunity =
+ ecommunity_merge(attr->ecommunity, &ecom_rmac);
}
/* Add default gateway, if needed. */
@@ -718,8 +713,8 @@ static void build_evpn_route_extcomm(struct bgpevpn *vpn, struct attr *attr,
encode_default_gw_extcomm(&eval_default_gw);
ecom_default_gw.size = 1;
ecom_default_gw.val = (uint8_t *)eval_default_gw.val;
- attr->ecommunity = ecommunity_merge(attr->ecommunity,
- &ecom_default_gw);
+ attr->ecommunity =
+ ecommunity_merge(attr->ecommunity, &ecom_default_gw);
}
attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
@@ -856,7 +851,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
int ret = 0;
- u_char flags = 0;
+ u_char flags = 0;
/* Compute the best path. */
bgp_best_selection(bgp, rn, &bgp->maxpaths[afi][safi], &old_and_new,
@@ -879,10 +874,9 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
SET_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY);
if (old_select->attr->default_gw)
SET_FLAG(flags, ZEBRA_MACIP_TYPE_GW);
- ret = evpn_zebra_install(bgp, vpn,
- (struct prefix_evpn *)&rn->p,
- old_select->attr->nexthop,
- flags);
+ ret = evpn_zebra_install(
+ bgp, vpn, (struct prefix_evpn *)&rn->p,
+ old_select->attr->nexthop, flags);
}
UNSET_FLAG(old_select->flags, BGP_INFO_MULTIPATH_CHG);
bgp_zebra_clear_route_change_flags(rn);
@@ -914,8 +908,7 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
if (new_select->attr->default_gw)
SET_FLAG(flags, ZEBRA_MACIP_TYPE_GW);
ret = evpn_zebra_install(bgp, vpn, (struct prefix_evpn *)&rn->p,
- new_select->attr->nexthop,
- flags);
+ new_select->attr->nexthop, flags);
/* If an old best existed and it was a "local" route, the only
* reason
* it would be supplanted is due to MAC mobility procedures. So,
@@ -950,8 +943,8 @@ static int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
*/
static int evpn_route_is_def_gw(struct bgp *bgp, struct bgp_node *rn)
{
- struct bgp_info *tmp_ri = NULL;
- struct bgp_info *local_ri = NULL;
+ struct bgp_info *tmp_ri = NULL;
+ struct bgp_info *local_ri = NULL;
local_ri = NULL;
for (tmp_ri = rn->info; tmp_ri; tmp_ri = tmp_ri->next) {
@@ -1061,9 +1054,8 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_def,
}
/* update evpn type-5 route entry */
-static int update_evpn_type5_route(struct bgp *bgp_vrf,
- struct prefix_evpn *evp,
- struct attr* src_attr)
+static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
+ struct attr *src_attr)
{
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
@@ -1096,14 +1088,12 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf,
/* get the route node in global table */
rn = bgp_afi_node_get(bgp_def->rib[afi][safi], afi, safi,
- (struct prefix *)evp,
- &bgp_vrf->vrf_prd);
+ (struct prefix *)evp, &bgp_vrf->vrf_prd);
assert(rn);
/* create or update the route entry within the route node */
- update_evpn_type5_route_entry(bgp_def, bgp_vrf,
- afi, safi,
- rn, &attr, &route_changed);
+ update_evpn_type5_route_entry(bgp_def, bgp_vrf, afi, safi, rn, &attr,
+ &route_changed);
/* schedule for processing and unlock node */
if (route_changed) {
@@ -1208,8 +1198,8 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
* Only attach second label if we are advertising two labels for
* type-2 routes.
*/
- if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE &&
- CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) {
+ if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
+ && CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) {
vni_t l3vni;
l3vni = bgpevpn_get_l3vni(vpn);
@@ -1233,8 +1223,9 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
* be advertised with right labels.
*/
vni2label(vpn->vni, &label[0]);
- if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE &&
- CHECK_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS)) {
+ if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
+ && CHECK_FLAG(vpn->flags,
+ VNI_FLAG_USE_TWO_LABELS)) {
vni_t l3vni;
l3vni = bgpevpn_get_l3vni(vpn);
@@ -1357,9 +1348,8 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
/* Delete EVPN type5 route entry from global table */
static void delete_evpn_type5_route_entry(struct bgp *bgp_def,
- struct bgp *bgp_vrf,
- afi_t afi, safi_t safi,
- struct bgp_node *rn,
+ struct bgp *bgp_vrf, afi_t afi,
+ safi_t safi, struct bgp_node *rn,
struct bgp_info **ri)
{
struct bgp_info *tmp_ri = NULL;
@@ -1381,8 +1371,7 @@ static void delete_evpn_type5_route_entry(struct bgp *bgp_def,
}
/* Delete EVPN type5 route */
-static int delete_evpn_type5_route(struct bgp *bgp_vrf,
- struct prefix_evpn *evp)
+static int delete_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp)
{
afi_t afi = AFI_L2VPN;
safi_t safi = SAFI_EVPN;
@@ -1562,12 +1551,12 @@ static int update_all_type2_routes(struct bgp *bgp, struct bgpevpn *vpn)
else {
if (evpn_route_is_sticky(bgp, rn))
update_evpn_route_entry(bgp, vpn, afi, safi, rn,
- &attr_sticky, 0, 1,
- &ri, 0);
+ &attr_sticky, 0, 1, &ri,
+ 0);
else if (evpn_route_is_def_gw(bgp, rn))
update_evpn_route_entry(bgp, vpn, afi, safi, rn,
- &attr_def_gw, 0, 1,
- &ri, 0);
+ &attr_def_gw, 0, 1, &ri,
+ 0);
else
update_evpn_route_entry(bgp, vpn, afi, safi, rn,
&attr, 0, 1, &ri, 0);
@@ -1814,10 +1803,11 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
ip_prefix_from_type5_prefix(evp, pp);
if (bgp_debug_zebra(NULL)) {
- zlog_debug("installing evpn prefix %s as ip prefix %s in vrf %s",
- prefix2str(evp, buf, sizeof(buf)),
- prefix2str(pp, buf1, sizeof(buf)),
- vrf_id_to_name(bgp_vrf->vrf_id));
+ zlog_debug(
+ "installing evpn prefix %s as ip prefix %s in vrf %s",
+ prefix2str(evp, buf, sizeof(buf)),
+ prefix2str(pp, buf1, sizeof(buf)),
+ vrf_id_to_name(bgp_vrf->vrf_id));
}
/* Create (or fetch) route within the VRF. */
@@ -1991,10 +1981,11 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
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",
- prefix2str(evp, buf, sizeof(buf)),
- prefix2str(pp, buf1, sizeof(buf)),
- vrf_id_to_name(bgp_vrf->vrf_id));
+ zlog_debug(
+ "uninstalling evpn prefix %s as ip prefix %s in vrf %s",
+ prefix2str(evp, buf, sizeof(buf)),
+ prefix2str(pp, buf1, sizeof(buf)),
+ vrf_id_to_name(bgp_vrf->vrf_id));
}
/* Locate route within the VRF. */
@@ -2076,8 +2067,7 @@ static int uninstall_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn,
* Given a route entry and a VRF, see if this route entry should be
* imported into the VRF i.e., RTs match.
*/
-static int is_route_matching_for_vrf(struct bgp *bgp_vrf,
- struct bgp_info *ri)
+static int is_route_matching_for_vrf(struct bgp *bgp_vrf, struct bgp_info *ri)
{
struct attr *attr = ri->attr;
struct ecommunity *ecom;
@@ -2210,8 +2200,7 @@ static int is_route_matching_for_vni(struct bgp *bgp, struct bgpevpn *vpn,
* Install or uninstall mac-ip routes are appropriate for this
* particular VRF.
*/
-static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,
- int install)
+static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
{
afi_t afi;
safi_t safi;
@@ -2242,13 +2231,14 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,
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 ||
- evp->prefix.route_type == BGP_EVPN_IP_PREFIX_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 */
- if (!(IS_EVPN_PREFIX_IPADDR_V4(evp) ||
- IS_EVPN_PREFIX_IPADDR_V6(evp)))
+ if (!(IS_EVPN_PREFIX_IPADDR_V4(evp)
+ || IS_EVPN_PREFIX_IPADDR_V6(evp)))
continue;
for (ri = rn->info; ri; ri = ri->next) {
@@ -2262,12 +2252,10 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,
if (is_route_matching_for_vrf(bgp_vrf, ri)) {
if (install)
- ret =
- install_evpn_route_entry_in_vrf(
+ ret = install_evpn_route_entry_in_vrf(
bgp_vrf, evp, ri);
else
- ret =
- uninstall_evpn_route_entry_in_vrf(
+ ret = uninstall_evpn_route_entry_in_vrf(
bgp_vrf, evp, ri);
if (ret) {
@@ -2277,7 +2265,8 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf,
: "uninstall",
prefix2str(evp, buf,
sizeof(buf)),
- vrf_id_to_name(bgp_vrf->vrf_id));
+ vrf_id_to_name(
+ bgp_vrf->vrf_id));
return ret;
}
}
@@ -2433,24 +2422,24 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi,
struct listnode *node, *nnode;
/* Only type-2/type-5 routes go into a VRF */
- if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE ||
- evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE))
+ if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE
+ || evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE))
return 0;
/* if it is type-2 route and not a mac+ip route skip this route */
- if ((evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) &&
- !(IS_EVPN_PREFIX_IPADDR_V4(evp) || IS_EVPN_PREFIX_IPADDR_V6(evp)))
+ if ((evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)
+ && !(IS_EVPN_PREFIX_IPADDR_V4(evp)
+ || IS_EVPN_PREFIX_IPADDR_V6(evp)))
return 0;
for (ALL_LIST_ELEMENTS(vrfs, node, nnode, bgp_vrf)) {
int ret;
if (install)
- ret = install_evpn_route_entry_in_vrf(bgp_vrf,
- evp, ri);
+ ret = install_evpn_route_entry_in_vrf(bgp_vrf, evp, ri);
else
- ret = uninstall_evpn_route_entry_in_vrf(bgp_vrf,
- evp, ri);
+ ret = uninstall_evpn_route_entry_in_vrf(bgp_vrf, evp,
+ ri);
if (ret) {
zlog_err("%u: Failed to %s prefix %s in VRF %s",
@@ -2537,7 +2526,7 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,
u_char type, sub_type;
struct ecommunity_val *eval;
struct ecommunity_val eval_tmp;
- struct irt_node *irt; /* import rt for l2vni */
+ struct irt_node *irt; /* import rt for l2vni */
struct vrf_irt_node *vrf_irt; /* import rt for l3vni */
/* Only deal with RTs */
@@ -2585,9 +2574,8 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi,
install_uninstall_route_in_vnis(bgp, afi, safi, evp, ri,
irt->vnis, import);
if (vrf_irt && vrf_irt->vrfs)
- install_uninstall_route_in_vrfs(bgp, afi, safi, evp,
- ri, vrf_irt->vrfs,
- import);
+ install_uninstall_route_in_vrfs(bgp, afi, safi, evp, ri,
+ vrf_irt->vrfs, import);
}
return 0;
@@ -2905,7 +2893,8 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,
memcpy(&label[1], pfx, BGP_LABEL_BYTES);
/*
* If in future, we are required to access additional fields,
- * we MUST increment pfx by BGP_LABEL_BYTES in before reading the next field
+ * we MUST increment pfx by BGP_LABEL_BYTES in before reading
+ * the next field
*/
}
@@ -3065,7 +3054,8 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
/*
* If in future, we are required to access additional fields,
- * we MUST increment pfx by BGP_LABEL_BYTES in before reading the next field
+ * we MUST increment pfx by BGP_LABEL_BYTES in before reading the next
+ * field
*/
/* Process the route. */
@@ -3082,9 +3072,8 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
}
static void evpn_mpattr_encode_type5(struct stream *s, struct prefix *p,
- struct prefix_rd *prd,
- mpls_label_t *label, u_int32_t num_labels,
- struct attr *attr)
+ struct prefix_rd *prd, mpls_label_t *label,
+ u_int32_t num_labels, struct attr *attr)
{
int len;
char temp[16];
@@ -3242,16 +3231,14 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, struct prefix *p,
ret = delete_evpn_type5_route(bgp_vrf, &evp);
if (ret) {
zlog_err(
- "%u failed to delete type-5 route for prefix %s in vrf %s",
- bgp_vrf->vrf_id,
- prefix2str(p, buf, sizeof(buf)),
- vrf_id_to_name(bgp_vrf->vrf_id));
+ "%u failed to delete type-5 route for prefix %s in vrf %s",
+ bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)),
+ vrf_id_to_name(bgp_vrf->vrf_id));
}
}
/* withdraw all type-5 routes for an address family */
-void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
- afi_t afi, safi_t safi)
+void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi, safi_t safi)
{
struct bgp_table *table = NULL;
struct bgp_node *rn = NULL;
@@ -3266,8 +3253,8 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
/* Only care about "selected" routes - non-imported. */
/* TODO: Support for AddPath for EVPN. */
for (ri = rn->info; ri; ri = ri->next) {
- if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) &&
- (!ri->extra || !ri->extra->parent)) {
+ if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED)
+ && (!ri->extra || !ri->extra->parent)) {
bgp_evpn_withdraw_type5_route(bgp_vrf, &rn->p,
afi, safi);
break;
@@ -3283,8 +3270,8 @@ void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf,
* are advertising local subnets), the src_attr will be NULL.
*/
void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p,
- struct attr *src_attr,
- afi_t afi, safi_t safi)
+ struct attr *src_attr, afi_t afi,
+ safi_t safi)
{
int ret = 0;
struct prefix_evpn evp;
@@ -3297,18 +3284,16 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, struct prefix *p,
build_type5_prefix_from_ip_prefix(&evp, p);
ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr);
if (ret)
- zlog_err(
- "%u: Failed to create type-5 route for prefix %s",
- bgp_vrf->vrf_id,
- prefix2str(p, buf, sizeof(buf)));
+ zlog_err("%u: Failed to create type-5 route for prefix %s",
+ bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)));
}
/* Inject all prefixes of a particular address-family (currently, IPv4 or
* IPv6 unicast) into EVPN as type-5 routes. This is invoked when the
* advertisement is enabled.
*/
-void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,
- afi_t afi, safi_t safi)
+void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
+ safi_t safi)
{
struct bgp_table *table = NULL;
struct bgp_node *rn = NULL;
@@ -3325,31 +3310,29 @@ void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf,
* TODO: Support for AddPath for EVPN.
*/
for (ri = rn->info; ri; ri = ri->next) {
- if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED) &&
- (!ri->extra || !ri->extra->parent)) {
+ if (CHECK_FLAG(ri->flags, BGP_INFO_SELECTED)
+ && (!ri->extra || !ri->extra->parent)) {
/* apply the route-map */
if (bgp_vrf->adv_cmd_rmap[afi][safi].map) {
int ret = 0;
- ret =
- route_map_apply(
- bgp_vrf->adv_cmd_rmap[afi][safi].map,
- &rn->p, RMAP_BGP, ri);
+ ret = route_map_apply(
+ bgp_vrf->adv_cmd_rmap[afi][safi]
+ .map,
+ &rn->p, RMAP_BGP, ri);
if (ret == RMAP_DENYMATCH)
continue;
}
- bgp_evpn_advertise_type5_route(bgp_vrf, &rn->p,
- ri->attr,
- afi, safi);
+ bgp_evpn_advertise_type5_route(
+ bgp_vrf, &rn->p, ri->attr, afi, safi);
break;
}
}
}
}
-void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni,
- struct list *rtl)
+void evpn_rt_delete_auto(struct bgp *bgp, vni_t vni, struct list *rtl)
{
struct listnode *node, *nnode, *node_to_del;
struct ecommunity *ecom, *ecom_auto;
@@ -3445,7 +3428,6 @@ void bgp_evpn_configure_export_rt_for_vrf(struct bgp *bgp_vrf,
SET_FLAG(bgp_vrf->vrf_flags, BGP_VRF_EXPORT_RT_CFGD);
bgp_evpn_handle_export_rt_change_for_vrf(bgp_vrf);
-
}
void bgp_evpn_unconfigure_export_rt_for_vrf(struct bgp *bgp_vrf,
@@ -3523,8 +3505,7 @@ int bgp_evpn_handle_export_rt_change(struct bgp *bgp, struct bgpevpn *vpn)
return update_routes_for_vni(bgp, vpn);
}
-void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf,
- int withdraw)
+void bgp_evpn_handle_vrf_rd_change(struct bgp *bgp_vrf, int withdraw)
{
if (withdraw)
delete_withdraw_vrf_routes(bgp_vrf);
@@ -3568,14 +3549,14 @@ int bgp_evpn_uninstall_routes(struct bgp *bgp, struct bgpevpn *vpn)
/*
* TODO: Hardcoded for a maximum of 2 VNIs right now
*/
-char *bgp_evpn_label2str(mpls_label_t *label, u_int32_t num_labels,
- char *buf, int len)
+char *bgp_evpn_label2str(mpls_label_t *label, u_int32_t num_labels, char *buf,
+ int len)
{
vni_t vni1, vni2;
vni1 = label2vni(label);
if (num_labels == 2) {
- vni2 = label2vni(label+1);
+ vni2 = label2vni(label + 1);
snprintf(buf, len, "%u/%u", vni1, vni2);
} else
snprintf(buf, len, "%u", vni1);
@@ -3683,11 +3664,10 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len)
}
} else if (p->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) {
snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]",
- p->prefix.route_type,
- p->prefix.ip_prefix_length,
- IS_EVPN_PREFIX_IPADDR_V4(p) ?
- inet_ntoa(p->prefix.ip.ipaddr_v4) :
- inet6_ntoa(p->prefix.ip.ipaddr_v6));
+ p->prefix.route_type, p->prefix.ip_prefix_length,
+ IS_EVPN_PREFIX_IPADDR_V4(p)
+ ? inet_ntoa(p->prefix.ip.ipaddr_v4)
+ : inet6_ntoa(p->prefix.ip.ipaddr_v6));
} else {
/* For EVPN route types not supported yet. */
snprintf(buf, len, "(unsupported route type %d)",
@@ -3701,10 +3681,9 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len)
* Encode EVPN prefix in Update (MP_REACH)
*/
void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p,
- struct prefix_rd *prd,
- mpls_label_t *label, u_int32_t num_labels,
- struct attr *attr, int addpath_encode,
- u_int32_t addpath_tx_id)
+ struct prefix_rd *prd, mpls_label_t *label,
+ u_int32_t num_labels, struct attr *attr,
+ int addpath_encode, u_int32_t addpath_tx_id)
{
struct prefix_evpn *evp = (struct prefix_evpn *)p;
int len, ipa_len = 0;
@@ -3726,19 +3705,19 @@ void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p,
if (ipa_len && num_labels > 1) /* There are 2 VNIs */
len += 3;
stream_putc(s, len);
- stream_put(s, prd->val, 8); /* RD */
- stream_put(s, 0, 10); /* ESI */
- stream_putl(s, 0); /* Ethernet Tag ID */
+ stream_put(s, prd->val, 8); /* RD */
+ stream_put(s, 0, 10); /* ESI */
+ stream_putl(s, 0); /* Ethernet Tag ID */
stream_putc(s, 8 * ETH_ALEN); /* Mac Addr Len - bits */
stream_put(s, evp->prefix.mac.octet, 6); /* Mac Addr */
stream_putc(s, 8 * ipa_len); /* IP address Length */
- if (ipa_len) /* IP */
+ if (ipa_len) /* IP */
stream_put(s, &evp->prefix.ip.ip.addr, ipa_len);
/* 1st label is the L2 VNI */
stream_put(s, label, BGP_LABEL_BYTES);
/* Include 2nd label (L3 VNI) if advertising MAC+IP */
if (ipa_len && num_labels > 1)
- stream_put(s, label+1, BGP_LABEL_BYTES);
+ stream_put(s, label + 1, BGP_LABEL_BYTES);
break;
case BGP_EVPN_IMET_ROUTE:
@@ -3922,7 +3901,6 @@ void bgp_evpn_unmap_vrf_from_its_rts(struct bgp *bgp_vrf)
}
-
/*
* Map the RTs (configured or automatically derived) of a VNI to the VNI.
* The mapping will be used during route processing.
@@ -4250,11 +4228,11 @@ int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni, struct ethaddr *mac,
zlog_err(
"%u:Failed to create Type-2 route, VNI %u %s MAC %s IP %s (flags: 0x%x)",
bgp->vrf_id, vpn->vni,
- CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY) ? "sticky gateway"
- : "",
+ CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY)
+ ? "sticky gateway"
+ : "",
prefix_mac2str(mac, buf, sizeof(buf)),
- ipaddr2str(ip, buf2, sizeof(buf2)),
- flags);
+ ipaddr2str(ip, buf2, sizeof(buf2)), flags);
return -1;
}
@@ -4275,11 +4253,8 @@ static void link_l2vni_hash_to_l3vni(struct hash_backet *backet,
bgpevpn_link_to_l3vni(vpn);
}
-int bgp_evpn_local_l3vni_add(vni_t l3vni,
- vrf_id_t vrf_id,
- struct ethaddr *rmac,
- struct in_addr originator_ip,
- int filter)
+int bgp_evpn_local_l3vni_add(vni_t l3vni, vrf_id_t vrf_id, struct ethaddr *rmac,
+ struct in_addr originator_ip, int filter)
{
struct bgp *bgp_vrf = NULL; /* bgp VRF instance */
struct bgp *bgp_def = NULL; /* default bgp instance */
@@ -4292,8 +4267,9 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,
*/
bgp_def = bgp_get_default();
if (!bgp_def) {
- zlog_err("Cannot process L3VNI %u ADD - default BGP instance not yet created",
- l3vni);
+ zlog_err(
+ "Cannot process L3VNI %u ADD - default BGP instance not yet created",
+ l3vni);
return -1;
}
as = bgp_def->as;
@@ -4344,8 +4320,8 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,
/* link all corresponding l2vnis */
hash_iterate(bgp_def->vnihash,
- (void (*)(struct hash_backet *, void *))
- link_l2vni_hash_to_l3vni,
+ (void (*)(struct hash_backet *,
+ void *))link_l2vni_hash_to_l3vni,
bgp_vrf);
/* Only update all corresponding type-2 routes if we are advertising two
@@ -4365,8 +4341,7 @@ int bgp_evpn_local_l3vni_add(vni_t l3vni,
return 0;
}
-int bgp_evpn_local_l3vni_del(vni_t l3vni,
- vrf_id_t vrf_id)
+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 */
@@ -4375,15 +4350,17 @@ int bgp_evpn_local_l3vni_del(vni_t l3vni,
bgp_vrf = bgp_lookup_by_vrf_id(vrf_id);
if (!bgp_vrf) {
- zlog_err("Cannot process L3VNI %u Del - Could not find BGP instance",
- l3vni);
+ zlog_err(
+ "Cannot process L3VNI %u Del - Could not find BGP instance",
+ l3vni);
return -1;
}
bgp_def = bgp_get_default();
if (!bgp_def) {
- zlog_err("Cannot process L3VNI %u Del - Could not find default BGP instance",
- l3vni);
+ zlog_err(
+ "Cannot process L3VNI %u Del - Could not find default BGP instance",
+ l3vni);
return -1;
}
@@ -4469,8 +4446,7 @@ int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni)
* about are for the local-tunnel-ip and the (tenant) VRF.
*/
int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni,
- struct in_addr originator_ip,
- vrf_id_t tenant_vrf_id)
+ struct in_addr originator_ip, vrf_id_t tenant_vrf_id)
{
struct bgpevpn *vpn;
struct prefix_evpn p;
@@ -4620,10 +4596,8 @@ void bgp_evpn_init(struct bgp *bgp)
bgp->vrf_export_rtl->cmp =
(int (*)(void *, void *))evpn_route_target_cmp;
bgp->l2vnis = list_new();
- bgp->l2vnis->cmp =
- (int (*)(void *, void *))vni_hash_cmp;
+ bgp->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp;
bf_assign_index(bm->rd_idspace, bgp->vrf_rd_id);
-
}
void bgp_evpn_vrf_delete(struct bgp *bgp_vrf)