radvd prefix configuration for DHCPV6_Stateful RA
When an IPv6 subnet's ipv6_ra_mode is set to DHCPV6_STATEFUL,
the hosts on that subnet rely on router advertisement for the
prefix length. This is important for subnets where the lengths
of the prefixes are not 64.
Conflicts:
neutron/agent/linux/ra.py
Closes-Bug: #1531093
Change-Id: Ied8d390a05ee1a2e544e39e887abf11c8a56abc3
(cherry picked from commit 629d86d480
)
This commit is contained in:
parent
5ceb23d77f
commit
ec052cf212
|
@ -51,13 +51,21 @@ CONFIG_TEMPLATE = jinja2.Template("""interface {{ interface_name }}
|
|||
AdvManagedFlag on;
|
||||
{% endif %}
|
||||
|
||||
{% for prefix in prefixes %}
|
||||
{% for prefix in auto_config_prefixes %}
|
||||
prefix {{ prefix }}
|
||||
{
|
||||
AdvOnLink on;
|
||||
AdvAutonomous on;
|
||||
};
|
||||
{% endfor %}
|
||||
|
||||
{% for prefix in stateful_config_prefixes %}
|
||||
prefix {{ prefix }}
|
||||
{
|
||||
AdvOnLink on;
|
||||
AdvAutonomous off;
|
||||
};
|
||||
{% endfor %}
|
||||
};
|
||||
""")
|
||||
|
||||
|
@ -87,11 +95,14 @@ class DaemonMonitor(object):
|
|||
auto_config_prefixes = [subnet['cidr'] for subnet in v6_subnets if
|
||||
subnet['ipv6_ra_mode'] == constants.IPV6_SLAAC or
|
||||
subnet['ipv6_ra_mode'] == constants.DHCPV6_STATELESS]
|
||||
stateful_config_prefixes = [subnet['cidr'] for subnet in v6_subnets
|
||||
if subnet['ipv6_ra_mode'] == constants.DHCPV6_STATEFUL]
|
||||
interface_name = self._dev_name_helper(p['id'])
|
||||
buf.write('%s' % CONFIG_TEMPLATE.render(
|
||||
ra_modes=list(ra_modes),
|
||||
interface_name=interface_name,
|
||||
prefixes=auto_config_prefixes,
|
||||
auto_config_prefixes=auto_config_prefixes,
|
||||
stateful_config_prefixes=stateful_config_prefixes,
|
||||
constants=constants))
|
||||
|
||||
utils.replace_file(radvd_conf, buf.getvalue())
|
||||
|
|
|
@ -1263,8 +1263,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
ri = self._process_router_ipv6_interface_added(router)
|
||||
self._assert_ri_process_enabled(ri)
|
||||
# Expect radvd configured without prefix
|
||||
self.assertNotIn('prefix',
|
||||
self.utils_replace_file.call_args[0][1].split())
|
||||
self.assertNotIn('prefix', self.utils_replace_file.call_args[0][1])
|
||||
|
||||
def test_process_router_ipv6_slaac_interface_added(self):
|
||||
router = l3_test_common.prepare_router_data()
|
||||
|
@ -1272,8 +1271,19 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
router, ra_mode=l3_constants.IPV6_SLAAC)
|
||||
self._assert_ri_process_enabled(ri)
|
||||
# Expect radvd configured with prefix
|
||||
self.assertIn('prefix',
|
||||
self.utils_replace_file.call_args[0][1].split())
|
||||
radvd_config_str = self.utils_replace_file.call_args[0][1]
|
||||
self.assertIn('prefix', radvd_config_str)
|
||||
self.assertIn('AdvAutonomous on', radvd_config_str)
|
||||
|
||||
def test_process_router_ipv6_dhcpv6_stateful_interface_added(self):
|
||||
router = l3_test_common.prepare_router_data()
|
||||
ri = self._process_router_ipv6_interface_added(
|
||||
router, ra_mode=l3_constants.DHCPV6_STATEFUL)
|
||||
self._assert_ri_process_enabled(ri)
|
||||
# Expect radvd configured with prefix
|
||||
radvd_config_str = self.utils_replace_file.call_args[0][1]
|
||||
self.assertIn('prefix', radvd_config_str)
|
||||
self.assertIn('AdvAutonomous off', radvd_config_str)
|
||||
|
||||
def test_process_router_ipv6_subnets_added(self):
|
||||
router = l3_test_common.prepare_router_data()
|
||||
|
@ -1285,11 +1295,13 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
{'ra_mode': l3_constants.DHCPV6_STATEFUL,
|
||||
'address_mode': l3_constants.DHCPV6_STATEFUL}])
|
||||
self._assert_ri_process_enabled(ri)
|
||||
radvd_config = self.utils_replace_file.call_args[0][1].split()
|
||||
radvd_config_str = self.utils_replace_file.call_args[0][1]
|
||||
# Assert we have a prefix from IPV6_SLAAC and a prefix from
|
||||
# DHCPV6_STATELESS on one interface
|
||||
self.assertEqual(2, radvd_config.count("prefix"))
|
||||
self.assertEqual(1, radvd_config.count("interface"))
|
||||
self.assertEqual(3, radvd_config_str.count("prefix"))
|
||||
self.assertEqual(1, radvd_config_str.count("interface"))
|
||||
self.assertEqual(2, radvd_config_str.count("AdvAutonomous on"))
|
||||
self.assertEqual(1, radvd_config_str.count("AdvAutonomous off"))
|
||||
|
||||
def test_process_router_ipv6_subnets_added_to_existing_port(self):
|
||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
|
|
Loading…
Reference in New Issue