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
This commit is contained in:
Beniamino Galvani
2017-12-19 15:56:12 +01:00
parent c72df50b6d
commit aa820e9386
4 changed files with 7 additions and 4 deletions

View File

@@ -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) */

View File

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

View File

@@ -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) \

View File

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