From 6185502ee9315ea88f4d0c6839ba13736c35233f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 2 Jul 2021 09:24:03 +0200 Subject: [PATCH] libnm: let nm_connection_normalize() default to ipv{4,6}.method={disabled,ignore} on dummy devices On a dummy device we cannot do DHCP. The default makes no sense. This also affects `nmcli device connect dummy0`. We want that the generated profile gets normalized to no IP configuration, because DHCP/autoconf is not working on a dummy device. Currently there is another problem and that command is not working. But if that other problem would be fixed, then the generated profile would try to do DHCP, fail, and retry endlessly (with backoff pauses). That endless loop is a third problem. If `nmcli device connect` creates a new profile, then upon failure the profile should be deleted again. But these two other problems are not solved hereby. --- src/libnm-core-impl/nm-connection.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index f90b81de1d..60105f05f8 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -1216,7 +1216,11 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters) NM_CONNECTION_NORMALIZE_PARAM_IP4_CONFIG_METHOD); } if (!default_ip4_method) { - if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME)) + const char *type = nm_connection_get_connection_type(self); + + if (NM_IN_STRSET(type, + NM_SETTING_WIREGUARD_SETTING_NAME, + NM_SETTING_DUMMY_SETTING_NAME)) default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_DISABLED; else default_ip4_method = NM_SETTING_IP4_CONFIG_METHOD_AUTO; @@ -1270,7 +1274,11 @@ _normalize_ip_config(NMConnection *self, GHashTable *parameters) NM_CONNECTION_NORMALIZE_PARAM_IP6_CONFIG_METHOD); } if (!default_ip6_method) { - if (nm_connection_is_type(self, NM_SETTING_WIREGUARD_SETTING_NAME)) + const char *type = nm_connection_get_connection_type(self); + + if (NM_IN_STRSET(type, + NM_SETTING_WIREGUARD_SETTING_NAME, + NM_SETTING_DUMMY_SETTING_NAME)) default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_IGNORE; else default_ip6_method = NM_SETTING_IP6_CONFIG_METHOD_AUTO;