diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2015-04-20 10:08:30 +0200 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2015-04-20 10:13:12 +0200 |
commit | 80a72a40928914820bda1a1039c4ffa283d56830 (patch) | |
tree | 8cf66509b5c1edee84e4cd5278c25e980a6418f5 | |
parent | 8257940606b1ad3cd333974a0c5c52afd4281a8b (diff) | |
parent | 1b9c1ed6d38b408a17abe77f46de1708b27900f0 (diff) | |
download | NetworkManager-80a72a40928914820bda1a1039c4ffa283d56830.tar.gz |
merge: add new nm-plugin-missing property for devices (bgo #747851)
The property indicates that a device type is supported by NetworkManager, but
the plugin for handling the device is missing.
The property is accessible through D-Bus API, libnm and nmcli.
https://bugzilla.gnome.org/show_bug.cgi?id=747851
-rw-r--r-- | clients/cli/devices.c | 106 | ||||
-rw-r--r-- | introspection/nm-device.xml | 6 | ||||
-rw-r--r-- | libnm/libnm.ver | 1 | ||||
-rw-r--r-- | libnm/nm-device.c | 39 | ||||
-rw-r--r-- | libnm/nm-device.h | 3 | ||||
-rw-r--r-- | src/devices/nm-device.c | 35 | ||||
-rw-r--r-- | src/devices/nm-device.h | 4 | ||||
-rw-r--r-- | src/nm-manager.c | 4 |
8 files changed, 153 insertions, 45 deletions
diff --git a/clients/cli/devices.c b/clients/cli/devices.c index c50a8539ca..11c584d2a1 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -58,30 +58,32 @@ static NmcOutputField nmc_fields_dev_show_general[] = { {"NAME", N_("NAME"), 10}, /* 0 */ {"DEVICE", N_("DEVICE"), 10}, /* 1 */ {"TYPE", N_("TYPE"), 17}, /* 2 */ - {"VENDOR", N_("VENDOR"), 20}, /* 3 */ - {"PRODUCT", N_("PRODUCT"), 50}, /* 4 */ - {"DRIVER", N_("DRIVER"), 9}, /* 5 */ - {"DRIVER-VERSION", N_("DRIVER-VERSION"), 18}, /* 6 */ - {"FIRMWARE-VERSION", N_("FIRMWARE-VERSION"), 18}, /* 7 */ - {"HWADDR", N_("HWADDR"), 19}, /* 8 */ - {"MTU", N_("MTU"), 10}, /* 9 */ - {"STATE", N_("STATE"), 14}, /* 10 */ - {"REASON", N_("REASON"), 25}, /* 11 */ - {"UDI", N_("UDI"), 64}, /* 12 */ - {"IP-IFACE", N_("IP-IFACE"), 10}, /* 13 */ - {"IS-SOFTWARE", N_("IS-SOFTWARE"), 15}, /* 14 */ - {"NM-MANAGED", N_("NM-MANAGED"), 15}, /* 15 */ - {"AUTOCONNECT", N_("AUTOCONNECT"), 15}, /* 16 */ - {"FIRMWARE-MISSING", N_("FIRMWARE-MISSING"), 18}, /* 17 */ - {"PHYS-PORT-ID", N_("PHYS-PORT-ID"), 18}, /* 18 */ - {"CONNECTION", N_("CONNECTION"), 20}, /* 19 */ - {"CON-UUID", N_("CON-UUID"), 38}, /* 20 */ - {"CON-PATH", N_("CON-PATH"), 51}, /* 21 */ + {"NM-TYPE", N_("NM-TYPE"), 17}, /* 3 */ + {"VENDOR", N_("VENDOR"), 20}, /* 4 */ + {"PRODUCT", N_("PRODUCT"), 50}, /* 5 */ + {"DRIVER", N_("DRIVER"), 9}, /* 6 */ + {"DRIVER-VERSION", N_("DRIVER-VERSION"), 18}, /* 7 */ + {"FIRMWARE-VERSION", N_("FIRMWARE-VERSION"), 18}, /* 8 */ + {"HWADDR", N_("HWADDR"), 19}, /* 9 */ + {"MTU", N_("MTU"), 10}, /* 10 */ + {"STATE", N_("STATE"), 14}, /* 11 */ + {"REASON", N_("REASON"), 25}, /* 12 */ + {"UDI", N_("UDI"), 64}, /* 13 */ + {"IP-IFACE", N_("IP-IFACE"), 10}, /* 14 */ + {"IS-SOFTWARE", N_("IS-SOFTWARE"), 15}, /* 15 */ + {"NM-MANAGED", N_("NM-MANAGED"), 15}, /* 16 */ + {"AUTOCONNECT", N_("AUTOCONNECT"), 15}, /* 17 */ + {"FIRMWARE-MISSING", N_("FIRMWARE-MISSING"), 18}, /* 18 */ + {"NM-PLUGIN-MISSING", N_("NM-PLUGIN-MISSING"), 18}, /* 19 */ + {"PHYS-PORT-ID", N_("PHYS-PORT-ID"), 18}, /* 20 */ + {"CONNECTION", N_("CONNECTION"), 20}, /* 21 */ + {"CON-UUID", N_("CON-UUID"), 38}, /* 22 */ + {"CON-PATH", N_("CON-PATH"), 51}, /* 23 */ {NULL, NULL, 0} }; -#define NMC_FIELDS_DEV_SHOW_GENERAL_ALL "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,DRIVER-VERSION,FIRMWARE-VERSION,HWADDR,MTU,STATE,REASON,"\ - "UDI,IP-IFACE,IS-SOFTWARE,NM-MANAGED,AUTOCONNECT,FIRMWARE-MISSING,PHYS-PORT-ID,"\ - "CONNECTION,CON-UUID,CON-PATH" +#define NMC_FIELDS_DEV_SHOW_GENERAL_ALL "NAME,DEVICE,TYPE,NM-TYPE,VENDOR,PRODUCT,DRIVER,DRIVER-VERSION,FIRMWARE-VERSION,HWADDR,MTU,"\ + "STATE,REASON,UDI,IP-IFACE,IS-SOFTWARE,NM-MANAGED,AUTOCONNECT,FIRMWARE-MISSING,NM-PLUGIN-MISSING,"\ + "PHYS-PORT-ID,CONNECTION,CON-UUID,CON-PATH" #define NMC_FIELDS_DEV_SHOW_GENERAL_COMMON "NAME,DEVICE,TYPE,VENDOR,PRODUCT,DRIVER,HWADDR,STATE" /* Available fields for 'device show' - CONNECTIONS part */ @@ -822,25 +824,27 @@ show_device_info (NMDevice *device, NmCli *nmc) set_val_strc (arr, 0, nmc_fields_dev_show_sections[0].name); /* "GENERAL"*/ set_val_strc (arr, 1, nm_device_get_iface (device)); set_val_strc (arr, 2, nm_device_get_type_description (device)); - set_val_strc (arr, 3, nm_device_get_vendor (device)); - set_val_strc (arr, 4, nm_device_get_product (device)); - set_val_strc (arr, 5, nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)")); - set_val_strc (arr, 6, nm_device_get_driver_version (device)); - set_val_strc (arr, 7, nm_device_get_firmware_version (device)); - set_val_strc (arr, 8, hwaddr ? hwaddr : _("(unknown)")); - set_val_str (arr, 9, mtu_str); - set_val_str (arr, 10, state_str); - set_val_str (arr, 11, reason_str); - set_val_strc (arr, 12, nm_device_get_udi (device)); - set_val_strc (arr, 13, nm_device_get_ip_iface (device)); - set_val_strc (arr, 14, nm_device_is_software (device) ? _("yes") : _("no")); - set_val_strc (arr, 15, nm_device_get_managed (device) ? _("yes") : _("no")); - set_val_strc (arr, 16, nm_device_get_autoconnect (device) ? _("yes") : _("no")); - set_val_strc (arr, 17, nm_device_get_firmware_missing (device) ? _("yes") : _("no")); - set_val_strc (arr, 18, nm_device_get_physical_port_id (device)); - set_val_strc (arr, 19, get_active_connection_id (device)); - set_val_strc (arr, 20, acon ? nm_active_connection_get_uuid (acon) : NULL); - set_val_strc (arr, 21, acon ? nm_object_get_path (NM_OBJECT (acon)) : NULL); + set_val_strc (arr, 3, G_OBJECT_TYPE_NAME (device)); + set_val_strc (arr, 4, nm_device_get_vendor (device)); + set_val_strc (arr, 5, nm_device_get_product (device)); + set_val_strc (arr, 6, nm_device_get_driver (device) ? nm_device_get_driver (device) : _("(unknown)")); + set_val_strc (arr, 7, nm_device_get_driver_version (device)); + set_val_strc (arr, 8, nm_device_get_firmware_version (device)); + set_val_strc (arr, 9, hwaddr ? hwaddr : _("(unknown)")); + set_val_str (arr, 10, mtu_str); + set_val_str (arr, 11, state_str); + set_val_str (arr, 12, reason_str); + set_val_strc (arr, 13, nm_device_get_udi (device)); + set_val_strc (arr, 14, nm_device_get_ip_iface (device)); + set_val_strc (arr, 15, nm_device_is_software (device) ? _("yes") : _("no")); + set_val_strc (arr, 16, nm_device_get_managed (device) ? _("yes") : _("no")); + set_val_strc (arr, 17, nm_device_get_autoconnect (device) ? _("yes") : _("no")); + set_val_strc (arr, 18, nm_device_get_firmware_missing (device) ? _("yes") : _("no")); + set_val_strc (arr, 19, nm_device_get_nm_plugin_missing (device) ? _("yes") : _("no")); + set_val_strc (arr, 20, nm_device_get_physical_port_id (device)); + set_val_strc (arr, 21, get_active_connection_id (device)); + set_val_strc (arr, 22, acon ? nm_active_connection_get_uuid (acon) : NULL); + set_val_strc (arr, 23, acon ? nm_object_get_path (NM_OBJECT (acon)) : NULL); g_ptr_array_add (nmc->output_data, arr); print_data (nmc); /* Print all data */ @@ -2043,7 +2047,13 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv) show_access_point_info (device, nmc); } } else { - g_string_printf (nmc->return_text, _("Error: Device '%s' is not a Wi-Fi device."), ifname); + const char *err_msg; + if ( nm_device_get_device_type (device) == NM_DEVICE_TYPE_GENERIC + && g_strcmp0 (nm_device_get_type_description (device), "wifi") == 0) + err_msg = _("Error: Device '%s' was not recognized as a Wi-Fi device, check NetworkManager Wi-Fi plugin."); + else + err_msg = _("Error: Device '%s' is not a Wi-Fi device."); + g_string_printf (nmc->return_text, err_msg, ifname); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; goto error; } @@ -2523,9 +2533,15 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv) device = find_wifi_device_by_iface (devices, ifname, &devices_idx); if (!device) { - if (ifname) - g_string_printf (nmc->return_text, _("Error: Device '%s' is not a Wi-Fi device."), ifname); - else + if (ifname) { + const char *err_msg; + if ( nm_device_get_device_type (device) == NM_DEVICE_TYPE_GENERIC + && g_strcmp0 (nm_device_get_type_description (device), "wifi") == 0) + err_msg = _("Error: Device '%s' was not recognized as a Wi-Fi device, check NetworkManager Wi-Fi plugin."); + else + err_msg = _("Error: Device '%s' is not a Wi-Fi device."); + g_string_printf (nmc->return_text, err_msg, ifname); + } else g_string_printf (nmc->return_text, _("Error: No Wi-Fi device found.")); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; goto error; diff --git a/introspection/nm-device.xml b/introspection/nm-device.xml index 9e78856cf5..7aef2f35b1 100644 --- a/introspection/nm-device.xml +++ b/introspection/nm-device.xml @@ -116,6 +116,12 @@ its operation. </tp:docstring> </property> + <property name="NmPluginMissing" type="b" access="read"> + <tp:docstring> + If TRUE, indicates the NetworkManager plugin for the device is likely + missing or misconfigured. + </tp:docstring> + </property> <property name="DeviceType" type="u" access="read" tp:type="NM_DEVICE_TYPE"> <tp:docstring> The general type of the network device; ie Ethernet, WiFi, etc. diff --git a/libnm/libnm.ver b/libnm/libnm.ver index 44b83f6ecb..0b7bacc27e 100644 --- a/libnm/libnm.ver +++ b/libnm/libnm.ver @@ -847,6 +847,7 @@ local: libnm_1_2_0 { global: + nm_device_get_nm_plugin_missing; nm_setting_802_1x_check_cert_scheme; nm_setting_bridge_get_multicast_snooping; nm_setting_wireless_get_powersave; diff --git a/libnm/nm-device.c b/libnm/nm-device.c index 96322e6392..48d0f42b50 100644 --- a/libnm/nm-device.c +++ b/libnm/nm-device.c @@ -84,6 +84,7 @@ typedef struct { NMDeviceCapabilities capabilities; gboolean managed; gboolean firmware_missing; + gboolean nm_plugin_missing; gboolean autoconnect; NMIPConfig *ip4_config; NMDhcpConfig *dhcp4_config; @@ -116,6 +117,7 @@ enum { PROP_MANAGED, PROP_AUTOCONNECT, PROP_FIRMWARE_MISSING, + PROP_NM_PLUGIN_MISSING, PROP_IP4_CONFIG, PROP_DHCP4_CONFIG, PROP_IP6_CONFIG, @@ -183,6 +185,7 @@ init_dbus (NMObject *object) { NM_DEVICE_MANAGED, &priv->managed }, { NM_DEVICE_AUTOCONNECT, &priv->autoconnect }, { NM_DEVICE_FIRMWARE_MISSING, &priv->firmware_missing }, + { NM_DEVICE_NM_PLUGIN_MISSING, &priv->nm_plugin_missing }, { NM_DEVICE_IP4_CONFIG, &priv->ip4_config, NULL, NM_TYPE_IP4_CONFIG }, { NM_DEVICE_DHCP4_CONFIG, &priv->dhcp4_config, NULL, NM_TYPE_DHCP4_CONFIG }, { NM_DEVICE_IP6_CONFIG, &priv->ip6_config, NULL, NM_TYPE_IP6_CONFIG }, @@ -413,6 +416,9 @@ get_property (GObject *object, case PROP_FIRMWARE_MISSING: g_value_set_boolean (value, nm_device_get_firmware_missing (device)); break; + case PROP_NM_PLUGIN_MISSING: + g_value_set_boolean (value, nm_device_get_nm_plugin_missing (device)); + break; case PROP_IP4_CONFIG: g_value_set_object (value, nm_device_get_ip4_config (device)); break; @@ -646,6 +652,21 @@ nm_device_class_init (NMDeviceClass *device_class) G_PARAM_STATIC_STRINGS)); /** + * NMDevice:nm-plugin-missing: + * + * When %TRUE indicates that the NetworkManager plugin for the device + * is not installed. + * + * Since: 1.2 + **/ + g_object_class_install_property + (object_class, PROP_NM_PLUGIN_MISSING, + g_param_spec_boolean (NM_DEVICE_NM_PLUGIN_MISSING, "", "", + FALSE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); + + /** * NMDevice:ip4-config: * * The #NMIP4Config of the device. @@ -1105,6 +1126,24 @@ nm_device_get_firmware_missing (NMDevice *device) } /** + * nm_device_get_nm_plugin_missing: + * @device: a #NMDevice + * + * Indicates that the NetworkManager plugin for the device is not installed. + * + * Returns: %TRUE if the device plugin not installed. + * + * Since: 1.2 + **/ +gboolean +nm_device_get_nm_plugin_missing (NMDevice *device) +{ + g_return_val_if_fail (NM_IS_DEVICE (device), FALSE); + + return NM_DEVICE_GET_PRIVATE (device)->nm_plugin_missing; +} + +/** * nm_device_get_ip4_config: * @device: a #NMDevice * diff --git a/libnm/nm-device.h b/libnm/nm-device.h index 5cc3735695..91cf13b1a0 100644 --- a/libnm/nm-device.h +++ b/libnm/nm-device.h @@ -48,6 +48,7 @@ G_BEGIN_DECLS #define NM_DEVICE_MANAGED "managed" #define NM_DEVICE_AUTOCONNECT "autoconnect" #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing" +#define NM_DEVICE_NM_PLUGIN_MISSING "nm-plugin-missing" #define NM_DEVICE_IP4_CONFIG "ip4-config" #define NM_DEVICE_DHCP4_CONFIG "dhcp4-config" #define NM_DEVICE_IP6_CONFIG "ip6-config" @@ -104,6 +105,8 @@ gboolean nm_device_get_managed (NMDevice *device); gboolean nm_device_get_autoconnect (NMDevice *device); void nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect); gboolean nm_device_get_firmware_missing (NMDevice *device); +NM_AVAILABLE_IN_1_2 +gboolean nm_device_get_nm_plugin_missing (NMDevice *device); NMIPConfig * nm_device_get_ip4_config (NMDevice *device); NMDhcpConfig * nm_device_get_dhcp4_config (NMDevice *device); NMIPConfig * nm_device_get_ip6_config (NMDevice *device); diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 85050154d3..05392392c1 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -120,6 +120,7 @@ enum { PROP_MANAGED, PROP_AUTOCONNECT, PROP_FIRMWARE_MISSING, + PROP_NM_PLUGIN_MISSING, PROP_TYPE_DESC, PROP_RFKILL_TYPE, PROP_IFINDEX, @@ -197,6 +198,7 @@ typedef struct { char * firmware_version; RfKillType rfkill_type; gboolean firmware_missing; + gboolean nm_plugin_missing; GHashTable * available_connections; char * hw_addr; guint hw_addr_len; @@ -6691,6 +6693,26 @@ nm_device_get_firmware_missing (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->firmware_missing; } +void +nm_device_set_nm_plugin_missing (NMDevice *self, gboolean new_missing) +{ + NMDevicePrivate *priv; + + g_return_if_fail (NM_IS_DEVICE (self)); + + priv = NM_DEVICE_GET_PRIVATE (self); + if (priv->nm_plugin_missing != new_missing) { + priv->nm_plugin_missing = new_missing; + g_object_notify (G_OBJECT (self), NM_DEVICE_NM_PLUGIN_MISSING); + } +} + +gboolean +nm_device_get_nm_plugin_missing (NMDevice *self) +{ + return NM_DEVICE_GET_PRIVATE (self)->nm_plugin_missing; +} + static NMIP4Config * find_ip4_lease_config (NMDevice *self, NMConnection *connection, @@ -8690,6 +8712,9 @@ set_property (GObject *object, guint prop_id, case PROP_FIRMWARE_MISSING: priv->firmware_missing = g_value_get_boolean (value); break; + case PROP_NM_PLUGIN_MISSING: + priv->nm_plugin_missing = g_value_get_boolean (value); + break; case PROP_DEVICE_TYPE: g_return_if_fail (priv->type == NM_DEVICE_TYPE_UNKNOWN); priv->type = g_value_get_uint (value); @@ -8835,6 +8860,9 @@ get_property (GObject *object, guint prop_id, case PROP_FIRMWARE_MISSING: g_value_set_boolean (value, priv->firmware_missing); break; + case PROP_NM_PLUGIN_MISSING: + g_value_set_boolean (value, priv->nm_plugin_missing); + break; case PROP_TYPE_DESC: g_value_set_string (value, priv->type_desc); break; @@ -9061,6 +9089,13 @@ nm_device_class_init (NMDeviceClass *klass) G_PARAM_STATIC_STRINGS)); g_object_class_install_property + (object_class, PROP_NM_PLUGIN_MISSING, + g_param_spec_boolean (NM_DEVICE_NM_PLUGIN_MISSING, "", "", + FALSE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property (object_class, PROP_TYPE_DESC, g_param_spec_string (NM_DEVICE_TYPE_DESC, "", "", NULL, diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index fb46c80dc0..ad6de877ff 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -54,6 +54,7 @@ #define NM_DEVICE_MANAGED "managed" #define NM_DEVICE_AUTOCONNECT "autoconnect" #define NM_DEVICE_FIRMWARE_MISSING "firmware-missing" +#define NM_DEVICE_NM_PLUGIN_MISSING "nm-plugin-missing" #define NM_DEVICE_AVAILABLE_CONNECTIONS "available-connections" #define NM_DEVICE_PHYSICAL_PORT_ID "physical-port-id" #define NM_DEVICE_MTU "mtu" @@ -389,6 +390,9 @@ void nm_device_queue_state (NMDevice *self, NMDeviceStateReason reason); gboolean nm_device_get_firmware_missing (NMDevice *self); +gboolean nm_device_get_nm_plugin_missing (NMDevice *self); +void nm_device_set_nm_plugin_missing (NMDevice *self, + gboolean missing); void nm_device_steal_connection (NMDevice *device, NMConnection *connection); diff --git a/src/nm-manager.c b/src/nm-manager.c index c9f126215a..d4312a2084 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -2156,6 +2156,7 @@ platform_link_added (NMManager *self, NMDevice *device = NULL; GSList *iter; GError *error = NULL; + gboolean nm_plugin_missing = FALSE; g_return_if_fail (ifindex > 0); @@ -2205,6 +2206,7 @@ platform_link_added (NMManager *self, case NM_LINK_TYPE_WIFI: nm_log_info (LOGD_HW, "(%s): '%s' plugin not available; creating generic device", plink->name, plink->type_name); + nm_plugin_missing = TRUE; /* fall through */ default: device = nm_device_generic_new (plink); @@ -2213,6 +2215,8 @@ platform_link_added (NMManager *self, } if (device) { + if (nm_plugin_missing) + nm_device_set_nm_plugin_missing (device, TRUE); add_device (self, device, plink->type != NM_LINK_TYPE_LOOPBACK); g_object_unref (device); } |