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 2a497eeadc)
This commit is contained in:
Jiří Klimeš 2015-05-06 10:59:11 +02:00
parent 408b631673
commit 8aa0b5b17d
3 changed files with 18 additions and 2 deletions

View file

@ -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---

View file

@ -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);

View file

@ -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);