From 7abd8c6e380a9c1148f1a355b26b079bda571576 Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Tue, 25 Apr 2023 14:27:59 +0800 Subject: [PATCH] Fix error when DHCP enabled with auto ip on STP bridge Resolves: RHBZ#2177733 Signed-off-by: Gris Ge --- ...-with-auto-IP-address-on-STP-enabled.patch | 67 +++++++++++++++++++ nmstate.spec | 6 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 0002-Fix-error-when-DHCP-with-auto-IP-address-on-STP-enabled.patch diff --git a/0002-Fix-error-when-DHCP-with-auto-IP-address-on-STP-enabled.patch b/0002-Fix-error-when-DHCP-with-auto-IP-address-on-STP-enabled.patch new file mode 100644 index 0000000..9424326 --- /dev/null +++ b/0002-Fix-error-when-DHCP-with-auto-IP-address-on-STP-enabled.patch @@ -0,0 +1,67 @@ +From 333e82445c048812e3e85fb9f3cb7558dc3f2aeb Mon Sep 17 00:00:00 2001 +From: Gris Ge +Date: Tue, 25 Apr 2023 14:10:34 +0800 +Subject: [PATCH] ip: Fix error when DHCP with auto IP address on STP enabled + bridge + +When DHCP enabled with auto IP address on STP enabled bridge, nmstate +will fail with verification error: + + Verification failure: br0.interface.ipv4.address desire '[]', + current 'null' + +The root cause is STP suspended the DHCP action which cause current +state shows null IP address. And nmstate incorrectly treat [] != null +for IP address. + +Fixed in `sanitize_current_for_verify()` to set empty array if None. + +To reproduce this problem, we just enable DHCP with auto IP address +where no DHCP server exists. Integration test case included. + +Signed-off-by: Gris Ge +--- + rust/src/lib/query_apply/ip.rs | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/rust/src/lib/query_apply/ip.rs b/rust/src/lib/query_apply/ip.rs +index b2d6ac49..a6df740b 100644 +--- a/rust/src/lib/query_apply/ip.rs ++++ b/rust/src/lib/query_apply/ip.rs +@@ -12,6 +12,11 @@ impl InterfaceIpv4 { + if self.dhcp_custom_hostname.is_none() { + self.dhcp_custom_hostname = Some(String::new()); + } ++ ++ // No IP address means empty. ++ if self.enabled && self.addresses.is_none() { ++ self.addresses = Some(Vec::new()); ++ } + } + + // Sort addresses and dedup +@@ -89,6 +94,11 @@ impl InterfaceIpv6 { + if self.dhcp_custom_hostname.is_none() { + self.dhcp_custom_hostname = Some(String::new()); + } ++ ++ // No IP address means empty. ++ if self.enabled && self.addresses.is_none() { ++ self.addresses = Some(Vec::new()); ++ } + } + + // Sort addresses and dedup +@@ -96,9 +106,6 @@ impl InterfaceIpv6 { + if let Some(addrs) = self.addresses.as_mut() { + addrs.sort_unstable(); + addrs.dedup(); +- if addrs.is_empty() { +- self.addresses = None; +- } + } + } + pub(crate) fn update(&mut self, other: &Self) { +-- +2.40.0 + diff --git a/nmstate.spec b/nmstate.spec index 353c13a..9ea9258 100644 --- a/nmstate.spec +++ b/nmstate.spec @@ -4,7 +4,7 @@ Name: nmstate Version: 2.2.10 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Declarative network manager API License: LGPLv2+ URL: https://github.com/%{srcname}/%{srcname} @@ -13,6 +13,7 @@ Source1: https://github.com/nmstate/nmstate/releases/download/v%{version} Source2: https://nmstate.io/nmstate.gpg Source3: https://github.com/nmstate/nmstate/releases/download/v%{version}/nmstate-vendor-%{version}.tar.xz Patch1: BZ_2182769-skip_if_ifnetifnames_0.patch +Patch2: 0002-Fix-error-when-DHCP-with-auto-IP-address-on-STP-enabled.patch BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: gnupg2 @@ -151,6 +152,9 @@ popd /sbin/ldconfig %changelog +* Tue Apr 25 2023 Gris Ge - 2.2.10-3 +- Fix error when DHCP enabled with auto ip on STP bridge + * Sun Apr 23 2023 Gris Ge - 2.2.10-2 - Do not pin NIC if `net.ifnames=0`