2016-09-05 11:07:25 +02:00
|
|
|
/* E-VPN header for packet handling
|
2017-05-13 10:25:29 +02:00
|
|
|
* Copyright (C) 2016 6WIND
|
|
|
|
*
|
|
|
|
* This file is part of FRRouting.
|
|
|
|
*
|
|
|
|
* FRRouting is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* FRRouting is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2016-09-05 11:07:25 +02:00
|
|
|
|
|
|
|
#ifndef _QUAGGA_BGP_EVPN_H
|
|
|
|
#define _QUAGGA_BGP_EVPN_H
|
|
|
|
|
2017-05-15 23:34:04 +02:00
|
|
|
#include "vxlan.h"
|
2017-11-02 11:38:01 +01:00
|
|
|
#include "bgpd.h"
|
2016-09-05 11:07:25 +02:00
|
|
|
|
2017-05-15 23:53:31 +02:00
|
|
|
#define EVPN_ROUTE_STRLEN 200 /* Must be >> MAC + IPv6 strings. */
|
2017-04-12 11:24:07 +02:00
|
|
|
#define EVPN_AUTORT_VXLAN 0x10000000
|
2017-05-15 23:53:31 +02:00
|
|
|
|
2019-03-22 13:37:06 +01:00
|
|
|
#define EVPN_ENABLED(bgp) (bgp)->advertise_all_vni
|
2017-11-02 11:38:01 +01:00
|
|
|
static inline int is_evpn_enabled(void)
|
|
|
|
{
|
|
|
|
struct bgp *bgp = NULL;
|
|
|
|
|
2019-03-06 19:09:25 +01:00
|
|
|
bgp = bgp_get_evpn();
|
2019-03-22 13:37:06 +01:00
|
|
|
return bgp ? EVPN_ENABLED(bgp) : 0;
|
2017-11-02 11:38:01 +01:00
|
|
|
}
|
|
|
|
|
2017-11-21 11:42:05 +01:00
|
|
|
static inline void vni2label(vni_t vni, mpls_label_t *label)
|
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t *tag = (uint8_t *)label;
|
2017-11-21 11:42:05 +01:00
|
|
|
|
|
|
|
tag[0] = (vni >> 16) & 0xFF;
|
|
|
|
tag[1] = (vni >> 8) & 0xFF;
|
|
|
|
tag[2] = vni & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline vni_t label2vni(mpls_label_t *label)
|
|
|
|
{
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t *tag = (uint8_t *)label;
|
2017-11-21 11:42:05 +01:00
|
|
|
vni_t vni;
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
vni = ((uint32_t)*tag++ << 16);
|
|
|
|
vni |= (uint32_t)*tag++ << 8;
|
|
|
|
vni |= (uint32_t)(*tag & 0xFF);
|
2017-11-21 11:42:05 +01:00
|
|
|
|
|
|
|
return vni;
|
|
|
|
}
|
|
|
|
|
2018-02-20 09:23:06 +01:00
|
|
|
static inline int advertise_type5_routes(struct bgp *bgp_vrf,
|
|
|
|
afi_t afi)
|
|
|
|
{
|
|
|
|
if (!bgp_vrf->l3vni)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (afi == AFI_IP &&
|
2018-02-20 09:46:22 +01:00
|
|
|
CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
|
|
|
BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST))
|
2018-02-20 09:23:06 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (afi == AFI_IP6 &&
|
2018-02-20 09:46:22 +01:00
|
|
|
CHECK_FLAG(bgp_vrf->af_flags[AFI_L2VPN][SAFI_EVPN],
|
|
|
|
BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST))
|
2018-02-20 09:23:06 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-03-30 02:24:00 +02:00
|
|
|
/* Flag if the route's parent is a EVPN route. */
|
2020-05-09 04:44:35 +02:00
|
|
|
static inline struct bgp_path_info *
|
|
|
|
get_route_parent_evpn(struct bgp_path_info *ri)
|
2018-03-30 02:24:00 +02:00
|
|
|
{
|
2018-10-02 22:41:30 +02:00
|
|
|
struct bgp_path_info *parent_ri;
|
2018-03-30 02:24:00 +02:00
|
|
|
|
|
|
|
/* If not imported (or doesn't have a parent), bail. */
|
|
|
|
if (ri->sub_type != BGP_ROUTE_IMPORTED ||
|
|
|
|
!ri->extra ||
|
|
|
|
!ri->extra->parent)
|
2020-05-09 04:44:35 +02:00
|
|
|
return NULL;
|
2018-03-30 02:24:00 +02:00
|
|
|
|
2019-03-01 08:17:16 +01:00
|
|
|
/* Determine parent recursively */
|
|
|
|
for (parent_ri = ri->extra->parent;
|
|
|
|
parent_ri->extra && parent_ri->extra->parent;
|
|
|
|
parent_ri = parent_ri->extra->parent)
|
|
|
|
;
|
|
|
|
|
2020-05-09 04:44:35 +02:00
|
|
|
return parent_ri;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Flag if the route's parent is a EVPN route. */
|
|
|
|
static inline int is_route_parent_evpn(struct bgp_path_info *ri)
|
|
|
|
{
|
|
|
|
struct bgp_path_info *parent_ri;
|
|
|
|
struct bgp_table *table;
|
|
|
|
struct bgp_dest *dest;
|
|
|
|
|
|
|
|
parent_ri = get_route_parent_evpn(ri);
|
|
|
|
if (!parent_ri)
|
|
|
|
return 0;
|
|
|
|
|
2019-03-01 08:17:16 +01:00
|
|
|
/* See if of family L2VPN/EVPN */
|
2020-03-27 00:11:58 +01:00
|
|
|
dest = parent_ri->net;
|
|
|
|
if (!dest)
|
2018-03-30 02:24:00 +02:00
|
|
|
return 0;
|
2020-03-27 00:11:58 +01:00
|
|
|
table = bgp_dest_table(dest);
|
2018-03-30 02:24:00 +02:00
|
|
|
if (table &&
|
|
|
|
table->afi == AFI_L2VPN &&
|
|
|
|
table->safi == SAFI_EVPN)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-28 12:11:01 +01:00
|
|
|
/* Flag if the route path's family is EVPN. */
|
|
|
|
static inline bool is_pi_family_evpn(struct bgp_path_info *pi)
|
|
|
|
{
|
|
|
|
return is_pi_family_matching(pi, AFI_L2VPN, SAFI_EVPN);
|
|
|
|
}
|
|
|
|
|
2019-02-28 17:01:38 +01:00
|
|
|
/* Flag if the route is injectable into EVPN. This would be either a
|
|
|
|
* non-imported route or a non-EVPN imported route.
|
|
|
|
*/
|
|
|
|
static inline bool is_route_injectable_into_evpn(struct bgp_path_info *pi)
|
|
|
|
{
|
|
|
|
struct bgp_path_info *parent_pi;
|
|
|
|
struct bgp_table *table;
|
2020-03-27 00:11:58 +01:00
|
|
|
struct bgp_dest *dest;
|
2019-02-28 17:01:38 +01:00
|
|
|
|
|
|
|
if (pi->sub_type != BGP_ROUTE_IMPORTED ||
|
|
|
|
!pi->extra ||
|
|
|
|
!pi->extra->parent)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
parent_pi = (struct bgp_path_info *)pi->extra->parent;
|
2020-03-27 00:11:58 +01:00
|
|
|
dest = parent_pi->net;
|
|
|
|
if (!dest)
|
2019-02-28 17:01:38 +01:00
|
|
|
return true;
|
2020-03-27 00:11:58 +01:00
|
|
|
table = bgp_dest_table(dest);
|
2019-02-28 17:01:38 +01:00
|
|
|
if (table &&
|
|
|
|
table->afi == AFI_L2VPN &&
|
|
|
|
table->safi == SAFI_EVPN)
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-09 11:37:09 +01:00
|
|
|
extern void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf,
|
2020-03-22 19:50:46 +01:00
|
|
|
const struct prefix *p,
|
2017-12-04 18:52:54 +01:00
|
|
|
struct attr *src_attr, afi_t afi,
|
2017-11-09 11:37:09 +01:00
|
|
|
safi_t safi);
|
2020-03-22 19:50:46 +01:00
|
|
|
extern void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf,
|
|
|
|
const struct prefix *p, afi_t afi,
|
|
|
|
safi_t safi);
|
2017-11-05 02:24:02 +01:00
|
|
|
extern void bgp_evpn_withdraw_type5_routes(struct bgp *bgp_vrf, afi_t afi,
|
|
|
|
safi_t safi);
|
|
|
|
extern void bgp_evpn_advertise_type5_routes(struct bgp *bgp_vrf, afi_t afi,
|
|
|
|
safi_t safi);
|
2017-12-27 20:47:10 +01:00
|
|
|
extern void bgp_evpn_vrf_delete(struct bgp *bgp_vrf);
|
2017-05-16 00:02:33 +02:00
|
|
|
extern void bgp_evpn_handle_router_id_update(struct bgp *bgp, int withdraw);
|
2018-03-27 21:13:34 +02:00
|
|
|
extern char *bgp_evpn_label2str(mpls_label_t *label, uint32_t num_labels,
|
2017-11-21 11:42:05 +01:00
|
|
|
char *buf, int len);
|
2020-03-22 19:50:46 +01:00
|
|
|
extern void bgp_evpn_route2json(const struct prefix_evpn *p, json_object *json);
|
2020-03-24 12:58:08 +01:00
|
|
|
extern void bgp_evpn_encode_prefix(struct stream *s, const struct prefix *p,
|
|
|
|
const struct prefix_rd *prd,
|
|
|
|
mpls_label_t *label, uint32_t num_labels,
|
|
|
|
struct attr *attr, int addpath_encode,
|
|
|
|
uint32_t addpath_tx_id);
|
2017-05-15 23:34:04 +02:00
|
|
|
extern int bgp_nlri_parse_evpn(struct peer *peer, struct attr *attr,
|
|
|
|
struct bgp_nlri *packet, int withdraw);
|
|
|
|
extern int bgp_evpn_import_route(struct bgp *bgp, afi_t afi, safi_t safi,
|
2020-03-22 02:56:36 +01:00
|
|
|
const struct prefix *p,
|
|
|
|
struct bgp_path_info *ri);
|
2017-05-15 23:34:04 +02:00
|
|
|
extern int bgp_evpn_unimport_route(struct bgp *bgp, afi_t afi, safi_t safi,
|
2020-03-22 02:56:36 +01:00
|
|
|
const struct prefix *p,
|
|
|
|
struct bgp_path_info *ri);
|
2017-08-17 08:19:58 +02:00
|
|
|
extern int bgp_filter_evpn_routes_upon_martian_nh_change(struct bgp *bgp);
|
2017-05-15 23:34:04 +02:00
|
|
|
extern int bgp_evpn_local_macip_del(struct bgp *bgp, vni_t vni,
|
2019-01-15 00:24:43 +01:00
|
|
|
struct ethaddr *mac, struct ipaddr *ip,
|
|
|
|
int state);
|
2017-05-15 23:34:04 +02:00
|
|
|
extern int bgp_evpn_local_macip_add(struct bgp *bgp, vni_t vni,
|
2017-05-15 23:42:57 +02:00
|
|
|
struct ethaddr *mac, struct ipaddr *ip,
|
bgpd: support for Ethernet Segments and Type-1/EAD routes
This is the base patch that brings in support for Type-1 routes.
It includes support for -
- Ethernet Segment (ES) management
- EAD route handling
- MAC-IP (Type-2) routes with a non-zero ESI i.e. Aliasing for
active-active multihoming
- Initial infra for consistency checking. Consistency checking
is a fundamental feature for active-active solutions like MLAG.
We will try to levarage the info in the EAD-ES/EAD-EVI routes to
detect inconsitencies in access config across VTEPs attached to
the same Ethernet Segment.
Functionality Overview -
========================
1. Ethernet segments are created in zebra and associated with
access VLANs. zebra sends that info as ES and ES-EVI objects to BGP.
2. BGP advertises EAD-ES and EAD-EVI routes for the locally attached
ethernet segments.
3. Similarly BGP processes EAD-ES and EAD-EVI routes from peers
and translates them into ES-VTEP objects which are then sent to zebra
as remote ESs.
4. Each ES in zebra is associated with a list of active VTEPs which
is then translated into a L2-NHG (nexthop group). This is the ES
"Alias" entry
5. MAC-IP routes with a non-zero ESI use the alias entry created in
(4.) to forward traffic i.e. a MAC-ECMP is done to these remote-ES
destinations.
EAD route management (route table and key) -
============================================
1. Local EAD-ES routes
a. route-table: per-ES route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
b. route-table: per-VNI route-table
Not added
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)
2. Remote EAD-ES routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)
3. Local EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)
4. Remote EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)
Please refer to bgp_evpn_mh.h for info on how the data-structures are
organized.
Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-03-27 22:43:50 +01:00
|
|
|
uint8_t flags, uint32_t seq, esi_t *esi);
|
2017-12-27 20:47:10 +01:00
|
|
|
extern int bgp_evpn_local_l3vni_add(vni_t vni, vrf_id_t vrf_id,
|
|
|
|
struct ethaddr *rmac,
|
2019-08-05 01:51:33 +02:00
|
|
|
struct ethaddr *vrr_rmac,
|
2019-02-27 12:52:34 +01:00
|
|
|
struct in_addr originator_ip, int filter,
|
2019-08-05 01:51:33 +02:00
|
|
|
ifindex_t svi_ifindex, bool is_anycast_mac);
|
2017-12-27 20:47:10 +01:00
|
|
|
extern int bgp_evpn_local_l3vni_del(vni_t vni, vrf_id_t vrf_id);
|
2017-05-15 23:34:04 +02:00
|
|
|
extern int bgp_evpn_local_vni_del(struct bgp *bgp, vni_t vni);
|
|
|
|
extern int bgp_evpn_local_vni_add(struct bgp *bgp, vni_t vni,
|
2017-10-08 05:26:16 +02:00
|
|
|
struct in_addr originator_ip,
|
2019-03-19 19:08:24 +01:00
|
|
|
vrf_id_t tenant_vrf_id,
|
|
|
|
struct in_addr mcast_grp);
|
2018-10-05 01:20:12 +02:00
|
|
|
extern void bgp_evpn_flood_control_change(struct bgp *bgp);
|
2017-05-15 23:30:19 +02:00
|
|
|
extern void bgp_evpn_cleanup_on_disable(struct bgp *bgp);
|
2017-05-15 23:27:51 +02:00
|
|
|
extern void bgp_evpn_cleanup(struct bgp *bgp);
|
|
|
|
extern void bgp_evpn_init(struct bgp *bgp);
|
2020-03-24 12:58:08 +01:00
|
|
|
extern int bgp_evpn_get_type5_prefixlen(const struct prefix *pfx);
|
2020-03-22 02:56:36 +01:00
|
|
|
extern bool bgp_evpn_is_prefix_nht_supported(const struct prefix *pfx);
|
2019-04-18 09:17:57 +02:00
|
|
|
extern void update_advertise_vrf_routes(struct bgp *bgp_vrf);
|
2017-05-15 23:34:04 +02:00
|
|
|
#endif /* _QUAGGA_BGP_EVPN_H */
|