import nmstate-1.3.3-8.el8_7

This commit is contained in:
CentOS Sources 2023-04-04 08:52:29 +00:00 committed by Stepan Oksanichenko
parent e90e2ba2e7
commit 3250ae7c70
5 changed files with 1572 additions and 1 deletions

View File

@ -0,0 +1,206 @@
From 12e298f27f1ffa58f6f7e60016ff197719b7a26e Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Thu, 23 Feb 2023 13:06:01 +0800
Subject: [PATCH] nm: Fix error on SR-IOV
When SR-IOV VF naming scheme is like `ens1f0v0`, nmstate will delete
the VF NM connection when applying this state:
```yml
---
interfaces:
- name: ens1f0
type: ethernet
state: up
ethernet:
sr-iov:
total-vfs: 1
- name: ens1f0v0
type: ethernet
state: up
ipv4:
enabled: false
ipv6:
enabled: false
```
This is because `delete_other_profiles()` is checking
`self._nm_profile()` from active NM profile instead of newly created
one. The fix is using newly created profile `self._nm_simple_conn`.
We also have race problem when activating PF along with VF, PF
activation might delete VF NIC which cause VF activation failed. To
workaround that, we activate PF first via `NmProfile.ACTION_SRIOV_PF`
and wait on it before start VF activation.
Also problem found during SR-IOV investigations is we do extra
un-required modification to `NM.SettingOvsExternalIDs` even it is not
mentioned in desired. We skip overriding `NM.SettingOvsExternalIDs` when
not desired.
Existing test case can cover the use cases.
Signed-off-by: Gris Ge <fge@redhat.com>
---
libnmstate/ifaces/ifaces.py | 18 +++++++++++++++++-
libnmstate/netapplier.py | 20 +++++++++++---------
libnmstate/nm/connection.py | 2 +-
libnmstate/nm/profile.py | 12 ++++++++++--
4 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/libnmstate/ifaces/ifaces.py b/libnmstate/ifaces/ifaces.py
index 828ff578..470dc0e6 100644
--- a/libnmstate/ifaces/ifaces.py
+++ b/libnmstate/ifaces/ifaces.py
@@ -157,6 +157,23 @@ class Ifaces:
def has_vf_count_change_and_missing_eth(self):
return self._has_vf_count_change() and self._has_missing_veth()
+ def has_sriov_iface(self):
+ for iface in self.all_kernel_ifaces.values():
+ if (iface.is_desired or iface.is_changed) and iface.is_up:
+ cur_iface = self._cur_kernel_ifaces.get(iface.name)
+ if (
+ cur_iface
+ and cur_iface.raw.get(Ethernet.CONFIG_SUBTREE, {}).get(
+ Ethernet.SRIOV_SUBTREE, {}
+ )
+ ) or iface.original_desire_dict.get(
+ Ethernet.CONFIG_SUBTREE, {}
+ ).get(
+ Ethernet.SRIOV_SUBTREE, {}
+ ):
+ return True
+ return False
+
def _has_vf_count_change(self):
for iface in self.all_kernel_ifaces.values():
cur_iface = self._cur_kernel_ifaces.get(iface.name)
@@ -664,7 +681,6 @@ class Ifaces:
return None
def get_cur_iface(self, iface_name, iface_type):
-
iface = self._cur_kernel_ifaces.get(iface_name)
if iface and iface_type in (None, InterfaceType.UNKNOWN, iface.type):
return iface
diff --git a/libnmstate/netapplier.py b/libnmstate/netapplier.py
index ae909126..50a70a9c 100644
--- a/libnmstate/netapplier.py
+++ b/libnmstate/netapplier.py
@@ -104,7 +104,7 @@ def apply(
pf_net_state,
verify_change,
save_to_disk,
- has_sriov_pf=True,
+ VERIFY_RETRY_COUNT_SRIOV,
)
# Refresh the current state
current_state = show_with_plugins(
@@ -120,8 +120,16 @@ def apply(
current_state,
save_to_disk,
)
+
+ if net_state.ifaces.has_sriov_iface():
+ # If SR-IOV is present, the verification timeout is being increased
+ # to avoid timeouts due to slow drivers like i40e.
+ verify_retry = VERIFY_RETRY_COUNT_SRIOV
+ else:
+ verify_retry = VERIFY_RETRY_COUNT
+
_apply_ifaces_state(
- plugins, net_state, verify_change, save_to_disk, has_sriov_pf=False
+ plugins, net_state, verify_change, save_to_disk, verify_retry
)
if commit:
destroy_checkpoints(plugins, checkpoints)
@@ -154,7 +162,7 @@ def rollback(*, checkpoint=None):
def _apply_ifaces_state(
- plugins, net_state, verify_change, save_to_disk, has_sriov_pf=False
+ plugins, net_state, verify_change, save_to_disk, verify_retry
):
for plugin in plugins:
# Do not allow plugin to modify the net_state for future verification
@@ -163,12 +171,6 @@ def _apply_ifaces_state(
verified = False
if verify_change:
- if has_sriov_pf:
- # If SR-IOV is present, the verification timeout is being increased
- # to avoid timeouts due to slow drivers like i40e.
- verify_retry = VERIFY_RETRY_COUNT_SRIOV
- else:
- verify_retry = VERIFY_RETRY_COUNT
for _ in range(verify_retry):
try:
_verify_change(plugins, net_state)
diff --git a/libnmstate/nm/connection.py b/libnmstate/nm/connection.py
index 1fbb380b..6448e372 100644
--- a/libnmstate/nm/connection.py
+++ b/libnmstate/nm/connection.py
@@ -240,7 +240,7 @@ def create_new_nm_simple_conn(iface, nm_profile):
InterfaceType.OVS_PORT,
)
or iface.type == InterfaceType.OVS_BRIDGE
- ):
+ ) and OvsDB.OVS_DB_SUBTREE in iface.original_desire_dict:
nm_setting = create_ovsdb_external_ids_setting(
iface_info.get(OvsDB.OVS_DB_SUBTREE, {})
)
diff --git a/libnmstate/nm/profile.py b/libnmstate/nm/profile.py
index 53eaebed..ad1ad19f 100644
--- a/libnmstate/nm/profile.py
+++ b/libnmstate/nm/profile.py
@@ -56,6 +56,7 @@ ROUTE_REMOVED = "_route_removed"
class NmProfile:
# For unmanged iface and desired to down
ACTION_ACTIVATE_FIRST = "activate_first"
+ ACTION_SRIOV_PF = "activate_sriov_pf"
ACTION_DEACTIVATE = "deactivate"
ACTION_DEACTIVATE_FIRST = "deactivate_first"
ACTION_DELETE_DEVICE = "delete_device"
@@ -77,6 +78,7 @@ class NmProfile:
ACTION_ACTIVATE_FIRST,
ACTION_DEACTIVATE_FIRST,
ACTION_TOP_CONTROLLER,
+ ACTION_SRIOV_PF,
ACTION_NEW_IFACES,
ACTION_OTHER_CONTROLLER,
ACTION_NEW_OVS_PORT,
@@ -181,6 +183,11 @@ class NmProfile:
else:
self._add_action(NmProfile.ACTION_NEW_IFACES)
else:
+ if (
+ self._nm_dev.props.capabilities
+ & NM.DeviceCapabilities.SRIOV
+ ):
+ self._add_action(NmProfile.ACTION_SRIOV_PF)
if self._iface.type == InterfaceType.OVS_PORT:
self._add_action(NmProfile.ACTION_MODIFIED_OVS_PORT)
if self._iface.type == InterfaceType.OVS_INTERFACE:
@@ -462,6 +469,7 @@ class NmProfile:
def do_action(self, action):
if action in (
+ NmProfile.ACTION_SRIOV_PF,
NmProfile.ACTION_MODIFIED,
NmProfile.ACTION_MODIFIED_OVS_PORT,
NmProfile.ACTION_MODIFIED_OVS_IFACE,
@@ -559,8 +567,8 @@ class NmProfile:
or nm_profile.get_connection_type() == self._nm_iface_type
)
and (
- self._nm_profile is None
- or nm_profile.get_uuid() != self._nm_profile.get_uuid()
+ self._nm_simple_conn is None
+ or nm_profile.get_uuid() != self._nm_simple_conn.get_uuid()
)
):
ProfileDelete(
--
2.39.2

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
From 030bd5e38a2913e96ef145f88cb74c619acea6bf Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Mon, 27 Feb 2023 12:17:05 +0800
Subject: [PATCH] nm: Ignore error when creating profile if not desired
When a undesired interface holding `autoconf: true` and `dhcp: false`
for IPv6, nmstate will fail with error:
Autoconf without DHCP is not supported yet
This is caused by `nm/connection.py` try to create `NM.SimpleConnection`
for every interface even not desired.
This patch changed to:
* Only create new `NM.SimpleConnection` when desired or changed.
* Use current profile if exists when not desired or changed.
* Ignore error if not desired/changed.
Integration test case included.
Signed-off-by: Gris Ge <fge@redhat.com>
---
libnmstate/nm/profile.py | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/libnmstate/nm/profile.py b/libnmstate/nm/profile.py
index ad1ad19f..1119cd1a 100644
--- a/libnmstate/nm/profile.py
+++ b/libnmstate/nm/profile.py
@@ -24,6 +24,7 @@ from distutils.version import StrictVersion
import logging
import time
+from libnmstate.error import NmstateError
from libnmstate.error import NmstateInternalError
from libnmstate.error import NmstateLibnmError
from libnmstate.error import NmstateNotSupportedError
@@ -321,9 +322,22 @@ class NmProfile:
# TODO: Use applied config as base profile
# Or even better remove the base profile argument as top level
# of nmstate should provide full/merged configure.
- self._nm_simple_conn = create_new_nm_simple_conn(
- self._iface, self._nm_profile
- )
+ if self._iface.is_changed or self._iface.is_desired:
+ self._nm_simple_conn = create_new_nm_simple_conn(
+ self._iface, self._nm_profile
+ )
+ elif self._nm_profile:
+ self._nm_simple_conn = NM.SimpleConnection.new_clone(
+ self._nm_profile
+ )
+ else:
+ try:
+ self._nm_simple_conn = create_new_nm_simple_conn(
+ self._iface, self._nm_profile
+ )
+ # No error for undesired interface
+ except NmstateError:
+ pass
def save_config(self, save_to_disk):
self._check_sriov_support()
--
2.39.2

View File

@ -0,0 +1,208 @@
From ef23275126898f316cb3e7e2df552c006e867105 Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Tue, 14 Feb 2023 15:20:21 +0800
Subject: [PATCH] ip: Introduce `Interface.WAIT_IP`
This patch is introducing `Interface.WAIT_IP` property with these
possible values:
* `Interface.WAIT_IP_ANY`("any"):
System will consider interface activated when any IP stack is
configured(neither static or automatic).
* `Interface.WAIT_IP_IPV4`("ipv4"):
System will wait IPv4 been configured.
* `Interface.WAIT_IP_IPV6`("ipv6"):
System will wait IPv6 been configured.
* `Introduce.WAIT_IP_IPV4_AND_IPV6`("ipv4+ipv6"):
System will wait both IPv4 and IPv6 been configured.
Considering this old branch, there is no validation on invalid use cases
like setting wait-ip on disabled IP stack.
Example YAML on waiting both IP stacks:
```yml
---
interfaces:
- name: eth1
type: ethernet
state: up
mtu: 1500
wait-ip: ipv4+ipv6
ipv4:
enabled: true
dhcp: true
ipv6:
enabled: true
dhcp: true
autoconf: true
```
Integration test case included.
Signed-off-by: Gris Ge <fge@redhat.com>
---
libnmstate/nm/connection.py | 9 +++----
libnmstate/nm/ip.py | 48 +++++++++++++++++++++++++++++++++++++
libnmstate/nm/plugin.py | 29 +++++++++-------------
libnmstate/schema.py | 5 ++++
4 files changed, 69 insertions(+), 22 deletions(-)
create mode 100644 libnmstate/nm/ip.py
diff --git a/libnmstate/nm/connection.py b/libnmstate/nm/connection.py
index 1974cfd4..1fbb380b 100644
--- a/libnmstate/nm/connection.py
+++ b/libnmstate/nm/connection.py
@@ -39,6 +39,7 @@ from .common import NM
from .ethtool import create_ethtool_setting
from .ieee_802_1x import create_802_1x_setting
from .infiniband import create_setting as create_infiniband_setting
+from .ip import set_wait_ip
from .ipv4 import create_setting as create_ipv4_setting
from .ipv6 import create_setting as create_ipv6_setting
from .lldp import apply_lldp_setting
@@ -106,10 +107,10 @@ class _ConnectionSetting:
def create_new_nm_simple_conn(iface, nm_profile):
nm_iface_type = Api2Nm.get_iface_type(iface.type)
iface_info = iface.to_dict()
- settings = [
- create_ipv4_setting(iface_info.get(Interface.IPV4), nm_profile),
- create_ipv6_setting(iface_info.get(Interface.IPV6), nm_profile),
- ]
+ ipv4_set = create_ipv4_setting(iface_info.get(Interface.IPV4), nm_profile)
+ ipv6_set = create_ipv6_setting(iface_info.get(Interface.IPV6), nm_profile)
+ set_wait_ip(ipv4_set, ipv6_set, iface_info.get(Interface.WAIT_IP))
+ settings = [ipv4_set, ipv6_set]
con_setting = _ConnectionSetting()
if nm_profile and not is_multiconnect_profile(nm_profile):
con_setting.import_by_profile(nm_profile, iface.is_controller)
diff --git a/libnmstate/nm/ip.py b/libnmstate/nm/ip.py
new file mode 100644
index 00000000..d0fc1e3b
--- /dev/null
+++ b/libnmstate/nm/ip.py
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+from libnmstate.schema import Interface
+
+
+def get_wait_ip(applied_config):
+ if applied_config:
+ nm_ipv4_may_fail = _get_may_fail(applied_config, False)
+ nm_ipv6_may_fail = _get_may_fail(applied_config, True)
+ if nm_ipv4_may_fail and not nm_ipv6_may_fail:
+ return Interface.WAIT_IP_IPV6
+ elif not nm_ipv4_may_fail and nm_ipv6_may_fail:
+ return Interface.WAIT_IP_IPV4
+ elif not nm_ipv4_may_fail and not nm_ipv6_may_fail:
+ return Interface.WAIT_IP_IPV4_AND_IPV6
+ return Interface.WAIT_IP_ANY
+
+
+def set_wait_ip(nm_ipv4_set, nm_ipv6_set, wait_ip):
+ if nm_ipv4_set:
+ if wait_ip == Interface.WAIT_IP_ANY:
+ nm_ipv4_set.props.may_fail = True
+ elif wait_ip in (
+ Interface.WAIT_IP_IPV4,
+ Interface.WAIT_IP_IPV4_AND_IPV6,
+ ):
+ nm_ipv4_set.props.may_fail = False
+ if nm_ipv6_set:
+ if wait_ip == Interface.WAIT_IP_ANY:
+ nm_ipv6_set.props.may_fail = True
+ elif wait_ip in (
+ Interface.WAIT_IP_IPV6,
+ Interface.WAIT_IP_IPV4_AND_IPV6,
+ ):
+ nm_ipv6_set.props.may_fail = False
+
+
+def _get_may_fail(nm_profile, is_ipv6):
+ if is_ipv6:
+ nm_set = nm_profile.get_setting_ip6_config()
+ else:
+ nm_set = nm_profile.get_setting_ip4_config()
+
+ if nm_set:
+ return nm_set.props.may_fail
+ else:
+ # NM is defaulting `may-fail` as True
+ return True
diff --git a/libnmstate/nm/plugin.py b/libnmstate/nm/plugin.py
index bca1aedd..9bbbbb98 100644
--- a/libnmstate/nm/plugin.py
+++ b/libnmstate/nm/plugin.py
@@ -1,21 +1,5 @@
-#
-# Copyright (c) 2020-2021 Red Hat, Inc.
-#
-# This file is part of nmstate
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 2.1 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
from distutils.version import StrictVersion
import logging
from operator import itemgetter
@@ -25,6 +9,8 @@ from libnmstate.error import NmstateNotSupportedError
from libnmstate.error import NmstateValueError
from libnmstate.schema import DNS
from libnmstate.schema import Interface
+from libnmstate.schema import InterfaceIPv4
+from libnmstate.schema import InterfaceIPv6
from libnmstate.schema import InterfaceType
from libnmstate.schema import LLDP
from libnmstate.plugin import NmstatePlugin
@@ -41,6 +27,7 @@ from .device import list_devices
from .dns import get_running as get_dns_running
from .dns import get_running_config as get_dns_running_config
from .infiniband import get_info as get_infiniband_info
+from .ip import get_wait_ip
from .ipv4 import get_info as get_ipv4_info
from .ipv6 import get_info as get_ipv6_info
from .lldp import get_info as get_lldp_info
@@ -190,6 +177,12 @@ class NetworkManagerPlugin(NmstatePlugin):
if applied_config:
iface_info.update(get_ovsdb_external_ids(applied_config))
+ if iface_info.get(Interface.IPV4, {}).get(
+ InterfaceIPv4.ENABLED
+ ) or iface_info.get(Interface.IPV6, {}).get(
+ InterfaceIPv6.ENABLED
+ ):
+ iface_info[Interface.WAIT_IP] = get_wait_ip(applied_config)
info.append(iface_info)
diff --git a/libnmstate/schema.py b/libnmstate/schema.py
index e740abff..c3d3fcfc 100644
--- a/libnmstate/schema.py
+++ b/libnmstate/schema.py
@@ -49,6 +49,11 @@ class Interface:
COPY_MAC_FROM = "copy-mac-from"
ACCEPT_ALL_MAC_ADDRESSES = "accept-all-mac-addresses"
CONTROLLER = "controller"
+ WAIT_IP = "wait-ip"
+ WAIT_IP_ANY = "any"
+ WAIT_IP_IPV4 = "ipv4"
+ WAIT_IP_IPV6 = "ipv6"
+ WAIT_IP_IPV4_AND_IPV6 = "ipv4+ipv6"
class Route:
--
2.39.2

View File

@ -4,7 +4,7 @@
Name: nmstate
Version: 1.3.3
Release: 4%{?dist}
Release: 8%{?dist}
Summary: Declarative network manager API
License: LGPLv2+
URL: https://github.com/%{srcname}/%{srcname}
@ -18,6 +18,10 @@ Patch10: BZ_2139698-nm-sriov-Do-not-touch-SR-IOV-if-not-desired.patch
Patch11: BZ_2128555-ip-allow-extra-IP-address-found-in-verification-stag.patch
Patch12: BZ_2149048-ip-Preserve-the-IP-address-order-when-applying.patch
Patch13: BZ_2150705-nm-fix-activation-retry.patch
Patch14: BZ_2169642-Fix-sriov.patch
Patch15: BZ_2170078-Introduce-wait-ip.patch
Patch16: BZ_2169642-Fix-SRIOV-2.patch
Patch17: BZ_2169642-Ignore-error-when-creating-profile-if-not-desired.patch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: gnupg2
@ -152,6 +156,18 @@ popd
/sbin/ldconfig
%changelog
* Mon Feb 27 2023 Gris Ge <fge@redhat.com> - 1.3.3-8
- Ignore error in undesired iface. RHBZ#2169642
* Thu Feb 23 2023 Gris Ge <fge@redhat.com> - 1.3.3-7
- New patch for fixing SR-IOV. RHBZ#2169642
* Thu Feb 16 2023 Gris Ge <fge@redhat.com> - 1.3.3-6
- Add Interface wait-ip support. RHBZ#2170078
* Wed Feb 15 2023 Gris Ge <fge@redhat.com> - 1.3.3-5
- Fix SR-IOV creating VF with IP stack disabled. RHBZ#2169642
* Tue Dec 06 2022 Gris Ge <fge@redhat.com> - 1.3.3-4
- Fix activation retry. RHBZ#2150705