From aa820e93864a452ec5089381a332be106f4d2c69 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 19 Dec 2017 15:56:12 +0100 Subject: [PATCH] all: add more meaningful error code for unsupported IP method Add a new device state reason code for unsupported IP method. It is returned, for example, when users select manual IP configuration for WWAN connections: # nmcli connection mod Gsm ipv4.method manual ipv4.address 1.2.3.4/32 # nmcli connection up Gsm Error: Connection activation failed: The selected IP method is not supported compared to the old: Error: Connection activation failed: IP configuration could not be reserved (no available address, timeout, etc.) Note that we could instead fail the connection validation if the method is not supported by the connection type, but adding such limitation now could make existing connections invalid. https://bugzilla.redhat.com/show_bug.cgi?id=1459529 --- clients/common/nm-client-utils.c | 3 ++- libnm-core/nm-dbus-interface.h | 2 ++ src/devices/nm-device.c | 1 + src/devices/wwan/nm-modem.c | 5 ++--- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clients/common/nm-client-utils.c b/clients/common/nm-client-utils.c index 6422164600..194271a86c 100644 --- a/clients/common/nm-client-utils.c +++ b/clients/common/nm-client-utils.c @@ -392,7 +392,8 @@ nmc_device_reason_to_string (NMDeviceStateReason reason) return _("OpenVSwitch database connection failed"); case NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE: return _("A duplicate IP address was detected"); - + case NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED: + return _("The selected IP method is not supported"); } /* TRANSLATORS: Unknown reason for a device state change (NMDeviceStateReason) */ diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h index 4c586d5d8d..b2e448dfa3 100644 --- a/libnm-core/nm-dbus-interface.h +++ b/libnm-core/nm-dbus-interface.h @@ -553,6 +553,7 @@ typedef enum { * @NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED: the device parent's management changed * @NM_DEVICE_STATE_REASON_OVSDB_FAILED: problem communicating with OpenVSwitch database * @NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE: a duplicate IP address was detected + * @NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED: The selected IP method is not supported * * Device state change reason codes */ @@ -622,6 +623,7 @@ typedef enum { NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62, NM_DEVICE_STATE_REASON_OVSDB_FAILED = 63, NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE = 64, + NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED = 65, } NMDeviceStateReason; /** diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b4a830fe99..8168957dd4 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -656,6 +656,7 @@ NM_UTILS_LOOKUP_STR_DEFINE (nm_device_state_reason_to_str, NMDeviceStateReason, NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED, "parent-managed-changed"), NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_OVSDB_FAILED, "ovsdb-failed"), NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE, "ip-address-duplicate"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED, "ip-method-unsupported"), ); #define reason_to_string(reason) \ diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 1c32791f11..010a2b604f 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -685,9 +685,8 @@ nm_modem_stage3_ip4_config_start (NMModem *self, return NM_ACT_STAGE_RETURN_SUCCESS; if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0) { - _LOGW ("unhandled WWAN IPv4 method '%s'; will fail", - method); - NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + _LOGE ("unhandled WWAN IPv4 method '%s'; will fail", method); + NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED); return NM_ACT_STAGE_RETURN_FAILURE; }