From 952f6a378721052afb4cb59c3afeab789f9d90d4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 9 Sep 2022 17:34:15 +0200 Subject: [PATCH 1/2] core: accept unmanaged parent if it's unrealized find_parent_device_for_connection() must return a parent device even if it's unrealized. In fact, callers already handle the unrealized case; in specific: - _internal_activate_device() will try to autoactivate a connection on the unrealized parent to realize it; - system_create_virtual_device()'s goal is to create a NMDevice object, so it doesn't matter whether the parent is realized or not. Relax the condition about managed-ness, since any unrealized device is also unmanaged. This change fixes the following scenario, where all profiles have autoconnect=no and autoconnect-slaves=yes: vrf0 -------------^---------------- | | | | bridge0 bond0.4000 | . bond0 <...................... ---^--- | | veth0 veth1 ----> = controller ....> = VLAN parent When profiles are added, unrealized devices are created for bond0 and bridge0, but not for bond0.4000 becase its parent is unrealized. Then the autoconnect-slaves machinery for vrf0 tries to activate all ports but fails for bond0.4000 because it can't find a device for it. https://bugzilla.redhat.com/show_bug.cgi?id=2101317 --- src/core/nm-manager.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 5bfefb7bcc..a38cae7209 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -1887,8 +1887,11 @@ find_parent_device_for_connection(NMManager *self, * with some known device. */ c_list_for_each_entry (candidate, &priv->devices_lst_head, devices_lst) { - /* Unmanaged devices are not compatible with any connection */ - if (!nm_device_get_managed(candidate, FALSE)) + /* For a realized device, check that it's managed; otherwise it's not + * compatible with any connection. If the device is unrealized then + * the managed state is meaningless. + */ + if (nm_device_is_real(candidate) && !nm_device_get_managed(candidate, FALSE)) continue; if (nm_device_get_settings_connection(candidate) == parent_connection) From ed29863645a487bdbe55c1ec2fbc74df2662e50f Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 15 Sep 2022 16:19:24 +0200 Subject: [PATCH 2/2] manager: fix syntax Remove the commas and use compound literals. --- src/core/nm-manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index a38cae7209..ea71af3370 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -4713,8 +4713,10 @@ find_slaves(NMManager *manager, } nm_assert(n_slaves < n_all_connections); - slaves[n_slaves].connection = candidate, slaves[n_slaves].device = slave_device, - n_slaves++; + slaves[n_slaves++] = (SlaveConnectionInfo){ + .connection = candidate, + .device = slave_device, + }; if (slave_device) g_hash_table_add(devices, slave_device);