From 8c797f98f00c4aaa75a9dca75617d0d18f083277 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 26 Mar 2014 17:08:07 -0500 Subject: 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. --- libnm-util/nm-setting-connection.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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)); -- cgit v1.2.1