summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-06-30 14:04:45 +0200
committerThomas Haller <thaller@redhat.com>2021-07-08 17:20:15 +0200
commita32d04f0bb9b106a602b384defd7dfb09d208fe3 (patch)
treea98bbbc3fe600f0d9d6a231b854eae84098a7e61
parentf9b43ed7d4bbc2de8fdca4e1e4a9e7fe458e1c58 (diff)
downloadNetworkManager-a32d04f0bb9b106a602b384defd7dfb09d208fe3.tar.gz
core: fix `nmcli device connect dummy0` to add-and-activate dummy profile
$ ip link add dd type dummy $ nmcli device DEVICE TYPE STATE CONNECTION ... dd dummy unmanaged -- $ nmcli device connect dd Error: Failed to add/activate new connection: A 'dummy' setting is required. There are two problems here. The first is that we don't pass the interface name to nm_utils_complete_generic(), but dummy devices require "connection.interface-name" set. As a consequence, nm_utils_complete_generic() fails to normalize the connection and there is no [dummy] setting. Which then results in a failure with complete_connection(). The important part of the fix is to set the interface name. Once we do that, nm_utils_complete_generic() should be able to add the [dummy] setting and the second part is not strictly necessary. Still, the job of complete_connection() is not to verify the profile but to create it with best effort. If a [dummy] setting is still missing, we should just add it. The caller will then again try to normalize/verify the connection, and that might then fail -- but this time not with the wrong error message about missing 'dummy' setting. https://bugzilla.redhat.com/show_bug.cgi?id=1763054
-rw-r--r--src/core/devices/nm-device-dummy.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/core/devices/nm-device-dummy.c b/src/core/devices/nm-device-dummy.c
index 488f0ba003..7668be7b1b 100644
--- a/src/core/devices/nm-device-dummy.c
+++ b/src/core/devices/nm-device-dummy.c
@@ -57,16 +57,13 @@ complete_connection(NMDevice * device,
NULL,
_("Dummy connection"),
NULL,
- NULL,
+ nm_device_get_ip_iface(device),
TRUE);
s_dummy = nm_connection_get_setting_dummy(connection);
if (!s_dummy) {
- g_set_error_literal(error,
- NM_DEVICE_ERROR,
- NM_DEVICE_ERROR_INVALID_CONNECTION,
- "A 'dummy' setting is required.");
- return FALSE;
+ s_dummy = NM_SETTING_DUMMY(nm_setting_dummy_new());
+ nm_connection_add_setting(connection, NM_SETTING(s_dummy));
}
return TRUE;