diff options
| -rw-r--r-- | bgpd/bgp_evpn.c | 39 | ||||
| -rw-r--r-- | bgpd/bgp_evpn_private.h | 19 | ||||
| -rw-r--r-- | bgpd/bgp_zebra.c | 12 | ||||
| -rw-r--r-- | lib/zclient.c | 4 | ||||
| -rw-r--r-- | lib/zebra.h | 2 | ||||
| -rw-r--r-- | zebra/zebra_rib.c | 4 | ||||
| -rw-r--r-- | zebra/zserv.c | 4 |
7 files changed, 55 insertions, 29 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 42bc686cdf..fe88c509cc 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1684,7 +1684,10 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, 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("installing evpn prefix %s as ip prefix %s in vrf %s", @@ -2282,13 +2285,14 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi, struct bgp *bgp_vrf; struct listnode *node, *nnode; - /* Only type-2 routes go into a VRF */ - if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE)) + /* 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)) return 0; - /* if not a mac+ip route skip this route */ - if (!(IS_EVPN_PREFIX_IPADDR_V4(evp) || - IS_EVPN_PREFIX_IPADDR_V6(evp))) + /* 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))) return 0; for (ALL_LIST_ELEMENTS(vrfs, node, nnode, bgp_vrf)) { @@ -2364,9 +2368,10 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, assert(attr); - /* Only type-2 and type-3 routes go into a L2 VNI. */ + /* Only type-2 and type-3 and type-5 are supported currently */ if (!(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE - || evp->prefix.route_type == BGP_EVPN_IMET_ROUTE)) + || evp->prefix.route_type == BGP_EVPN_IMET_ROUTE + || evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE)) return 0; /* If we don't have Route Target, nothing much to do. */ @@ -2377,8 +2382,8 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, if (!ecom || !ecom->size) return -1; - /* For each extended community RT, see which VNIs match and import - * the route into matching VNIs. + /* For each extended community RT, see which VNIs/VRFs match and import + * the route into matching VNIs/VRFs. */ for (i = 0; i < ecom->size; i++) { u_char *pnt; @@ -2397,22 +2402,24 @@ static int install_uninstall_evpn_route(struct bgp *bgp, afi_t afi, safi_t safi, if (sub_type != ECOMMUNITY_ROUTE_TARGET) continue; - /* Import route into matching l2-vnis */ + /* Import route into matching l2-vnis (type-2/type-3 routes go + * 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 (vrfs) */ + /* Import route into matching l3-vnis (type-2/type-5 routes go + * 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, vrf_irt->vrfs, import); - /* Also check for non-exact match. In this, we mask out the AS - * and - * only check on the local-admin sub-field. This is to - * facilitate using + /* Also check for non-exact match. In this, + * we mask out the AS and + * only check on the local-admin sub-field. + * This is to facilitate using * VNI as the RT for EBGP peering too. */ irt = NULL; diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index f308f5ed9a..12f997bebb 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -271,6 +271,25 @@ static inline void encode_mac_mobility_extcomm(int static_mac, u_int32_t seq, eval->val[7] = seq & 0xff; } +static inline void ip_prefix_from_type5_prefix(struct prefix_evpn *evp, + struct prefix *ip) +{ + memset(ip, 0, sizeof(struct prefix)); + if (IS_EVPN_PREFIX_IPADDR_V4(evp)) { + ip->family = AF_INET; + ip->prefixlen = evp->prefix.ip_prefix_length; + memcpy(&(ip->u.prefix4), + &(evp->prefix.ip.ip), + IPV4_MAX_BYTELEN); + } else if (IS_EVPN_PREFIX_IPADDR_V6(evp)) { + ip->family = AF_INET6; + ip->prefixlen = evp->prefix.ip_prefix_length; + memcpy(&(ip->u.prefix6), + &(evp->prefix.ip.ip), + IPV6_MAX_BYTELEN); + } +} + static inline void ip_prefix_from_type2_prefix(struct prefix_evpn *evp, struct prefix *ip) { diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 72c16b101b..9c6969a96a 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -1020,7 +1020,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, * Currently presence of rmac in attr denotes * this is an EVPN type-2 route */ if (!is_zero_mac(&(info->attr->rmac))) - SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE); + SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE); if (peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED || info->sub_type == BGP_ROUTE_AGGREGATE) { @@ -1082,7 +1082,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, /* EVPN type-2 routes are programmed as onlink on l3-vni SVI */ - if (CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) + if (CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) api_nh->type = NEXTHOP_TYPE_IPV4_IFINDEX; else api_nh->type = NEXTHOP_TYPE_IPV4; @@ -1140,7 +1140,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, } if (mpinfo->extra && bgp_is_valid_label(&mpinfo->extra->label) - && !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) { + && !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) { has_valid_label = 1; label = label_pton(&mpinfo->extra->label); @@ -1152,7 +1152,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, /* if this is a evpn route we don't have to include the label */ if (has_valid_label && - !(CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE))) + !(CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE))) SET_FLAG(api.message, ZAPI_MESSAGE_LABEL); if (info->sub_type != BGP_ROUTE_AGGREGATE) @@ -1195,7 +1195,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, label_buf[0] = '\0'; if (has_valid_label && - !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) + !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) sprintf(label_buf, "label %u", api_nh->labels[0]); zlog_debug(" nhop [%d]: %s %s", i + 1, nh_buf, @@ -1259,7 +1259,7 @@ void bgp_zebra_withdraw(struct prefix *p, struct bgp_info *info, safi_t safi) * Currently presence of rmac in attr denotes * this is an EVPN type-2 route */ if (!is_zero_mac(&(info->attr->rmac))) - SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE); + SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE); if (peer->sort == BGP_PEER_IBGP) { SET_FLAG(api.flags, ZEBRA_FLAG_INTERNAL); diff --git a/lib/zclient.c b/lib/zclient.c index 48694ee717..4177ce1a71 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -912,7 +912,7 @@ int zapi_route_encode(u_char cmd, struct stream *s, struct zapi_route *api) stream_putl(s, api->flags); stream_putc(s, api->message); stream_putc(s, api->safi); - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) + if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) stream_put(s, &(api->rmac), sizeof(struct ethaddr)); /* Put prefix information. */ @@ -1034,7 +1034,7 @@ int zapi_route_decode(struct stream *s, struct zapi_route *api) STREAM_GETL(s, api->flags); STREAM_GETC(s, api->message); STREAM_GETC(s, api->safi); - if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) + if (CHECK_FLAG(api->flags, ZEBRA_FLAG_EVPN_ROUTE)) stream_get(&(api->rmac), s, sizeof(struct ethaddr)); /* Prefix. */ diff --git a/lib/zebra.h b/lib/zebra.h index 73b5f7058e..1eb0c56252 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -409,7 +409,7 @@ extern const char *zserv_command_string(unsigned int command); #define ZEBRA_FLAG_STATIC 0x40 #define ZEBRA_FLAG_SCOPE_LINK 0x100 #define ZEBRA_FLAG_FIB_OVERRIDE 0x200 -#define ZEBRA_FLAG_EVPN_TYPE2_ROUTE 0x400 +#define ZEBRA_FLAG_EVPN_ROUTE 0x400 /* ZEBRA_FLAG_BLACKHOLE was 0x04 */ /* ZEBRA_FLAG_REJECT was 0x80 */ diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 804c65023c..3ed3438cae 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -261,7 +261,7 @@ struct nexthop *route_entry_nexthop_ipv4_ifindex_add(struct route_entry *re, There was a crash because ifp here was coming to be NULL */ if (ifp) if (connected_is_unnumbered(ifp) || - CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) { + CHECK_FLAG(re->flags, ZEBRA_FLAG_EVPN_ROUTE)) { SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK); } @@ -2475,7 +2475,7 @@ void rib_delete(afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, return; } - if (CHECK_FLAG(flags, ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) { + if (CHECK_FLAG(flags, ZEBRA_FLAG_EVPN_ROUTE)) { struct nexthop *tmp_nh; for (ALL_NEXTHOPS(re->nexthop, tmp_nh)) { diff --git a/zebra/zserv.c b/zebra/zserv.c index 7f3d7c7fcd..b70385f112 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -1168,7 +1168,7 @@ static int zread_route_add(struct zserv *client, u_short length, memset(&vtep_ip, 0, sizeof(struct ipaddr)); if (CHECK_FLAG(api.flags, - ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) { + ZEBRA_FLAG_EVPN_ROUTE)) { ifindex = get_l3vni_svi_ifindex(vrf_id); } else { @@ -1182,7 +1182,7 @@ static int zread_route_add(struct zserv *client, u_short length, /* if this an EVPN route entry, program the nh as neigh */ if (CHECK_FLAG(api.flags, - ZEBRA_FLAG_EVPN_TYPE2_ROUTE)) { + ZEBRA_FLAG_EVPN_ROUTE)) { SET_FLAG(nexthop->flags, NEXTHOP_FLAG_EVPN_RVTEP); vtep_ip.ipa_type = IPADDR_V4; |
