diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-07-10 15:09:40 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-07-10 18:30:34 +0200 |
commit | 354140e8d3a9f0b72ba6da3011cc6c506c607f4f (patch) | |
tree | bc98c69302e9a42181c391043dac9ad075d85c8f /libnm-core | |
parent | c866df799735a46689cb53e06c42b09a904062b6 (diff) | |
download | NetworkManager-354140e8d3a9f0b72ba6da3011cc6c506c607f4f.tar.gz |
setting-connection: fix ovs-port parent setting verification
$ nmcli c add type ovs-port ifname ovsport0
Error: Failed to add 'ovs-port-ovsport0' connection: connection.type:
Only 'ovs-port' connections can be enslaved to 'ovs-bridge'
nm_streq0() is not good here. It fails (with a wrong error message) even
when the slave_type is not set, which it shouldn't since slave_type can
be normalized. The real problem is the lack of the master property.
This fixes the condition:
$ nmcli c add type ovs-port ifname ovsport0
Error: Failed to add 'ovs-port-ovsport0' connection: connection.master:
A connection with a 'ovs-port' setting must have a master.
Corrects the error message:
$ nmcli c add con-name br0 type bridge
$ nmcli c add type ovs-port ifname ovsport0 parent br0
Error: Failed to add 'bridge-slave-ovsport0' connection: connection.slave-type:
'ovs-port' connections must be enslaved to 'ovs-bridge', not 'bridge'
And gets rid of a confusing nm_streq0 use when comparing the type, since
at that point type must not be NULL anymore.
Fixes: 4199c976dac21c22773e0c133c42c3b738ca76d2
Diffstat (limited to 'libnm-core')
-rw-r--r-- | libnm-core/nm-setting-connection.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index d8034d31ad..ac354fb944 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -1050,15 +1050,17 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } } - if ( nm_streq0 (type, NM_SETTING_OVS_PORT_SETTING_NAME) - && !nm_streq0 (slave_type, NM_SETTING_OVS_BRIDGE_SETTING_NAME)) { + if ( strcmp (type, NM_SETTING_OVS_PORT_SETTING_NAME) == 0 + && slave_type + && strcmp (slave_type, NM_SETTING_OVS_BRIDGE_SETTING_NAME) != 0) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("Only '%s' connections can be enslaved to '%s'"), + _("'%s' connections must be enslaved to '%s', not '%s'"), NM_SETTING_OVS_PORT_SETTING_NAME, - NM_SETTING_OVS_BRIDGE_SETTING_NAME); - g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_TYPE); + NM_SETTING_OVS_BRIDGE_SETTING_NAME, + slave_type); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE); return FALSE; } |