From 38a8e719f93a0e6157f4d788856e34fcf6cbe089 Mon Sep 17 00:00:00 2001
From: Edward Haas <edwardh@redhat.com>
Date: Wed, 31 Jul 2019 12:35:37 +0300
Subject: [PATCH] nm.device: Exclude ipv6 changes from reapply
If ipv6 is changed, fallback from reapply to activate.
Ref: https://bugzilla.redhat.com/1734470
Signed-off-by: Edward Haas <edwardh@redhat.com>
Signed-off-by: Gris Ge <fge@redhat.com>
---
libnmstate/nm/device.py | 38 +++++++++++++++++++++++++++++++-------
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/libnmstate/nm/device.py b/libnmstate/nm/device.py
index 35f18b1..31ba298 100644
--- a/libnmstate/nm/device.py
+++ b/libnmstate/nm/device.py
@@ -186,18 +186,42 @@ def _modify_callback(src_object, result, user_data):
def _requires_activation(dev, connection_profile):
+ if _mtu_changed(dev, connection_profile):
+ logging.debug(
+ 'Device reapply does not support mtu changes, '
+ 'fallback to device activation: dev=%s',
+ dev.get_iface(),
+ )
+ return True
+ if _ipv6_changed(dev, connection_profile):
+ logging.debug(
+ 'Device reapply does not support ipv6 changes, '
+ 'fallback to device activation: dev=%s',
+ dev.get_iface(),
+ )
+ return True
+ return False
+
+
+def _mtu_changed(dev, connection_profile):
wired_setting = connection_profile.get_setting_wired()
configured_mtu = wired_setting.props.mtu if wired_setting else None
if configured_mtu:
current_mtu = int(dev.get_mtu())
- if configured_mtu != current_mtu:
- logging.debug(
- 'Device reapply does not support mtu changes, '
- 'fallback to device activation: dev=%s',
- dev.get_iface(),
- )
- return True
+ return configured_mtu != current_mtu
+ return False
+
+def _ipv6_changed(dev, connection_profile):
+ """
+ Detecting that the IPv6 method changed is not possible at this stage,
+ therefore, if IPv6 is defined (i.e. the method if not 'ignore'), IPv6 is
+ considered as changed.
+ """
+ ipv6_setting = connection_profile.get_setting_ip6_config()
+ if ipv6_setting:
+ ignore = nmclient.NM.SETTING_IP6_CONFIG_METHOD_IGNORE
+ return ipv6_setting.props.method != ignore
return False
--
2.22.0