diff options
author | Dan Williams <dcbw@redhat.com> | 2014-03-26 17:08:07 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-03-26 17:08:07 -0500 |
commit | 8c797f98f00c4aaa75a9dca75617d0d18f083277 (patch) | |
tree | 936896a2d1dc5834faa52c6b1b7afc3598138bd4 | |
parent | 4dba720d8c883549e57a292a236c8ea44e1e0bca (diff) | |
download | NetworkManager-8c797f98f00c4aaa75a9dca75617d0d18f083277.tar.gz |
libnm-util: if one of slave-type and master is set, both must be set
slave-type is required because master may refer to an interface that
is not yet created, and thus the details of the slave connection are
ambiguous. While we can auto-detect slave-type in some cases (like
if a bridge-port setting exists, then slave-type=bridge), that
functionality isn't implemented yet and doesn't work for all cases.
So for the moment, require that both slave-type and master are
set if one is set.
-rw-r--r-- | libnm-util/nm-setting-connection.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index 4e793a2e0a..3fbd33cbdb 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -861,6 +861,21 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + /* If one of master or slave_type is set, the other must also be set */ + if ((priv->master || priv->slave_type) && !(priv->master && priv->slave_type)) { + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY, + _("%s is required if %s is set"), + priv->master ? NM_SETTING_CONNECTION_SLAVE_TYPE : NM_SETTING_CONNECTION_MASTER, + priv->master ? NM_SETTING_CONNECTION_MASTER : NM_SETTING_CONNECTION_SLAVE_TYPE); + /* Invalid property is the one that is *not* set */ + g_prefix_error (error, "%s.%s: ", + NM_SETTING_CONNECTION_SETTING_NAME, + priv->master ? NM_SETTING_CONNECTION_SLAVE_TYPE : NM_SETTING_CONNECTION_MASTER); + return FALSE; + } + is_slave = ( !g_strcmp0 (priv->slave_type, NM_SETTING_BOND_SETTING_NAME) || !g_strcmp0 (priv->slave_type, NM_SETTING_BRIDGE_SETTING_NAME) || !g_strcmp0 (priv->slave_type, NM_SETTING_TEAM_SETTING_NAME)); |