From 7e8425de529f00cb286e52db5c47e2cd12a62776 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Tue, 10 Jul 2018 15:09:40 +0200 Subject: [PATCH] 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 (cherry picked from commit 354140e8d3a9f0b72ba6da3011cc6c506c607f4f) --- libnm-core/nm-setting-connection.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 2649838c43..689ba79456 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -1051,15 +1051,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; }