Commit 4f7a7551 by Czémán Arnold

Merge branch 'issue_9' into 'master'

Enable IPv6 Neighbor Advertisement from linklocal source address

See merge request !11
parents a86690c5 fc27dbd9
...@@ -22,6 +22,7 @@ AMQP_URI = getenv('AMQP_URI') ...@@ -22,6 +22,7 @@ AMQP_URI = getenv('AMQP_URI')
def to_bool(value): def to_bool(value):
return value.lower() in ("true", "yes", "y", "t") return value.lower() in ("true", "yes", "y", "t")
lib_connection = None lib_connection = None
native_ovs = False native_ovs = False
......
...@@ -63,6 +63,8 @@ def build_flow_rule( ...@@ -63,6 +63,8 @@ def build_flow_rule(
protocol=None, protocol=None,
nw_src=None, nw_src=None,
ipv6_src=None, ipv6_src=None,
icmp_type=None,
nd_target=None,
tp_dst=None, tp_dst=None,
priority=None, priority=None,
actions=None): actions=None):
...@@ -74,6 +76,8 @@ def build_flow_rule( ...@@ -74,6 +76,8 @@ def build_flow_rule(
protocol - Protocol for the rule like ip,ipv6,arp,udp,tcp protocol - Protocol for the rule like ip,ipv6,arp,udp,tcp
nw_src - Source network IP(v4) nw_src - Source network IP(v4)
ipv6_src - Source network IP(v6) ipv6_src - Source network IP(v6)
icmp_type - ICMP/ICMPv6 type
nd_target - IPv6 Neighbor Discovery target IP(v6)
tp_dst - Destination port tp_dst - Destination port
priority - Rule priority priority - Rule priority
actions - Action for the matching rule actions - Action for the matching rule
...@@ -89,6 +93,8 @@ def build_flow_rule( ...@@ -89,6 +93,8 @@ def build_flow_rule(
('%s', protocol), ('%s', protocol),
('nw_src=%s', nw_src), ('nw_src=%s', nw_src),
('ipv6_src=%s', ipv6_src), ('ipv6_src=%s', ipv6_src),
('icmp_type=%s', icmp_type),
('nd_target=%s', nd_target),
('tp_dst=%s', tp_dst), ('tp_dst=%s', tp_dst),
('priority=%s', priority), ('priority=%s', priority),
('actions=%s', actions)] ('actions=%s', actions)]
...@@ -158,13 +164,31 @@ def ipv4_filter(network, port_number, remove=False): ...@@ -158,13 +164,31 @@ def ipv4_filter(network, port_number, remove=False):
def ipv6_filter(network, port_number, remove=False): def ipv6_filter(network, port_number, remove=False):
""" Apply/Remove ipv6 filter rule to network. """ """ Apply/Remove ipv6 filter rule to network. """
LINKLOCAL_SUBNET = "FE80::/64"
ICMPv6_NA = "136" # The type of IPv6 Neighbor Advertisement
if not remove: if not remove:
# Enable Neighbor Advertisement from linklocal address
# if target ip same as network.ipv6
flow_cmd = build_flow_rule(in_port=port_number, dl_src=network.mac,
protocol="icmp6", ipv6_src=LINKLOCAL_SUBNET,
icmp_type=ICMPv6_NA,
nd_target=network.ipv6,
priority=42001, actions="normal")
ofctl_command_execute(["add-flow", network.bridge, flow_cmd])
# Enable traffic from valid source
flow_cmd = build_flow_rule(in_port=port_number, dl_src=network.mac, flow_cmd = build_flow_rule(in_port=port_number, dl_src=network.mac,
protocol="ipv6", ipv6_src=network.ipv6, protocol="ipv6", ipv6_src=network.ipv6,
priority=42000, actions="normal") priority=42000, actions="normal")
ofctl_command_execute(["add-flow", network.bridge, flow_cmd]) ofctl_command_execute(["add-flow", network.bridge, flow_cmd])
else: else:
flow_cmd = build_flow_rule(in_port=port_number, dl_src=network.mac, flow_cmd = build_flow_rule(in_port=port_number, dl_src=network.mac,
protocol="icmp6", ipv6_src=LINKLOCAL_SUBNET,
icmp_type=ICMPv6_NA,
nd_target=network.ipv6)
flow_cmd = build_flow_rule(in_port=port_number, dl_src=network.mac,
protocol="ipv6", ipv6_src=network.ipv6) protocol="ipv6", ipv6_src=network.ipv6)
ofctl_command_execute(["del-flows", network.bridge, flow_cmd]) ofctl_command_execute(["del-flows", network.bridge, flow_cmd])
......
...@@ -9,6 +9,7 @@ from argparse import ArgumentParser ...@@ -9,6 +9,7 @@ from argparse import ArgumentParser
def to_bool(value): def to_bool(value):
return value.lower() in ("true", "yes", "y", "t") return value.lower() in ("true", "yes", "y", "t")
if to_bool(getenv("LIBVIRT_TEST", "False")): if to_bool(getenv("LIBVIRT_TEST", "False")):
HOSTNAME = "vmdriver.test" HOSTNAME = "vmdriver.test"
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment