Blame SOURCES/BZ_1858762-hide_ovs_patch_port_mtu.patch

dad7e0
From bc2f8445d493f8a5a4ff1ceead13d2b3ac5325cc Mon Sep 17 00:00:00 2001
dad7e0
From: Fernando Fernandez Mancera <ffmancera@riseup.net>
dad7e0
Date: Sun, 26 Jul 2020 00:46:16 +0200
dad7e0
Subject: [PATCH 1/2] nm.wired: do not report MTU if it is 0
dad7e0
dad7e0
If an interface contains an MTU with value 0, Nmstate should not report
dad7e0
it because it is an special interface like OVS patch port interfaces.
dad7e0
dad7e0
Added a test case for this.
dad7e0
dad7e0
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
dad7e0
---
dad7e0
 libnmstate/nm/wired.py | 4 +++-
dad7e0
 1 file changed, 3 insertions(+), 1 deletion(-)
dad7e0
dad7e0
diff --git a/libnmstate/nm/wired.py b/libnmstate/nm/wired.py
dad7e0
index 27d4318..64662ac 100644
dad7e0
--- a/libnmstate/nm/wired.py
dad7e0
+++ b/libnmstate/nm/wired.py
dad7e0
@@ -124,7 +124,9 @@ def get_info(device):
dad7e0
 
dad7e0
     iface = device.get_iface()
dad7e0
     try:
dad7e0
-        info[Interface.MTU] = int(device.get_mtu())
dad7e0
+        mtu = int(device.get_mtu())
dad7e0
+        if mtu:
dad7e0
+            info[Interface.MTU] = mtu
dad7e0
     except AttributeError:
dad7e0
         pass
dad7e0
 
dad7e0
-- 
dad7e0
2.27.0
dad7e0
dad7e0
dad7e0
From 03aea7d7debfca0f01b60e9f406c9acdf3de3775 Mon Sep 17 00:00:00 2001
dad7e0
From: Gris Ge <fge@redhat.com>
dad7e0
Date: Mon, 27 Jul 2020 20:51:53 +0800
dad7e0
Subject: [PATCH 2/2] nm ovs: Raise NmstateNotSupportedError for
dad7e0
 save_to_disk=False
dad7e0
dad7e0
Due to limitation of NetworkManager 1.26, nmstate cannot support
dad7e0
`save_to_disk=False`(ask, memory only) state for OVS interfaces.
dad7e0
dad7e0
Raise NmstateNotSupportedError if NetworkManager version is older than
dad7e0
1.28 and has OVS interface in desire state with `save_to_disk=False`.
dad7e0
dad7e0
Integration test case included.
dad7e0
dad7e0
Signed-off-by: Gris Ge <fge@redhat.com>
dad7e0
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
dad7e0
---
dad7e0
 libnmstate/nm/applier.py | 23 +++++++++++++++++++++++
dad7e0
 1 file changed, 23 insertions(+)
dad7e0
dad7e0
diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py
dad7e0
index 4e20af5..a91cee5 100644
dad7e0
--- a/libnmstate/nm/applier.py
dad7e0
+++ b/libnmstate/nm/applier.py
dad7e0
@@ -17,9 +17,11 @@
dad7e0
 # along with this program. If not, see <https://www.gnu.org/licenses/>.
dad7e0
 #
dad7e0
 
dad7e0
+from distutils.version import StrictVersion
dad7e0
 import logging
dad7e0
 import itertools
dad7e0
 
dad7e0
+from libnmstate.error import NmstateNotSupportedError
dad7e0
 from libnmstate.error import NmstateValueError
dad7e0
 from libnmstate.schema import Interface
dad7e0
 from libnmstate.schema import InterfaceState
dad7e0
@@ -65,6 +67,17 @@ MASTER_IFACE_TYPES = (
dad7e0
 def apply_changes(context, net_state, save_to_disk):
dad7e0
     con_profiles = []
dad7e0
 
dad7e0
+    if (
dad7e0
+        not save_to_disk
dad7e0
+        and _has_ovs_interface_desired_or_changed(net_state)
dad7e0
+        and StrictVersion(context.client.get_version())
dad7e0
+        < StrictVersion("1.28.0")
dad7e0
+    ):
dad7e0
+        raise NmstateNotSupportedError(
dad7e0
+            f"NetworkManager version {context.client.get_version()} does not "
dad7e0
+            f"support 'save_to_disk=False' against OpenvSwitch interface"
dad7e0
+        )
dad7e0
+
dad7e0
     _preapply_dns_fix(context, net_state)
dad7e0
 
dad7e0
     ifaces_desired_state = net_state.ifaces.state_to_edit
dad7e0
@@ -602,3 +615,13 @@ def _preapply_dns_fix(context, net_state):
dad7e0
         for iface in net_state.ifaces.values():
dad7e0
             if iface.is_changed or iface.is_desired:
dad7e0
                 iface.remove_dns_metadata()
dad7e0
+
dad7e0
+
dad7e0
+def _has_ovs_interface_desired_or_changed(net_state):
dad7e0
+    for iface in net_state.ifaces.values():
dad7e0
+        if iface.type in (
dad7e0
+            InterfaceType.OVS_BRIDGE,
dad7e0
+            InterfaceType.OVS_INTERFACE,
dad7e0
+            InterfaceType.OVS_PORT,
dad7e0
+        ) and (iface.is_desired or iface.is_changed):
dad7e0
+            return True
dad7e0
-- 
dad7e0
2.27.0
dad7e0