diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index bc7ebcb..423cc74 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2150,7 +2150,10 @@ can_auto_connect (NMDevice *self, s_con = nm_connection_get_setting_connection (connection); if (!nm_setting_connection_get_autoconnect (s_con)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [device] not autoconnect", nm_device_get_iface (self)); return FALSE; +} return nm_device_check_connection_available (self, connection, NM_DEVICE_CHECK_CON_AVAILABLE_NONE, NULL); } @@ -7765,24 +7768,40 @@ nm_device_check_connection_available (NMDevice *self, const char *specific_object) { NMDeviceState state; + gboolean avail; state = nm_device_get_state (self); if (state < NM_DEVICE_STATE_UNMANAGED) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [device] < unmanaged", nm_device_get_iface (self)); return FALSE; +} if ( state < NM_DEVICE_STATE_UNAVAILABLE && nm_device_get_unmanaged_flag (self, NM_UNMANAGED_ALL & ~NM_UNMANAGED_DEFAULT)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [device] < unavailable", nm_device_get_iface (self)); return FALSE; +} if ( state < NM_DEVICE_STATE_DISCONNECTED && ( ( !NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER) && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_NONE)) || ( NM_FLAGS_HAS (flags, _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST_WAITING_CARRIER) && !nm_device_is_available (self, NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER)))) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [device] < disconnected", nm_device_get_iface (self)); return FALSE; +} if (!nm_device_check_connection_compatible (self, connection)) +{ + nm_log_info (LOGD_DEVICE, "#### (%s) [device] incompatible with device", nm_device_get_iface (self)); return FALSE; +} - return NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, flags, specific_object); + avail = NM_DEVICE_GET_CLASS (self)->check_connection_available (self, connection, flags, specific_object); + if (!avail) + nm_log_info (LOGD_DEVICE, "#### (%s) [device] connection not available", nm_device_get_iface (self)); + return avail; } static void diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 0f7fb6e..0dc53b9 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -777,53 +777,84 @@ check_connection_compatible (NMDevice *device, NMConnection *connection) const char *perm_hw_addr; if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->check_connection_compatible (device, connection)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] parent fail", nm_device_get_iface (device)); return FALSE; +} s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_WIRELESS_SETTING_NAME)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] not wifi", nm_device_get_iface (device)); return FALSE; +} s_wireless = nm_connection_get_setting_wireless (connection); if (!s_wireless) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] no wireless setting", nm_device_get_iface (device)); return FALSE; +} perm_hw_addr = nm_device_get_permanent_hw_address (device); mac = nm_setting_wireless_get_mac_address (s_wireless); if (perm_hw_addr) { if (mac && !nm_utils_hwaddr_matches (mac, -1, perm_hw_addr, -1)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] mac mismatch", nm_device_get_iface (device)); return FALSE; +} /* Check for MAC address blacklist */ mac_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless); for (i = 0; mac_blacklist[i]; i++) { if (!nm_utils_hwaddr_valid (mac_blacklist[i], ETH_ALEN)) { g_warn_if_reached (); +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] mac blacklist entry invalid", nm_device_get_iface (device)); return FALSE; } if (nm_utils_hwaddr_matches (mac_blacklist[i], -1, perm_hw_addr, -1)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] mac blacklisted", nm_device_get_iface (device)); return FALSE; +} } } else if (mac) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] mac required; no permaddr", nm_device_get_iface (device)); return FALSE; +} if (is_adhoc_wpa (connection)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] adhoc wpa", nm_device_get_iface (device)); return FALSE; +} /* Early exit if supplicant or device doesn't support requested mode */ mode = nm_setting_wireless_get_mode (s_wireless); if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) { if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_ADHOC)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] adhoc unsupported", nm_device_get_iface (device)); return FALSE; +} } else if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0) { if (!(priv->capabilities & NM_WIFI_DEVICE_CAP_AP)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] ap unsupported", nm_device_get_iface (device)); return FALSE; +} if (priv->sup_iface) { if (nm_supplicant_interface_get_ap_support (priv->sup_iface) == AP_SUPPORT_NO) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) [wifi compat] supplicant ap unsupported", nm_device_get_iface (device)); return FALSE; +} } } @@ -856,7 +887,14 @@ check_connection_available (NMDevice *device, NMAccessPoint *ap; ap = get_ap_by_path (NM_DEVICE_WIFI (device), specific_object); - return ap ? nm_ap_check_compatible (ap, connection) : FALSE; + if (ap) { + gboolean compat = nm_ap_check_compatible (ap, connection); +if (!compat) + nm_log_info (LOGD_DEVICE, "#### (%s) [wifi avail] specific object AP incompat with connection", nm_device_get_iface (device)); + return compat; + } + nm_log_info (LOGD_DEVICE, "#### (%s) [wifi avail] specific object not found", nm_device_get_iface (device)); + return FALSE; } /* Ad-Hoc and AP connections are always available because they may be @@ -880,10 +918,20 @@ check_connection_available (NMDevice *device, /* check if its visible */ for (ap_iter = priv->ap_list; ap_iter; ap_iter = g_slist_next (ap_iter)) { + const GByteArray *ssid = nm_ap_get_ssid (NM_AP (ap_iter->data)); + char *tmp = ssid ? nm_utils_ssid_to_utf8 (ssid->data, ssid->len) : ""; + + nm_log_info (LOGD_DEVICE, "#### (%s) [wifi avail] checking AP '%s'", nm_device_get_iface (device), tmp); if (nm_ap_check_compatible (NM_AP (ap_iter->data), connection)) +{ + nm_log_info (LOGD_DEVICE, "#### (%s) [wifi avail] AP '%s' compatible", nm_device_get_iface (device), tmp); +if (ssid) g_free (tmp); return TRUE; +} + nm_log_info (LOGD_DEVICE, "#### (%s) [wifi avail] AP '%s' incompatible with connection", nm_device_get_iface (device), tmp); } + nm_log_info (LOGD_DEVICE, "#### (%s) [wifi avail] no compatible AP found", nm_device_get_iface (device)); return FALSE; } @@ -1140,7 +1188,10 @@ can_auto_connect (NMDevice *device, guint64 timestamp = 0; if (!NM_DEVICE_CLASS (nm_device_wifi_parent_class)->can_auto_connect (device, connection, specific_object)) +{ +//nm_log_info (LOGD_DEVICE, "#### (%s) [wifi] parent can_auto_connect() fail", nm_device_get_iface (device)); return FALSE; +} s_wifi = nm_connection_get_setting_wireless (connection); g_return_val_if_fail (s_wifi, FALSE); @@ -1160,19 +1211,29 @@ can_auto_connect (NMDevice *device, */ if (nm_settings_connection_get_timestamp (NM_SETTINGS_CONNECTION (connection), ×tamp)) { if (timestamp == 0) +{ +nm_log_info (LOGD_DEVICE, "#### (%s) [wifi] zero timestamp", nm_device_get_iface (device)); return FALSE; +} } for (ap_iter = priv->ap_list; ap_iter; ap_iter = g_slist_next (ap_iter)) { NMAccessPoint *ap = NM_AP (ap_iter->data); + const GByteArray *ssid = nm_ap_get_ssid (ap); + char *tmp = ssid ? nm_utils_ssid_to_utf8 (ssid->data, ssid->len) : ""; +nm_log_info (LOGD_DEVICE, "#### (%s) [wifi] (checking %s)", nm_device_get_iface (device), tmp); if (nm_ap_check_compatible (ap, connection)) { /* All good; connection is usable */ *specific_object = (char *) nm_ap_get_dbus_path (ap); + if (ssid) g_free (tmp); return TRUE; } +nm_log_info (LOGD_DEVICE, "#### (%s) [wifi] (%s incompatible with connection)", nm_device_get_iface (device), tmp); + if (ssid) g_free (tmp); } +nm_log_info (LOGD_DEVICE, "#### (%s) [wifi] no compatible AP", nm_device_get_iface (device)); return FALSE; } diff --git a/src/nm-policy.c b/src/nm-policy.c index fc2a9bf..cb886f0 100644 --- a/src/nm-policy.c +++ b/src/nm-policy.c @@ -650,16 +650,24 @@ auto_activate_device (gpointer user_data) data->autoactivate_id = 0; + nm_log_info (LOGD_DEVICE, "#### (%s) autoactivate attempt", nm_device_get_iface (data->device)); + // FIXME: if a device is already activating (or activated) with a connection // but another connection now overrides the current one for that device, // deactivate the device and activate the new connection instead of just // bailing if the device is already active if (nm_device_get_act_request (data->device)) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) autoactivate fail; already activating", nm_device_get_iface (data->device)); goto out; +} connection_list = nm_manager_get_activatable_connections (priv->manager); if (!connection_list) +{ +// nm_log_info (LOGD_DEVICE, "#### (%s) autoactivate fail; no activatable connections", nm_device_get_iface (data->device)); goto out; +} connections = _nm_utils_copy_slist_to_array (connection_list, NULL, NULL); g_slist_free (connection_list); @@ -668,17 +676,29 @@ auto_activate_device (gpointer user_data) * with same priority are still sorted by last-connected-timestamp. */ g_ptr_array_sort (connections, (GCompareFunc) nm_utils_cmp_connection_by_autoconnect_priority); +//if (!nm_device_autoconnect_allowed (data->device)) +// nm_log_info (LOGD_DEVICE, "#### (%s) autoactivate fail; device autoconnect blocked", nm_device_get_iface (data->device)); + /* Find the first connection that should be auto-activated */ best_connection = NULL; for (i = 0; i < connections->len; i++) { NMSettingsConnection *candidate = NM_SETTINGS_CONNECTION (connections->pdata[i]); + nm_log_info (LOGD_DEVICE, "#### (%s) autoactivate candidate '%s'", nm_device_get_iface (data->device), nm_connection_get_id (NM_CONNECTION (candidate))); + if (!nm_settings_connection_can_autoconnect (candidate)) +{ + nm_log_info (LOGD_DEVICE, "#### (%s) not auto-activate", nm_device_get_iface (data->device)); continue; +} if (nm_device_can_auto_connect (data->device, (NMConnection *) candidate, &specific_object)) { + nm_log_info (LOGD_DEVICE, "#### (%s) BEST", nm_device_get_iface (data->device)); best_connection = (NMConnection *) candidate; break; } +//else { +// nm_log_info (LOGD_DEVICE, "#### (%s) can't autoconnect", nm_device_get_iface (data->device)); +//} } g_ptr_array_free (connections, TRUE); @@ -703,6 +723,8 @@ auto_activate_device (gpointer user_data) } g_object_unref (subject); } +//else +// nm_log_info (LOGD_DEVICE, "#### (%s) autoactivate fail; no best connection", nm_device_get_iface (data->device)); out: activate_data_free (data);