Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic ipv6 support #112

Merged
merged 14 commits into from
Feb 20, 2025
8 changes: 8 additions & 0 deletions asr1k_neutron_l3/common/asr1k_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,11 @@ class DynamicNatPoolGivenIPsDontBelongToNetwork(nexception.BadRequest):
class DynamicNatPoolExternalNetExhausted(nexception.BadRequest):
message = ("Could not find %(ip_count)s consecutive IP addresses in subnet %(subnet_id)s - "
"make sure there is enough undivided IP space")


class OnlyOneExternalIPv6AddressAllowed(nexception.BadRequest):
message = ("Only one external IPv6 address allowed per router")


class InvalidExternalGatewayIPDefinition(nexception.BadRequest):
message = ("Invalid external gateway ip definition found: %(ext_ip)s")
4 changes: 4 additions & 0 deletions asr1k_neutron_l3/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
cfg.BoolOpt('enable_fwaas_cleaning', default=True, help="Run FWaaS cleaning sync to remove stale FWaaS ACLs, "
"Class Maps and Service Policies"),
cfg.IntOpt('fwaas_cleaning_interval', default=300, help="Interval for FWaaS cleaning"),
cfg.BoolOpt('advertise_bgp_ipv4_routes_via_redistribute', default=False,
help=('Advertise BGP routes (BGPVPN/DAPNets) on IPv4 via redistribute static/connected + route-map '
'instead of using network statements. This avoids the global config lock, that occurs on current '
'firmwares (at least 17.15) when the BGP tree is modified.')),
]

ASR1K_L2_OPTS = [
Expand Down
10 changes: 9 additions & 1 deletion asr1k_neutron_l3/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import socket
import struct

from netaddr import IPNetwork, IPAddress
from netaddr import AddrFormatError, IPNetwork, IPAddress
from oslo_log import log as logging


Expand Down Expand Up @@ -134,6 +134,14 @@ def ip_in_network(ip, net):
return IPAddress(ip) in IPNetwork(net)


def get_ip_version(ip):
try:
ip = IPNetwork(ip)
return ip.version
except AddrFormatError:
return None


def network_in_network(net, parent_net):
"""Check if a network is contained inside another network (also true for net == parent_net)"""
return IPNetwork(net) in IPNetwork(parent_net)
Expand Down
Loading