summaryrefslogtreecommitdiff
path: root/bgpd/bgp_evpn_private.h
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2022-11-17 16:46:58 +0200
committerGitHub <noreply@github.com>2022-11-17 16:46:58 +0200
commitf8d69be43fe6c19fd66d2c65c178e4692dc25aed (patch)
treeb5c40ab8a88878d1c21d0d374a70fd137d1b751a /bgpd/bgp_evpn_private.h
parent1e5e7934eabc39831f79c113bb1c0b8b9a74c499 (diff)
parentd950d2246db240816162bbade29f4fb6cea14988 (diff)
Merge pull request #12081 from sworleys/EMM-upstream
Rework of Various Handling in EVPN for Extended Mac Mobility
Diffstat (limited to 'bgpd/bgp_evpn_private.h')
-rw-r--r--bgpd/bgp_evpn_private.h121
1 files changed, 109 insertions, 12 deletions
diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h
index fdbffa95dd..3f18e4e9f1 100644
--- a/bgpd/bgp_evpn_private.h
+++ b/bgpd/bgp_evpn_private.h
@@ -112,9 +112,10 @@ struct bgpevpn {
*/
struct hash *remote_ip_hash;
- /* Route table for EVPN routes for
+ /* Route tables for EVPN routes for
* this VNI. */
- struct bgp_table *route_table;
+ struct bgp_table *ip_table;
+ struct bgp_table *mac_table;
/* RB tree of ES-EVIs */
struct bgp_es_evi_rb_head es_evi_rb_tree;
@@ -543,10 +544,10 @@ static inline void evpn_type1_prefix_global_copy(struct prefix_evpn *global_p,
/* EAD prefix in the global table doesn't include the VTEP-IP so
* we need to create a different copy for the VNI
*/
-static inline struct prefix_evpn *evpn_type1_prefix_vni_copy(
- struct prefix_evpn *vni_p,
- const struct prefix_evpn *global_p,
- struct in_addr originator_ip)
+static inline struct prefix_evpn *
+evpn_type1_prefix_vni_ip_copy(struct prefix_evpn *vni_p,
+ const struct prefix_evpn *global_p,
+ struct in_addr originator_ip)
{
memcpy(vni_p, global_p, sizeof(*vni_p));
vni_p->prefix.ead_addr.ip.ipa_type = IPADDR_V4;
@@ -555,6 +556,77 @@ static inline struct prefix_evpn *evpn_type1_prefix_vni_copy(
return vni_p;
}
+static inline void evpn_type2_prefix_global_copy(
+ struct prefix_evpn *global_p, const struct prefix_evpn *vni_p,
+ const struct ethaddr *mac, const struct ipaddr *ip)
+{
+ memcpy(global_p, vni_p, sizeof(*global_p));
+
+ if (mac)
+ global_p->prefix.macip_addr.mac = *mac;
+
+ if (ip)
+ global_p->prefix.macip_addr.ip = *ip;
+}
+
+static inline void
+evpn_type2_prefix_vni_ip_copy(struct prefix_evpn *vni_p,
+ const struct prefix_evpn *global_p)
+{
+ memcpy(vni_p, global_p, sizeof(*vni_p));
+ memset(&vni_p->prefix.macip_addr.mac, 0, sizeof(struct ethaddr));
+}
+
+static inline void
+evpn_type2_prefix_vni_mac_copy(struct prefix_evpn *vni_p,
+ const struct prefix_evpn *global_p)
+{
+ memcpy(vni_p, global_p, sizeof(*vni_p));
+ memset(&vni_p->prefix.macip_addr.ip, 0, sizeof(struct ipaddr));
+}
+
+/* Get MAC of path_info prefix */
+static inline struct ethaddr *
+evpn_type2_path_info_get_mac(const struct bgp_path_info *local_pi)
+{
+ assert(local_pi->extra);
+ return &local_pi->extra->vni_info.mac;
+}
+
+/* Get IP of path_info prefix */
+static inline struct ipaddr *
+evpn_type2_path_info_get_ip(const struct bgp_path_info *local_pi)
+{
+ assert(local_pi->extra);
+ return &local_pi->extra->vni_info.ip;
+}
+
+/* Set MAC of path_info prefix */
+static inline void evpn_type2_path_info_set_mac(struct bgp_path_info *local_pi,
+ const struct ethaddr mac)
+{
+ assert(local_pi->extra);
+ local_pi->extra->vni_info.mac = mac;
+}
+
+/* Set IP of path_info prefix */
+static inline void evpn_type2_path_info_set_ip(struct bgp_path_info *local_pi,
+ const struct ipaddr ip)
+{
+ assert(local_pi->extra);
+ local_pi->extra->vni_info.ip = ip;
+}
+
+/* Is the IP empty for the RT's dest? */
+static inline bool is_evpn_type2_dest_ipaddr_none(const struct bgp_dest *dest)
+{
+ const struct prefix_evpn *evp =
+ (const struct prefix_evpn *)bgp_dest_get_prefix(dest);
+
+ assert(evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE);
+ return is_evpn_prefix_ipaddr_none(evp);
+}
+
static inline int evpn_default_originate_set(struct bgp *bgp, afi_t afi,
safi_t safi)
{
@@ -651,14 +723,39 @@ extern void delete_evpn_route_entry(struct bgp *bgp, afi_t afi, safi_t safi,
int vni_list_cmp(void *p1, void *p2);
extern int evpn_route_select_install(struct bgp *bgp, struct bgpevpn *vpn,
struct bgp_dest *dest);
-extern struct bgp_dest *bgp_global_evpn_node_get(struct bgp_table *table,
- afi_t afi, safi_t safi,
- const struct prefix_evpn *evp,
- struct prefix_rd *prd);
extern struct bgp_dest *
-bgp_global_evpn_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi,
+bgp_evpn_global_node_get(struct bgp_table *table, afi_t afi, safi_t safi,
+ const struct prefix_evpn *evp, struct prefix_rd *prd,
+ const struct bgp_path_info *local_pi);
+extern struct bgp_dest *
+bgp_evpn_global_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi,
+ const struct prefix_evpn *evp,
+ struct prefix_rd *prd,
+ const struct bgp_path_info *local_pi);
+extern struct bgp_dest *
+bgp_evpn_vni_ip_node_get(struct bgp_table *const table,
+ const struct prefix_evpn *evp,
+ const struct bgp_path_info *parent_pi);
+extern struct bgp_dest *
+bgp_evpn_vni_ip_node_lookup(const struct bgp_table *const table,
const struct prefix_evpn *evp,
- struct prefix_rd *prd);
+ const struct bgp_path_info *parent_pi);
+extern struct bgp_dest *
+bgp_evpn_vni_mac_node_get(struct bgp_table *const table,
+ const struct prefix_evpn *evp,
+ const struct bgp_path_info *parent_pi);
+extern struct bgp_dest *
+bgp_evpn_vni_mac_node_lookup(const struct bgp_table *const table,
+ const struct prefix_evpn *evp,
+ const struct bgp_path_info *parent_pi);
+extern struct bgp_dest *
+bgp_evpn_vni_node_get(struct bgpevpn *vpn, const struct prefix_evpn *p,
+ const struct bgp_path_info *parent_pi);
+extern struct bgp_dest *
+bgp_evpn_vni_node_lookup(const struct bgpevpn *vpn, const struct prefix_evpn *p,
+ const struct bgp_path_info *parent_pi);
+
+extern void bgp_evpn_import_route_in_vrfs(struct bgp_path_info *pi, int import);
extern void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
struct bgpevpn *vpn,
struct bgp_node *rn,