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.
This commit is contained in:
Thomas Haller 2021-07-02 09:24:03 +02:00
parent 93c6697413
commit 6185502ee9
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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;