From 8aa0b5b17d6c4d29bfa43c57e1be78bc8a29faf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Wed, 6 May 2015 10:59:11 +0200 Subject: [PATCH] ifcfg-rh: read/write autoconnect-slaves property as AUTOCONNECT_SLAVES AUTOCONNECT_SLAVES is an NetworkManager extension. initscripts always activate slaves with the master connection for bond and team, and doesn't activate automatically slaves for bridge. NetworkManager behaviour is controlled by this variable. If the variable is missing the default value from configuration file is used. (cherry picked from commit 2a497eeadc7e78e624941b2f6e61a0dcbe7da0d4) --- libnm-core/nm-setting-connection.c | 2 +- src/settings/plugins/ifcfg-rh/reader.c | 2 ++ src/settings/plugins/ifcfg-rh/writer.c | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 9749d31915..e727e97e0b 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -1563,7 +1563,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class) /* ---ifcfg-rh--- * property: autoconnect-slaves * variable: AUTOCONNECT-SLAVES(+) - * default: no + * default: missing variable means global default * description: Whether slaves of this connection should be auto-connected * when this connection is activated. * ---end--- diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 2ef2617f92..881d18ce4f 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -178,6 +178,8 @@ make_connection_setting (const char *file, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MIN, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_MAX, NM_SETTING_CONNECTION_AUTOCONNECT_PRIORITY_DEFAULT), + NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES, + svTrueValue (ifcfg, "AUTOCONNECT_SLAVES", NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_DEFAULT), NULL); value = svGetValue (ifcfg, "USERS", FALSE); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index d2b0c97008..cef990d819 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -1665,7 +1665,7 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) { guint32 n, i; GString *str; - const char *master; + const char *master, *type; char *tmp; gint i_int; @@ -1682,6 +1682,20 @@ write_connection_setting (NMSettingConnection *s_con, shvarFile *ifcfg) svSetValue (ifcfg, "AUTOCONNECT_PRIORITY", tmp, FALSE); g_free (tmp); + /* Only save the value for master connections */ + svSetValue (ifcfg, "AUTOCONNECT_SLAVES", NULL, FALSE); + type = nm_setting_connection_get_connection_type (s_con); + if ( !g_strcmp0 (type, NM_SETTING_BOND_SETTING_NAME) + || !g_strcmp0 (type, NM_SETTING_TEAM_SETTING_NAME) + || !g_strcmp0 (type, NM_SETTING_BRIDGE_SETTING_NAME)) { + NMSettingConnectionAutoconnectSlaves autoconnect_slaves; + autoconnect_slaves = nm_setting_connection_get_autoconnect_slaves (s_con); + svSetValue (ifcfg, "AUTOCONNECT_SLAVES", + autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_YES ? "yes" : + autoconnect_slaves == NM_SETTING_CONNECTION_AUTOCONNECT_SLAVES_NO ? "no" : NULL, + FALSE); + } + /* Permissions */ svSetValue (ifcfg, "USERS", NULL, FALSE); n = nm_setting_connection_get_num_permissions (s_con);