diff --git a/neutron/agent/linux/ra.py b/neutron/agent/linux/ra.py index af721cca1b4..10a9f53a1ce 100644 --- a/neutron/agent/linux/ra.py +++ b/neutron/agent/linux/ra.py @@ -44,6 +44,10 @@ CONFIG_TEMPLATE = jinja2.Template("""interface {{ interface_name }} AdvOtherConfigFlag on; {% endif %} + {% if ra_mode == constants.DHCPV6_STATEFUL %} + AdvManagedFlag on; + {% endif %} + {% if ra_mode in (constants.IPV6_SLAAC, constants.DHCPV6_STATELESS) %} prefix {{ prefix }} { diff --git a/neutron/tests/unit/test_l3_agent.py b/neutron/tests/unit/test_l3_agent.py index 28a5568fe11..a3d6bff517f 100644 --- a/neutron/tests/unit/test_l3_agent.py +++ b/neutron/tests/unit/test_l3_agent.py @@ -2195,13 +2195,17 @@ vrrp_instance VR_1 { self.assertIn(_join('-p', pidfile), cmd) self.assertIn(_join('-m', 'syslog'), cmd) - def test_generate_radvd_conf_other_flag(self): + def test_generate_radvd_conf_other_and_managed_flag(self): + _skip_check = object() + skip = lambda flag: True if flag is _skip_check else False + + expected = {l3_constants.IPV6_SLAAC: (False, False), + l3_constants.DHCPV6_STATELESS: (True, False), # we don't check other flag for stateful since it's redundant # for this mode and can be ignored by clients, as per RFC4861 - expected = {l3_constants.IPV6_SLAAC: False, - l3_constants.DHCPV6_STATELESS: True} + l3_constants.DHCPV6_STATEFUL: (_skip_check, True)} - for ra_mode, flag_set in expected.iteritems(): + for ra_mode, flags_set in expected.iteritems(): router = prepare_router_data() ri = self._process_router_ipv6_interface_added(router, ra_mode=ra_mode) @@ -2209,9 +2213,18 @@ vrrp_instance VR_1 { ra._generate_radvd_conf(ri.router['id'], router[l3_constants.INTERFACE_KEY], mock.Mock()) - asserter = self.assertIn if flag_set else self.assertNotIn - asserter('AdvOtherConfigFlag on;', - self.utils_replace_file.call_args[0][1]) + + def assertFlag(flag): + return (self.assertIn if flag else self.assertNotIn) + + other_flag, managed_flag = flags_set + if not skip(other_flag): + assertFlag(other_flag)('AdvOtherConfigFlag on;', + self.utils_replace_file.call_args[0][1]) + + if not skip(managed_flag): + assertFlag(managed_flag)('AdvManagedFlag on', + self.utils_replace_file.call_args[0][1]) class TestL3AgentEventHandler(base.BaseTestCase):