From 86f22ce8bacb663e41980ba2463c6ae51e513e89 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 18 May 2021 10:31:08 +0200 Subject: [PATCH] initrd: add a 'origin' user tag to connections Introduce a user tag key to indicate where the connection comes from. It would also be possible to have this as a standard property (as 'connection.origin'), but since this information can be considered 'meta-data' I think the user setting is more appropriate. --- src/libnm-core-intern/nm-core-internal.h | 5 +++++ src/nm-initrd-generator/nm-initrd-generator.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/libnm-core-intern/nm-core-internal.h b/src/libnm-core-intern/nm-core-internal.h index 4a8b9f66e7..e8199531d2 100644 --- a/src/libnm-core-intern/nm-core-internal.h +++ b/src/libnm-core-intern/nm-core-internal.h @@ -60,6 +60,7 @@ #include "nm-setting-team-port.h" #include "nm-setting-team.h" #include "nm-setting-tun.h" +#include "nm-setting-user.h" #include "nm-setting-veth.h" #include "nm-setting-vlan.h" #include "nm-setting-vpn.h" @@ -80,6 +81,10 @@ #include "libnm-core-aux-intern/nm-libnm-core-utils.h" #include "libnm-glib-aux/nm-value-type.h" +#define NM_USER_TAG_ORIGIN "org.freedesktop.NetworkManager.origin" + +/*****************************************************************************/ + /* NM_SETTING_COMPARE_FLAG_INFERRABLE: check whether a device-generated * connection can be replaced by a already-defined connection. This flag only * takes into account properties marked with the %NM_SETTING_PARAM_INFERRABLE diff --git a/src/nm-initrd-generator/nm-initrd-generator.c b/src/nm-initrd-generator/nm-initrd-generator.c index 490a4547d5..b78808b210 100644 --- a/src/nm-initrd-generator/nm-initrd-generator.c +++ b/src/nm-initrd-generator/nm-initrd-generator.c @@ -35,6 +35,14 @@ output_conn(gpointer key, gpointer value, gpointer user_data) gs_free char * data = NULL; gs_free_error GError *error = NULL; gsize len; + NMSetting * setting; + + setting = nm_setting_user_new(); + nm_connection_add_setting(connection, setting); + nm_setting_user_set_data(NM_SETTING_USER(setting), + NM_USER_TAG_ORIGIN, + "nm-initrd-generator", + NULL); if (!nm_connection_normalize(connection, NULL, NULL, &error)) goto err_out;