diff options
| author | Stephen Worley <sworley@nvidia.com> | 2021-10-26 17:55:54 -0400 | 
|---|---|---|
| committer | Stephen Worley <sworley@nvidia.com> | 2022-10-11 16:18:21 -0400 | 
| commit | 852d9f97570045dc4186940d424c856995999fbb (patch) | |
| tree | f00c5fd3f0777aaa1e5e8a0ccf55707fee671e23 /bgpd/bgp_evpn_private.h | |
| parent | 36bac85c7f7b059818a8bc60c08e383369453750 (diff) | |
bgpd,zebra,lib: bgp evpn vni macip into two tables
Re-work the bgp vni table to use separately keyed tables for type2
routes.
So, with type2 routes, we have the main table keyed off of the IP and a
new MAC table keyed off of MACs.
By separating out the two, we are able to run path selection separately
for the neigh and mac. Keeping the two separate is also more in-line
with what happens in zebra (they are managed comptletely seperate).
With this change type2 routes go into each table like so:
```
Remote MAC-IP -> IP Table & MAC Table
Remote MAC -> MAC Table
Local MAC-IP -> IP Table
Local MAC -> MAC Table
```
The difference for local is necessary because we should not ever allow
multiple paths for a local MAC.
Also cleaned up the commands for querying the vni tables:
```
show bgp vni all type ...
show bgp vni VNI type ...
```
Old commands will be deprecated in a separate commit.
Signed-off-by: Stephen Worley <sworley@nvidia.com>
Diffstat (limited to 'bgpd/bgp_evpn_private.h')
| -rw-r--r-- | bgpd/bgp_evpn_private.h | 92 | 
1 files changed, 73 insertions, 19 deletions
diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index 9b4405afe7..eb78a755db 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; @@ -531,10 +532,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; @@ -543,29 +544,49 @@ 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) +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)); -	global_p->prefix.macip_addr.mac = mac; + +	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_copy(struct prefix_evpn *vni_p, -			   const struct prefix_evpn *global_p) +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->mac; +	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 */ @@ -573,7 +594,25 @@ 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->mac = mac; +	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, @@ -676,13 +715,28 @@ bgp_evpn_global_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi,  			    struct prefix_rd *prd,  			    const struct bgp_path_info *local_pi);  extern struct bgp_dest * -bgp_evpn_vni_node_get(struct bgp_table *const table, -		      const struct prefix_evpn *evp, +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, +			    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 bgp_table *const table, -			 const struct prefix_evpn *evp, +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,  | 
