From c274b3bb598b65d394486aa55274f5dd124da61c Mon Sep 17 00:00:00 2001 From: Danilo Egea Gondolfo Date: Mon, 2 Sep 2024 16:44:53 +0100 Subject: [PATCH] parse-nm: account for veth and dummy when checking for virtual types The new types DUMMY and VETH were added to the types enum after the generic type NM. In order to build the netdef ID, it checked if the interface was virtual but it wouldn't consider DUMMY and VETH. Because of that, when these types of interfaces are created via Network Manager, their netdef IDs will be the connection UUID. For virtual devices we want it to be the interface name. --- include/types.h | 1 + src/parse-nm.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/types.h b/include/types.h index 6273c9b3f..df4ef1954 100644 --- a/include/types.h +++ b/include/types.h @@ -65,6 +65,7 @@ typedef enum { * requires links to another netdef (such as vlan_link) * but it's not strictly mandatory * It's intended to be used only when renderer is NetworkManager + * Keep the PLACEHOLDER_ and MAX_ elements at the end of the enum */ NETPLAN_DEF_TYPE_NM_PLACEHOLDER_, NETPLAN_DEF_TYPE_MAX_ diff --git a/src/parse-nm.c b/src/parse-nm.c index 215916fd1..0311cc80d 100644 --- a/src/parse-nm.c +++ b/src/parse-nm.c @@ -668,7 +668,9 @@ netplan_parser_load_keyfile(NetplanParser* npp, const char* filename, GError** e nd_id = g_strdup(netdef_id); if (g_strcmp0(netdef_id, tmp_str) == 0) _kf_clear_key(kf, "connection", "interface-name"); - } else if (tmp_str && nd_type >= NETPLAN_DEF_TYPE_VIRTUAL && nd_type < NETPLAN_DEF_TYPE_NM) { + } else if (tmp_str && nd_type != NETPLAN_DEF_TYPE_NM + && nd_type >= NETPLAN_DEF_TYPE_VIRTUAL + && nd_type < NETPLAN_DEF_TYPE_NM_PLACEHOLDER_) { /* netdef ID equals "interface-name" for virtual devices (bridge/bond/...) */ nd_id = g_strdup(tmp_str); _kf_clear_key(kf, "connection", "interface-name");