diff --git a/SOURCES/BZ_1858762-hide_ovs_patch_port_mtu.patch b/SOURCES/BZ_1858762-hide_ovs_patch_port_mtu.patch new file mode 100644 index 0000000..3e5bea9 --- /dev/null +++ b/SOURCES/BZ_1858762-hide_ovs_patch_port_mtu.patch @@ -0,0 +1,105 @@ +From bc2f8445d493f8a5a4ff1ceead13d2b3ac5325cc Mon Sep 17 00:00:00 2001 +From: Fernando Fernandez Mancera +Date: Sun, 26 Jul 2020 00:46:16 +0200 +Subject: [PATCH 1/2] nm.wired: do not report MTU if it is 0 + +If an interface contains an MTU with value 0, Nmstate should not report +it because it is an special interface like OVS patch port interfaces. + +Added a test case for this. + +Signed-off-by: Fernando Fernandez Mancera +--- + libnmstate/nm/wired.py | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/libnmstate/nm/wired.py b/libnmstate/nm/wired.py +index 27d4318..64662ac 100644 +--- a/libnmstate/nm/wired.py ++++ b/libnmstate/nm/wired.py +@@ -124,7 +124,9 @@ def get_info(device): + + iface = device.get_iface() + try: +- info[Interface.MTU] = int(device.get_mtu()) ++ mtu = int(device.get_mtu()) ++ if mtu: ++ info[Interface.MTU] = mtu + except AttributeError: + pass + +-- +2.27.0 + + +From 03aea7d7debfca0f01b60e9f406c9acdf3de3775 Mon Sep 17 00:00:00 2001 +From: Gris Ge +Date: Mon, 27 Jul 2020 20:51:53 +0800 +Subject: [PATCH 2/2] nm ovs: Raise NmstateNotSupportedError for + save_to_disk=False + +Due to limitation of NetworkManager 1.26, nmstate cannot support +`save_to_disk=False`(ask, memory only) state for OVS interfaces. + +Raise NmstateNotSupportedError if NetworkManager version is older than +1.28 and has OVS interface in desire state with `save_to_disk=False`. + +Integration test case included. + +Signed-off-by: Gris Ge +Signed-off-by: Fernando Fernandez Mancera +--- + libnmstate/nm/applier.py | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py +index 4e20af5..a91cee5 100644 +--- a/libnmstate/nm/applier.py ++++ b/libnmstate/nm/applier.py +@@ -17,9 +17,11 @@ + # along with this program. If not, see . + # + ++from distutils.version import StrictVersion + import logging + import itertools + ++from libnmstate.error import NmstateNotSupportedError + from libnmstate.error import NmstateValueError + from libnmstate.schema import Interface + from libnmstate.schema import InterfaceState +@@ -65,6 +67,17 @@ MASTER_IFACE_TYPES = ( + def apply_changes(context, net_state, save_to_disk): + con_profiles = [] + ++ if ( ++ not save_to_disk ++ and _has_ovs_interface_desired_or_changed(net_state) ++ and StrictVersion(context.client.get_version()) ++ < StrictVersion("1.28.0") ++ ): ++ raise NmstateNotSupportedError( ++ f"NetworkManager version {context.client.get_version()} does not " ++ f"support 'save_to_disk=False' against OpenvSwitch interface" ++ ) ++ + _preapply_dns_fix(context, net_state) + + ifaces_desired_state = net_state.ifaces.state_to_edit +@@ -602,3 +615,13 @@ def _preapply_dns_fix(context, net_state): + for iface in net_state.ifaces.values(): + if iface.is_changed or iface.is_desired: + iface.remove_dns_metadata() ++ ++ ++def _has_ovs_interface_desired_or_changed(net_state): ++ for iface in net_state.ifaces.values(): ++ if iface.type in ( ++ InterfaceType.OVS_BRIDGE, ++ InterfaceType.OVS_INTERFACE, ++ InterfaceType.OVS_PORT, ++ ) and (iface.is_desired or iface.is_changed): ++ return True +-- +2.27.0 + diff --git a/SOURCES/BZ_1861263-handle-external-managed-interface.patch b/SOURCES/BZ_1861263-handle-external-managed-interface.patch new file mode 100644 index 0000000..dc59dc4 --- /dev/null +++ b/SOURCES/BZ_1861263-handle-external-managed-interface.patch @@ -0,0 +1,65 @@ +From ea7f304cc1ad32c3f2c25b49bf6b2663f348496a Mon Sep 17 00:00:00 2001 +From: Gris Ge +Date: Tue, 28 Jul 2020 15:59:11 +0800 +Subject: [PATCH] nm: Mark external subordinate as changed + +When user create bond with subordinate interfaces using non-NM +tools(iproute), the NetworkManager will mark the subordinates as +managed externally. + +When the desire state only contains the main interface, nmstate +noticing the slave list is unchanged, so only activate the main +interface, then NM remove the subordinate from their main interface. + +To workaround that, mark subordinate interfaces as changed when they are +managed by NM as externally. + +Integration test case included. + +Signed-off-by: Gris Ge +--- + libnmstate/nm/applier.py | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/libnmstate/nm/applier.py b/libnmstate/nm/applier.py +index a91cee5..68d11dc 100644 +--- a/libnmstate/nm/applier.py ++++ b/libnmstate/nm/applier.py +@@ -79,6 +79,7 @@ def apply_changes(context, net_state, save_to_disk): + ) + + _preapply_dns_fix(context, net_state) ++ _mark_nm_external_subordinate_changed(context, net_state) + + ifaces_desired_state = net_state.ifaces.state_to_edit + ifaces_desired_state.extend( +@@ -625,3 +626,26 @@ def _has_ovs_interface_desired_or_changed(net_state): + InterfaceType.OVS_PORT, + ) and (iface.is_desired or iface.is_changed): + return True ++ ++ ++def _mark_nm_external_subordinate_changed(context, net_state): ++ """ ++ When certain main interface contains subordinates is marked as ++ connected(externally), it means its profile is memory only and will lost ++ on next deactivation. ++ For this case, we should mark the subordinate as changed. ++ that subordinate should be marked as changed for NM to take over. ++ """ ++ for iface in net_state.ifaces.values(): ++ if iface.type in MASTER_IFACE_TYPES: ++ for subordinate in iface.slaves: ++ nmdev = context.get_nm_dev(subordinate) ++ if nmdev: ++ nm_ac = nmdev.get_active_connection() ++ if ( ++ nm_ac ++ and NM.ActivationStateFlags.EXTERNAL ++ & nm_ac.get_state_flags() ++ ): ++ subordinate_iface = net_state.ifaces[subordinate] ++ subordinate_iface.mark_as_changed() +-- +2.27.0 + diff --git a/SPECS/nmstate.spec b/SPECS/nmstate.spec index eff407c..001f341 100644 --- a/SPECS/nmstate.spec +++ b/SPECS/nmstate.spec @@ -4,13 +4,15 @@ Name: nmstate Version: 0.3.4 -Release: 1%{?dist} +Release: 3%{?dist} Summary: Declarative network manager API License: LGPLv2+ URL: https://github.com/%{srcname}/%{srcname} Source0: %{url}/releases/download/v%{version}/%{srcname}-%{version}.tar.gz Source1: %{url}/releases/download/v%{version}/%{srcname}-%{version}.tar.gz.asc Source2: https://www.nmstate.io/nmstate.gpg +Patch1: BZ_1858762-hide_ovs_patch_port_mtu.patch +Patch2: BZ_1861263-handle-external-managed-interface.patch BuildArch: noarch BuildRequires: python3-devel BuildRequires: python3-setuptools @@ -81,6 +83,12 @@ gpgv2 --keyring ./gpgkey-mantainers.gpg %{SOURCE1} %{SOURCE0} %{python3_sitelib}/%{libname}/plugins/__pycache__/nmstate_plugin_ovsdb* %changelog +* Tue Jul 28 2020 Gris Ge - 0.3.4-3 +- Add support NetworkManaged exteranl managed interface. RHBZ#1861263 + +* Tue Jul 28 2020 Gris Ge - 0.3.4-2 +- Hide MTU for OVS patch port. RHBZ#1858762 + * Sat Jul 25 2020 Fernando Fernandez Mancera - 0.3.4-1 - Upgrade to 0.3.4