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 4142bf6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 2 additions & 0 deletions asr1k_neutron_l3/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
cfg.StrOpt('dapnet_extra_routes_rm', default='RM-DAP-EXTRA-ROUTES',
help="Route-Map to apply to all BGP network statements for extra routes that are contained in a DAPNet"),
# FIXME: move defaults away from here
cfg.ListOpt('dapn_routable_nets_communities', default=["65126"],
help="Communities to assign to DAPNets (via redistribute statement)"),
cfg.ListOpt('dapn_extra_routes_communities', default=["65126", "4268097541"],
help="Communities to assign to DAPNet extraroutes (via redistribute statement)"),
cfg.IntOpt('external_iface_arp_timeout', default=1800,
Expand Down
4 changes: 1 addition & 3 deletions asr1k_neutron_l3/models/neutron/l3/route_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,10 @@ def __init__(self, router_id):
self.name = "BGPVPNREDIST-{}".format(self.vrf)

sequences = [
# FIXME: remove once we decided we don't need it (as we do it via network statements)
route_map.MapSequence(seq_no=10,
operation='permit',
community_list=cfg.CONF.asr1k_l3.dapn_routable_nets_communities,
access_list=f"{prefix.RoutableInternalPrefixes.PREFIX_NAME}-{self.vrf}"),

# FIXME: set community
route_map.MapSequence(seq_no=20,
operation='permit',
community_list=cfg.CONF.asr1k_l3.dapn_extra_routes_communities,
Expand Down
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 4142bf6

Please sign in to comment.