From 8bacb2e291d56eecd120db9fdfa363087949d273 Mon Sep 17 00:00:00 2001 From: dongyuzhen Date: Thu, 5 Sep 2024 14:14:26 +0800 Subject: [PATCH] backport upstream bugfix patches --- ...bc-ipconfig-PROTO-compatibility-5437.patch | 94 +++++++++++++++++++ ...-openstack-Fix-bond-mac_address-5369.patch | 29 ++++++ cloud-init.spec | 11 ++- 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 backport-fix-net-klibc-ipconfig-PROTO-compatibility-5437.patch create mode 100644 backport-fix-openstack-Fix-bond-mac_address-5369.patch diff --git a/backport-fix-net-klibc-ipconfig-PROTO-compatibility-5437.patch b/backport-fix-net-klibc-ipconfig-PROTO-compatibility-5437.patch new file mode 100644 index 0000000..d519276 --- /dev/null +++ b/backport-fix-net-klibc-ipconfig-PROTO-compatibility-5437.patch @@ -0,0 +1,94 @@ +From 2c09f69173d448118b02e013518bf5f1674d3c1f Mon Sep 17 00:00:00 2001 +From: Alexsander de Souza <61709370+alexsander-souza@users.noreply.github.com> +Date: Thu, 27 Jun 2024 12:24:50 -0300 +Subject: [PATCH] fix(net): klibc ipconfig PROTO compatibility (#5437) + +klibc's ipconfig format [1] states that PROTO values 'none', 'off', +'static' and blank all mean no autoconfiguration, but cloud-init parser +is too strict and accepts only the first. + +Reference:https://github.com/canonical/cloud-init/commit/2c09f69173d448118b02e013518bf5f1674d3c1f +Conflict:not change tools/.github-cla-signers + +LP: #2065787 + +[1] https://git.kernel.org/pub/scm/libs/klibc/klibc.git/plain/usr/kinit/ipconfig/README.ipconfig +--- + cloudinit/net/cmdline.py | 3 +++ + tests/unittests/test_net.py | 39 +++++++++++++++++++++++++++++++++++-- + 2 files changed, 40 insertions(+), 2 deletions(-) + +diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py +index 7cdd428..89b9b24 100755 +--- a/cloudinit/net/cmdline.py ++++ b/cloudinit/net/cmdline.py +@@ -126,6 +126,9 @@ def _klibc_to_config_entry(content, mac_addrs=None): + else: + proto = 'none' + ++ if proto in ("static", "off"): ++ proto = "none" ++ + if proto not in ('none', 'dhcp', 'dhcp6'): + raise ValueError("Unexpected value for PROTO: %s" % proto) + +diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py +index 27b28ca..23e5c0e 100644 +--- a/tests/unittests/test_net.py ++++ b/tests/unittests/test_net.py +@@ -108,6 +108,37 @@ STATIC_EXPECTED_1 = { + 'address': '10.0.0.2'}], + } + ++STATIC_CONTENT_2 = """ ++DEVICE='eth1' ++PROTO='static' ++IPV4ADDR='10.0.0.2' ++IPV4BROADCAST='10.0.0.255' ++IPV4NETMASK='255.255.255.0' ++IPV4GATEWAY='10.0.0.1' ++IPV4DNS0='10.0.1.1' ++IPV4DNS1='0.0.0.0' ++HOSTNAME='foohost' ++UPTIME='21' ++DHCPLEASETIME='3600' ++DOMAINSEARCH='foo.com' ++""" ++ ++STATIC_CONTENT_3 = """ ++DEVICE='eth1' ++PROTO='off' ++IPV4ADDR='10.0.0.2' ++IPV4BROADCAST='10.0.0.255' ++IPV4NETMASK='255.255.255.0' ++IPV4GATEWAY='10.0.0.1' ++IPV4DNS0='10.0.1.1' ++IPV4DNS1='0.0.0.0' ++HOSTNAME='foohost' ++UPTIME='21' ++DHCPLEASETIME='3600' ++DOMAINSEARCH='foo.com' ++""" ++ ++ + V1_NAMESERVER_ALIAS = """ + config: + - id: eno1 +@@ -4615,8 +4646,12 @@ class TestCmdlineConfigParsing(CiTestCase): + self.assertEqual(found, ('eno1', DHCP6_EXPECTED_1)) + + def test_cmdline_convert_static(self): +- found = cmdline._klibc_to_config_entry(STATIC_CONTENT_1) +- self.assertEqual(found, ('eth1', STATIC_EXPECTED_1)) ++ found1 = cmdline._klibc_to_config_entry(STATIC_CONTENT_1) ++ assert found1 == ("eth1", STATIC_EXPECTED_1) ++ found2 = cmdline._klibc_to_config_entry(STATIC_CONTENT_2) ++ assert found2 == ("eth1", STATIC_EXPECTED_1) ++ found3 = cmdline._klibc_to_config_entry(STATIC_CONTENT_3) ++ assert found3 == ("eth1", STATIC_EXPECTED_1) + + def test_config_from_cmdline_net_cfg(self): + files = [] +-- +2.43.0 + diff --git a/backport-fix-openstack-Fix-bond-mac_address-5369.patch b/backport-fix-openstack-Fix-bond-mac_address-5369.patch new file mode 100644 index 0000000..41aca3e --- /dev/null +++ b/backport-fix-openstack-Fix-bond-mac_address-5369.patch @@ -0,0 +1,29 @@ +From 12f1198e8e9e884363b14eeaaf6eb69b7199c36a Mon Sep 17 00:00:00 2001 +From: Curt Moore +Date: Tue, 4 Jun 2024 14:37:43 -0500 +Subject: [PATCH] fix(openstack): Fix bond mac_address (#5369) + +Reference:https://github.com/canonical/cloud-init/commit/12f1198e8e9e884363b14eeaaf6eb69b7199c36a +Conflict:tools/.github-cla-signers not change. + +Fixes GH-5368 +--- + cloudinit/sources/helpers/openstack.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cloudinit/sources/helpers/openstack.py b/cloudinit/sources/helpers/openstack.py +index 4f566e6..bd5714f 100644 +--- a/cloudinit/sources/helpers/openstack.py ++++ b/cloudinit/sources/helpers/openstack.py +@@ -632,7 +632,7 @@ def convert_net_json(network_json=None, known_macs=None): + if link['type'] in ['bond']: + params = {} + if link_mac_addr: +- params['mac_address'] = link_mac_addr ++ cfg.update({"mac_address": link_mac_addr}) + for k, v in link.items(): + if k == 'bond_links': + continue +-- +2.43.0 + diff --git a/cloud-init.spec b/cloud-init.spec index 66b276a..3a42e5f 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -1,6 +1,6 @@ Name: cloud-init Version: 21.4 -Release: 28 +Release: 29 Summary: the defacto multi-distribution package that handles early initialization of a cloud instance. License: ASL 2.0 or GPLv3 URL: http://launchpad.net/cloud-init @@ -79,6 +79,8 @@ Patch6044: backport-ec2-Do-not-enable-dhcp6-on-EC2.patch Patch6045: backport-fix-azure-disable-use-dns-for-secondary-nics-5314.patch Patch6046: backport-fix-net-Make-duplicate-route-add-succeed.-5343.patch Patch6047: backport-fix-netplan-Fix-predictable-interface-rename-issue-5.patch +Patch6048: backport-fix-openstack-Fix-bond-mac_address-5369.patch +Patch6049: backport-fix-net-klibc-ipconfig-PROTO-compatibility-5437.patch BuildRequires: pkgconfig(systemd) python3-devel python3-setuptools systemd BuildRequires: iproute python3-configobj python3-httpretty >= 0.8.14-2 @@ -189,6 +191,13 @@ fi %exclude /usr/share/doc/* %changelog +* Thu Sep 5 2024 dongyuzhen - 21.4-29 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix(net): klibc ipconfig PROTO compatibility + fix(openstack): Fix bond mac_address + * Tue Jun 11 2024 shixuantong - 21.4-28 - Type:bugfix - CVE:NA -- Gitee