Skip to content

Commit

Permalink
Use route-map instead of network for DAPNets
Browse files Browse the repository at this point in the history
We now also advertise DAPNets via route-map.

WIP: Commit will most likely be squashed
  • Loading branch information
sebageek committed Aug 14, 2024
1 parent 06889e4 commit f6307e1
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions asr1k_neutron_l3/models/neutron/l3/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,40 +223,32 @@ def _route_has_connected_interface(self, l3_route):
return False

def _build_bgp_address_family(self):
routable_connected_cidrs = [
cidr for cidr in self.get_internal_cidrs()
if any(utils.network_in_network(cidr, rn) for rn in self.get_routable_networks())]

return bgp.AddressFamily(self.router_info.get('id'), asn=self.config.asr1k_l3.fabric_asn,
routable_interface=self.routable_interface,
rt_export=self.rt_export, connected_cidrs=routable_connected_cidrs,
rt_export=self.rt_export, connected_cidrs=[],
routable_networks=self.get_routable_networks(),
extra_routes=[],
redist_rm="BGPVPNREDIST-{}".format(utils.uuid_to_vrf_id(self.router_id)))

def _build_bgpvpn_extras(self):
# connected routes without DAPNets (DAPNets will be announced via network statement)
connected_cidrs = [cidr for cidr in self.get_internal_cidrs()
if not any(utils.network_in_network(cidr, rn)
for rn in self.get_routable_networks())]

# extra routes
extra_routes = []
if self.router_info["bgpvpn_advertise_extra_routes"]:
extra_routes = [x.cidr for x in self.routes.routes if x.cidr != "0.0.0.0/0"]

routable_internal = []
routable_extra = []
bgpvpn_cidrs = connected_cidrs

for cidr in extra_routes:
bgpvpn_cidrs = []
for cidr in self.get_internal_cidrs() + extra_routes:
if any(utils.network_in_network(cidr, rn) for rn in self.get_routable_networks()):
routable_extra.append(cidr)
if cidr in extra_routes:
routable_extra.append(cidr)
else:
routable_internal.append(cidr)
else:
bgpvpn_cidrs.append(cidr)

return [
prefix.RoutableInternalPrefixes(self.router_id, routable_internal), # FIXME: will be empty with current setup
prefix.RoutableInternalPrefixes(self.router_id, routable_internal),
prefix.RoutableExtraPrefixes(self.router_id, routable_extra),
prefix.BgpvpnPrefixes(self.router_id, bgpvpn_cidrs),

Expand Down

0 comments on commit f6307e1

Please sign in to comment.