nm ipv6: Enable IPv6 even without explicit addresses
IPv6 is now enabled even when the desired state includes IPv6 configuration enabled but without addresses or with link-local addresses only. The IPv6 method is set to link-local in such cases. Signed-off-by: Edward Haas <edwardh@redhat.com>
This commit is contained in:
parent
a05ddcad1c
commit
7948faf4c9
@ -48,10 +48,8 @@ def get_info(active_connection):
|
||||
|
||||
def create_setting(config):
|
||||
setting_ip = nmclient.NM.SettingIP6Config.new()
|
||||
if config and config.get('enabled') and config.get('address'):
|
||||
setting_ip.props.method = (
|
||||
nmclient.NM.SETTING_IP6_CONFIG_METHOD_MANUAL)
|
||||
for address in config['address']:
|
||||
if config and config.get('enabled'):
|
||||
for address in config.get('address', ()):
|
||||
if iplib.is_ipv6_link_local_addr(address['ip'],
|
||||
address['prefix-length']):
|
||||
logging.warning('IPv6 link local address '
|
||||
@ -62,8 +60,13 @@ def create_setting(config):
|
||||
address['ip'],
|
||||
address['prefix-length'])
|
||||
setting_ip.add_address(naddr)
|
||||
|
||||
if not setting_ip.props.addresses:
|
||||
if setting_ip.props.addresses:
|
||||
setting_ip.props.method = (
|
||||
nmclient.NM.SETTING_IP6_CONFIG_METHOD_MANUAL)
|
||||
else:
|
||||
setting_ip.props.method = (
|
||||
nmclient.NM.SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
|
||||
else:
|
||||
setting_ip.props.method = (
|
||||
nmclient.NM.SETTING_IP6_CONFIG_METHOD_IGNORE)
|
||||
return setting_ip
|
||||
|
@ -26,15 +26,12 @@ from .testlib import assertlib
|
||||
from .testlib import statelib
|
||||
from .testlib.statelib import INTERFACES
|
||||
|
||||
# FIXME: Once IPv6 disabling is supported, below IPv6 codes should be removed.
|
||||
|
||||
|
||||
def test_increase_iface_mtu():
|
||||
desired_state = statelib.show_only(('eth1',))
|
||||
eth1_desired_state = desired_state[INTERFACES][0]
|
||||
eth1_desired_state['state'] = 'up'
|
||||
eth1_desired_state['mtu'] = 1900
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
|
||||
@ -57,7 +54,6 @@ def test_upper_limit_jambo_iface_mtu():
|
||||
eth1_desired_state = desired_state[INTERFACES][0]
|
||||
eth1_desired_state['state'] = 'up'
|
||||
eth1_desired_state['mtu'] = 9000
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
|
||||
@ -69,7 +65,6 @@ def test_increase_more_than_jambo_iface_mtu():
|
||||
eth1_desired_state = desired_state[INTERFACES][0]
|
||||
eth1_desired_state['state'] = 'up'
|
||||
eth1_desired_state['mtu'] = 10000
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
|
||||
@ -82,7 +77,6 @@ def test_decrease_to_zero_iface_mtu():
|
||||
eth1_desired_state = desired_state[INTERFACES][0]
|
||||
eth1_desired_state['state'] = 'up'
|
||||
eth1_desired_state['mtu'] = 0
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
|
||||
with pytest.raises(netapplier.DesiredStateIsNotCurrentError) as err:
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
@ -96,7 +90,6 @@ def test_decrease_to_negative_iface_mtu():
|
||||
eth1_desired_state = desired_state[INTERFACES][0]
|
||||
eth1_desired_state['state'] = 'up'
|
||||
eth1_desired_state['mtu'] = -1
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
|
||||
with pytest.raises(js.ValidationError) as err:
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
@ -111,7 +104,6 @@ def test_decrease_to_min_ethernet_frame_size_iface_mtu():
|
||||
eth1_desired_state['state'] = 'up'
|
||||
# the min is 64 - 18 = 46
|
||||
eth1_desired_state['mtu'] = 40
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
|
||||
with pytest.raises(netapplier.DesiredStateIsNotCurrentError) as err:
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
|
@ -67,8 +67,6 @@ def test_add_static_ipv4_with_full_state():
|
||||
eth1_desired_state['ipv4']['address'] = [
|
||||
{'ip': IPV4_ADDRESS3, 'prefix-length': 24}
|
||||
]
|
||||
# FIXME: We don't have a way to disable IPv6 in libnmstate yet.
|
||||
eth1_desired_state['ipv6']['enabled'] = True
|
||||
netapplier.apply(copy.deepcopy(desired_state))
|
||||
|
||||
assertlib.assert_state(desired_state)
|
||||
|
@ -63,7 +63,7 @@ def test_create_setting_without_addresses(NM_mock):
|
||||
)
|
||||
|
||||
assert (ipv6_setting.props.method ==
|
||||
NM_mock.SETTING_IP6_CONFIG_METHOD_IGNORE)
|
||||
NM_mock.SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
|
||||
|
||||
|
||||
def test_create_setting_with_static_addresses(NM_mock):
|
||||
|
Loading…
x
Reference in New Issue
Block a user