diff options
author | Thomas Haller <thaller@redhat.com> | 2017-12-27 10:06:21 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-12-27 10:18:31 +0100 |
commit | 67a20a6ba518bbb3383cfb1601081b34d0c505ed (patch) | |
tree | a48d4471ffad1f882aa0133162d72f1812ad5917 | |
parent | bbcd0e9018fe229057a140b584526e03b10ee2fb (diff) | |
parent | 07756025745493b1999f7c04b5e826c50b73b42d (diff) | |
download | NetworkManager-67a20a6ba518bbb3383cfb1601081b34d0c505ed.tar.gz |
wifi/iwd: merge branch 'th/wifi-iwd-config'
https://github.com/NetworkManager/NetworkManager/pull/41
-rw-r--r-- | contrib/fedora/rpm/NetworkManager.spec | 11 | ||||
-rw-r--r-- | man/NetworkManager.conf.xml | 9 | ||||
-rw-r--r-- | src/NetworkManagerUtils.c | 35 | ||||
-rw-r--r-- | src/NetworkManagerUtils.h | 5 | ||||
-rw-r--r-- | src/devices/nm-device.c | 15 | ||||
-rw-r--r-- | src/devices/nm-device.h | 2 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-iwd.c | 4 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 2 | ||||
-rw-r--r-- | src/devices/wifi/nm-wifi-factory.c | 18 | ||||
-rw-r--r-- | src/nm-config-data.c | 45 | ||||
-rw-r--r-- | src/nm-config-data.h | 6 | ||||
-rw-r--r-- | src/nm-config.h | 3 |
12 files changed, 136 insertions, 19 deletions
diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index e0a0849933..3d15ee550e 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -50,6 +50,7 @@ %bcond_without wwan %bcond_without team %bcond_without wifi +%bcond_with iwd %bcond_without ovs %bcond_without ppp %bcond_without nmtui @@ -221,6 +222,11 @@ Summary: Wifi plugin for NetworkManager Group: System Environment/Base Requires: %{name}%{?_isa} = %{epoch}:%{version}-%{release} Requires: wpa_supplicant >= 1:1.1 +# the wifi plugin doesn't require iwd, even if it was build with +# iwd support. Note that the plugin supports both supplicant and +# iwd backend, that doesn't mean that the user requires to have them +# both installed. Maybe both iwd and supplicant should Provide a "wireless-daemon" +# meta package. Obsoletes: NetworkManager < %{obsoletes_device_plugins} %description wifi @@ -426,6 +432,11 @@ intltoolize --automake --copy --force %else --enable-wifi=no \ %endif +%if %{with iwd} + --with-iwd=yes \ +%else + --with-iwd=no \ +%endif --enable-vala=yes \ --enable-introspection \ %if %{with regen_docs} diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml index 231b7d017f..04f6b54b23 100644 --- a/man/NetworkManager.conf.xml +++ b/man/NetworkManager.conf.xml @@ -927,6 +927,15 @@ managed=1 </para> </listitem> </varlistentry> + <varlistentry id="wifi.backend"> + <term><varname>wifi.backend</varname></term> + <listitem> + <para> + Specify the Wi-Fi backend used for the device. Currently supported + are <literal>wpa_supplicant</literal> and <literal>iwd</literal> (experimental). + </para> + </listitem> + </varlistentry> <varlistentry> <term><varname>wifi.scan-generate-mac-address-mask</varname></term> <listitem> diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 89bd357f07..2259fc7e76 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -935,3 +935,38 @@ nm_utils_g_value_set_object_path_array (GValue *value, } /*****************************************************************************/ + +int +nm_match_spec_device_by_pllink (const NMPlatformLink *pllink, + const char *match_device_type, + const GSList *specs, + int no_match_value) +{ + NMMatchSpecMatchType m; + + /* we can only match by certain properties that are available on the + * platform link (and even @pllink might be missing. + * + * It's still useful because of specs like "*" and "except:interface-name:eth0", + * which match even in that case. */ + m = nm_match_spec_device (specs, + pllink ? pllink->name : NULL, + match_device_type, + pllink ? pllink->driver : NULL, + NULL, + NULL, + NULL); + + switch (m) { + case NM_MATCH_SPEC_MATCH: + return TRUE; + case NM_MATCH_SPEC_NEG_MATCH: + return FALSE; + case NM_MATCH_SPEC_NO_MATCH: + return no_match_value; + } + nm_assert_not_reached (); + return no_match_value; +} + + diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h index e5f28b2729..16b0873664 100644 --- a/src/NetworkManagerUtils.h +++ b/src/NetworkManagerUtils.h @@ -64,6 +64,11 @@ void nm_utils_g_value_set_object_path_array (GValue *value, NMUtilsObjectFunc filter_func, gpointer user_data); +int nm_match_spec_device_by_pllink (const NMPlatformLink *pllink, + const char *match_device_type, + const GSList *specs, + int no_match_value); + /*****************************************************************************/ #endif /* __NETWORKMANAGER_UTILS_H__ */ diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8168957dd4..ce144c3b08 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -269,7 +269,6 @@ typedef struct _NMDevicePrivate { int ip_ifindex; NMDeviceType type; char * type_desc; - char * type_description; NMLinkType link_type; NMDeviceCapabilities capabilities; char * driver; @@ -1988,18 +1987,23 @@ nm_device_get_type_description (NMDevice *self) static const char * get_type_description (NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDeviceClass *klass; - if (!priv->type_description) { + nm_assert (NM_IS_DEVICE (self)); + + klass = NM_DEVICE_GET_CLASS (self); + if (G_UNLIKELY (!klass->default_type_description)) { const char *typename; + gs_free char *s = NULL; typename = G_OBJECT_TYPE_NAME (self); if (g_str_has_prefix (typename, "NMDevice")) typename += 8; - priv->type_description = g_ascii_strdown (typename, -1); + s = g_ascii_strdown (typename, -1); + klass->default_type_description = g_intern_string (s); } - return priv->type_description; + return klass->default_type_description; } gboolean @@ -14581,7 +14585,6 @@ finalize (GObject *object) g_free (priv->driver_version); g_free (priv->firmware_version); g_free (priv->type_desc); - g_free (priv->type_description); g_free (priv->dhcp_anycast_address); g_free (priv->current_stable_id); diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index abb2420c14..8c823bab4d 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -192,6 +192,8 @@ typedef enum { /*< skip >*/ typedef struct { NMExportedObjectClass parent; + const char *default_type_description; + const char *connection_type; const NMLinkType *link_types; diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c index 36e9fe440c..da8cee2957 100644 --- a/src/devices/wifi/nm-device-iwd.c +++ b/src/devices/wifi/nm-device-iwd.c @@ -284,7 +284,7 @@ get_ordered_networks_cb (GObject *source, GAsyncResult *res, gpointer user_data) return; } - priv->new_aps = g_hash_table_new (g_str_hash, g_str_equal); + priv->new_aps = g_hash_table_new (nm_str_hash, g_str_equal); g_variant_get (variant, "(a(osns))", &networks); @@ -1791,7 +1791,7 @@ nm_device_iwd_init (NMDeviceIwd *self) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE (self); - priv->aps = g_hash_table_new (g_str_hash, g_str_equal); + priv->aps = g_hash_table_new (nm_str_hash, g_str_equal); /* Make sure the manager is running */ (void) nm_iwd_manager_get (); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index f8a985a2bb..f9441f8428 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1040,7 +1040,7 @@ _hw_addr_set_scanning (NMDeviceWifi *self, gboolean do_reset) priv = NM_DEVICE_WIFI_GET_PRIVATE (self); randomize = nm_config_data_get_device_config_boolean (NM_CONFIG_GET_DATA, - "wifi.scan-rand-mac-address", + NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_SCAN_RAND_MAC_ADDRESS, device, TRUE, TRUE); diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c index 1272e94139..6b8e5fb85a 100644 --- a/src/devices/wifi/nm-wifi-factory.c +++ b/src/devices/wifi/nm-wifi-factory.c @@ -104,12 +104,18 @@ create_device (NMDeviceFactory *factory, if (plink->type != NM_LINK_TYPE_WIFI) return nm_device_olpc_mesh_new (iface); - backend = nm_config_data_get_value (NM_CONFIG_GET_DATA, - NM_CONFIG_KEYFILE_GROUP_MAIN, - NM_CONFIG_KEYFILE_KEY_MAIN_WIFI_BACKEND, - NM_CONFIG_GET_VALUE_STRIP); - - nm_log_dbg (LOGD_PLATFORM | LOGD_WIFI, "(%s) config: backend is %s, %i", iface, backend, WITH_IWD); + backend = nm_config_data_get_device_config_by_pllink (NM_CONFIG_GET_DATA, + NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_BACKEND, + plink, + "wifi", + NULL); + nm_strstrip (backend); + + nm_log_dbg (LOGD_PLATFORM | LOGD_WIFI, + "(%s) config: backend is %s%s%s%s", + iface, + NM_PRINT_FMT_QUOTE_STRING (backend), + WITH_IWD ? " (iwd support enabled)" : ""); if (!backend || !strcasecmp (backend, "wpa_supplicant")) return nm_device_wifi_new (iface, capabilities); #if WITH_IWD diff --git a/src/nm-config-data.c b/src/nm-config-data.c index 00e5c635b5..e71ac95a63 100644 --- a/src/nm-config-data.c +++ b/src/nm-config-data.c @@ -1196,6 +1196,8 @@ _match_section_infos_lookup (const MatchSectionInfo *match_section_infos, GKeyFile *keyfile, const char *property, NMDevice *device, + const NMPlatformLink *pllink, + const char *match_device_type, char **out_value) { if (!match_section_infos) @@ -1216,9 +1218,15 @@ _match_section_infos_lookup (const MatchSectionInfo *match_section_infos, if (!value && !match_section_infos->stop_match) continue; - match = TRUE; - if (match_section_infos->match_device.has) - match = device && nm_device_spec_match_list (device, match_section_infos->match_device.spec); + if (match_section_infos->match_device.has) { + if (device) + match = nm_device_spec_match_list (device, match_section_infos->match_device.spec); + else if (pllink) + match = nm_match_spec_device_by_pllink (pllink, match_device_type, match_section_infos->match_device.spec, FALSE); + else + match = FALSE; + } else + match = TRUE; if (match) { *out_value = value; @@ -1248,6 +1256,35 @@ nm_config_data_get_device_config (const NMConfigData *self, priv->keyfile, property, device, + NULL, + NULL, + &value); + NM_SET_OUT (has_match, !!connection_info); + return value; +} + +char * +nm_config_data_get_device_config_by_pllink (const NMConfigData *self, + const char *property, + const NMPlatformLink *pllink, + const char *match_device_type, + gboolean *has_match) +{ + const NMConfigDataPrivate *priv; + const MatchSectionInfo *connection_info; + char *value = NULL; + + g_return_val_if_fail (self, NULL); + g_return_val_if_fail (property && *property, NULL); + + priv = NM_CONFIG_DATA_GET_PRIVATE (self); + + connection_info = _match_section_infos_lookup (&priv->device_infos[0], + priv->keyfile, + property, + NULL, + pllink, + match_device_type, &value); NM_SET_OUT (has_match, !!connection_info); return value; @@ -1287,6 +1324,8 @@ nm_config_data_get_connection_default (const NMConfigData *self, priv->keyfile, property, device, + NULL, + NULL, &value); return value; } diff --git a/src/nm-config-data.h b/src/nm-config-data.h index 3092a87f6c..87cb83ba12 100644 --- a/src/nm-config-data.h +++ b/src/nm-config-data.h @@ -188,6 +188,12 @@ char *nm_config_data_get_device_config (const NMConfigData *self, NMDevice *device, gboolean *has_match); +char *nm_config_data_get_device_config_by_pllink (const NMConfigData *self, + const char *property, + const NMPlatformLink *pllink, + const char *match_device_type, + gboolean *has_match); + gboolean nm_config_data_get_device_config_boolean (const NMConfigData *self, const char *property, NMDevice *device, diff --git a/src/nm-config.h b/src/nm-config.h index b99576abf3..5d027ce06e 100644 --- a/src/nm-config.h +++ b/src/nm-config.h @@ -64,7 +64,6 @@ #define NM_CONFIG_KEYFILE_KEY_MAIN_DEBUG "debug" #define NM_CONFIG_KEYFILE_KEY_MAIN_HOSTNAME_MODE "hostname-mode" #define NM_CONFIG_KEYFILE_KEY_MAIN_SLAVES_ORDER "slaves-order" -#define NM_CONFIG_KEYFILE_KEY_MAIN_WIFI_BACKEND "wifi-backend" #define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND "backend" #define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE "enable" #define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS ".was" @@ -79,6 +78,8 @@ #define NM_CONFIG_KEYFILE_KEY_DEVICE_MANAGED "managed" #define NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER "ignore-carrier" #define NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS "sriov-num-vfs" +#define NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_BACKEND "wifi.backend" +#define NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_SCAN_RAND_MAC_ADDRESS "wifi.scan-rand-mac-address" #define NM_CONFIG_KEYFILE_KEY_DEVICE_CARRIER_WAIT_TIMEOUT "carrier-wait-timeout" #define NM_CONFIG_KEYFILE_KEYPREFIX_WAS ".was." |