Commit graph

10255 commits

Author SHA1 Message Date
Masashi Honma
0109615c4e supplicant: enable FILS only when wpa_supplicant supports it
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
c7d490cfba ifcfg-rh/tests: add Wi-Fi FILS test
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
6e742693ee supplicant/tests: add FILS test
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
b4bbe5179f wifi: add support for FILS
The FILS(Fast Initial Link Setup) is a specification defined by IEEE 802.11ai to
speed up roaming. This patch adds support of it.

I have tested with these cases.
+-----+-------------------------+----------------+
| STA |            AP           |                |
|FILS |         key-mgmt        |     result     |
+-----+-------------------------+----------------+
|  1  | WPA-EAP                 |       O        |
+-----+-------------------------+----------------+
|  1  | WPA-EAP-SHA256          |       O        |
+-----+-------------------------+----------------+
|  1  | FILS-SHA256             |       X        |
+-----+-------------------------+----------------+
|  1  | FILS-SHA384             |       X        |
+-----+-------------------------+----------------+
|  1  | WPA-EAP WPA-EAP-SHA256  |       O        |
|     | FILS-SHA256 FILS-SHA384 | WPA-EAP-SHA256 |
+-----+-------------------------+----------------+
|  2  | WPA-EAP                 |       O        |
+-----+-------------------------+----------------+
|  2  | WPA-EAP-SHA256          |       O        |
+-----+-------------------------+----------------+
|  2  | FILS-SHA256             |       O        |
+-----+-------------------------+----------------+
|  2  | FILS-SHA384             |       O        |
+-----+-------------------------+----------------+
|  2  | WPA-EAP WPA-EAP-SHA256  |       O        |
|     | FILS-SHA256 FILS-SHA384 | FILS-SHA384    |
+-----+-------------------------+----------------+
|  3  | WPA-EAP                 |       X        |
+-----+-------------------------+----------------+
|  3  | WPA-EAP-SHA256          |       X        |
+-----+-------------------------+----------------+
|  3  | FILS-SHA256             |       O        |
+-----+-------------------------+----------------+
|  3  | FILS-SHA384             |       O        |
+-----+-------------------------+----------------+
|  3  | WPA-EAP WPA-EAP-SHA256  |       O        |
|     | FILS-SHA256 FILS-SHA384 | FILS-SHA384    |
+-----+-------------------------+----------------+

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:59 +01:00
Masashi Honma
87ec5e90fe supplicant: set key_mgmt independent of pmf value
Previouslly, the value of ieee80211w and key_mgmt field in
wpa_supplicant.conf was defined by the value of pmf.

NM_SETTING_WIRELESS_SECURITY_PMF_DISABLE
  ieee80211w=0
  key_mgmt=wpa-eap
NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL
  ieee80211w=1
  key_mgmt=wpa-eap wpa-eap-sha256
NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED
  ieee80211w=2
  key_mgmt=wpa-eap-sha256

Though these works, these does not include whole combinations.
The key_mgmt could be set independent of ieee80211w value.
For example, management frame protection could be used with
wpa-eap.
  ieee80211w=2
  key_mgmt=wpa-eap

And wpa-eap-sha256 could be used without management frame
protection.
  ieee80211w=0
  key_mgmt=wpa-eap-sha256

So this patch uses always key_mgmt=wpa-psk wpa-psk-sha256 or
key_mgmt=wpa-eap wpa-eap-sha256. By this setting, when AP
supports both, stronger algorithm will be chosen (ex. when AP
supports both wpa-eap and wpa-eap-sha256, wpa-eap-sha256 will be
chosen).

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
2018-01-16 15:01:35 +01:00
Thomas Haller
a21a5558b1 platform: move genl functions to nm-netlink.c
So they can be reused outside of wifi, like for implementing
wireguard support.
2018-01-15 20:29:26 +01:00
Thomas Haller
d702581812 platform: move netlink functions to nm-netlink.h 2018-01-15 20:29:26 +01:00
Thomas Haller
9562d88633 platform: add nm-netlink.h for netlink related helper functions
Especially useful, because we don't link against libnl-genl-3.so
but re-implement generic netlink support. Such code should go there
so it can be used by various components.
2018-01-15 20:29:26 +01:00
Thomas Haller
a3f77b259c wifi: always build nl80211 CRIT_PROTOCOL support
netlink's API is stable, and strictly defined by the integer values that make
up commands and attributes. There is little reason do disable a netlink feature
based on compile time detection of the kernel headers.

Either kernel supports it, or it will fail with an appropriate response.

Also, support for NL80211_CMD_CRIT_PROTOCOL_START was merge to kernel
in 2013. Maybe, we should now just always assume support (in the kernel
headers is there). Anyway, don't do that yet, but instead avoid the
defines and use the numeric values directly.
2018-01-15 20:29:26 +01:00
Thomas Haller
feb1fc2e73 wifi: rework WifiData to use a separate struct for function pointers
Add a WifiDataClass struct, that is immutable and contains all the
function pointers that were previously embedded in WifiData directly.
They are not ever modified after creation, hence this allows to have
a "static const" allocated instance of the VTable.

Also rename wifi_data_deinit() to wifi_data_unref(). It does not only
deinitialize the instance, instead it also frees it. Hence, rename it
to "unref()".
2018-01-15 20:29:26 +01:00
Thomas Haller
3cb81ee063 wifi: cleanup includes
- always include the corresponding header file first after "nm-default.h".
- include all our other headers last.
2018-01-15 20:29:26 +01:00
Thomas Haller
3de3f59ffd platform: fix wrong cleanup function in ip_route_get()
Fixes: 33a2a7c3e3
2018-01-15 20:29:26 +01:00
Thomas Haller
aa9b8049ed core/trivial: fix whitespace 2018-01-12 14:50:53 +01:00
Beniamino Galvani
e91f1a7d2a dns: introduce routing domains
Similarly to what systemd-resolved does, introduce the concept of
"routing" domain, which is a domain in the search list that is used
only to decide the interface over which a query must be forwarded, but
is not used to complete unqualified host names. Routing domains are
those starting with a tilde ('~') before the actual domain name.

Domains without the initial tilde are used both for completing
unqualified names and for the routing decision.
2018-01-12 13:42:08 +01:00
Beniamino Galvani
42ea86fb7a dns: systemd-resolved: use generic ip-config functions 2018-01-12 13:42:08 +01:00
Beniamino Galvani
70550e2740 dns: export search list in the D-Bus "domain" attribute
The "domain" key of the D-Bus configuration dictionary specifies the
domains a configuration applies to. In DNS code we consider domains
and searches as equivalent, so they should be exported via D-Bus using
the same logic used to populate resolv.conf and for plugins.
2018-01-12 13:42:08 +01:00
Beniamino Galvani
b4db0e8362 dns: add @dup argument to add_dns_domains() and add_string_item()
Add a @dup argument that tells whether the new item should be
duplicated.
2018-01-12 13:42:08 +01:00
Beniamino Galvani
e78bfb63cd dns: split out domains retrieval 2018-01-12 13:42:08 +01:00
Thomas Haller
34cb6f9877 build/meson: use variables for ldflags and linker-script 2018-01-11 12:46:01 +01:00
Beniamino Galvani
398f9105b4 ppp: update interface name in the plugin after NM changes it
When NM knows of the ifindex/name of the new PPP interface (through
the SetIfindex() call), it renames it. This can race with the pppd
daemon, which issues ioctl() using the interface name cached in the
global 'ifname' variable:

  ...
  NetworkManager[27213]: <debug> [1515427406.0036] ppp-manager: set-ifindex 71
  pppd[27801]: sent [CCP ConfRej id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
  NetworkManager[27213]: <debug> [1515427406.0036] platform: link: setting 'ppp5' (71) name dsl-ppp
  pppd[27801]: sent [IPCP ConfAck id=0x2 <addr 3.1.1.1>]
  pppd[27801]: ioctl(SIOCSIFADDR): No such device (line 2473)
  pppd[27801]: Interface configuration failed
  pppd[27801]: Couldn't get PPP statistics: No such device
  ...

Fortunately the variable is exposed to plugins and so we can turn the
SetIfindex() D-Bus call into a synchronous one and then update the
value of the 'ifname' global variable with the new interface name
assigned by NM.
2018-01-10 15:36:29 +01:00
Beniamino Galvani
41ef5853e6 ppp/trivial: rename field 2018-01-10 15:36:29 +01:00
Beniamino Galvani
dd98ada33f ppp: introduce SetIfindex pppd plugin D-Bus method
If IPV6CP terminates before IPCP, pppd enters the RUNNING phase and we
start IP configuration without having an IP interface set, which
triggers assertions.

Instead, add a SetIfindex() D-Bus method that gets called by the
plugin when pppd becomes RUNNING. The method sets the IP ifindex of
the device and starts IP configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1515829
2018-01-10 15:36:29 +01:00
Beniamino Galvani
2507046fea device: add nm_device_set_ip_ifindex() 2018-01-10 15:36:29 +01:00
Thomas Haller
349861ceec build/meson: unconditionally use linker version scripts
We also unconditionally use them with autotools.
Also, the detection for have_version_script does
not seem correct to me. At least, it didn't work
with clang.
2018-01-10 12:31:44 +01:00
Thomas Haller
ca9418232c build/meson: rename config_plugin_ibft option to just ibft 2018-01-10 12:27:33 +01:00
Iñigo Martínez
50930ed19a meson: Use string variables extensively
The strings holding the names used for libraries have also been
moved to different variables. This way they would be less error
as these variables can be reused easily and any typing error
would be quickly detected.
2018-01-10 12:22:55 +01:00
Iñigo Martínez
5e16bcf268 meson: Improve dependency system
Some targets are missing dependencies on some generated sources in
the meson port. These makes the build to fail due to missing source
files on a highly parallelized build.

These dependencies have been resolved by taking advantage of meson's
internal dependencies which can be used to pass source files,
include directories, libraries and compiler flags.

One of such internal dependencies called `core_dep` was already in
use. However, in order to avoid any confusion with another new
internal dependency called `nm_core_dep`, which is used to include
directories and source files from the `libnm-core` directory, the
`core_dep` dependency has been renamed to `nm_dep`.

These changes have allowed minimizing the build details which are
inherited by using those dependencies. The parallelized build has
also been improved.
2018-01-10 12:20:17 +01:00
Pavel Šimerda
681d2bcd70 device: split per-directory factory function
In some cases we might want to load device plugins from multiple
directories. A special case that I have in mind is to load plugins from
build directory subdirectories in order to run NetworkManager from the
build directory.

[thaller@redhat.com: modify original patch]
2018-01-10 11:01:46 +01:00
Thomas Haller
0e1fb1dbd2 dhcp: fix check for client-id in _set_client_id()
Fixes: 686afe531a
2018-01-09 15:55:43 +01:00
Thomas Haller
d1de905ed3 policy: merge IPv4 and IPv6 versions of device_ip_config_changed() 2018-01-09 14:24:54 +01:00
Thomas Haller
c03a534963 core: implement setting MDNS setting for systemd
The connection.mdns setting is a per-connection setting,
so one might expect that one activated device can only have
one MDNS setting at a time.

However, with certain VPN plugins (those that don't have their
own IP interface, like libreswan), the VPN configuration is merged
into the configuration of the device. So, in this case, there
might be multiple settings for one device that must be merged.

We already have a mechanism for that. It's NMIP4Config. Let NMIP4Config
track this piece of information. Although, stricitly speaking this
is not tied to IPv4, the alternative would be to introduce a new
object to track such data, which would be a tremendous effort
and more complicated then this.

Luckily, NMDnsManager and NMDnsPlugin are already equipped to
handle multiple NMIPConfig instances per device (IPv4 vs. IPv6,
and Device vs. VPN).

Also make "connection.mdns" configurable via global defaults in
NetworkManager.conf.
2018-01-09 14:24:54 +01:00
Thomas Haller
b40729ca5f core: rework tracking config in dns-manager to use ifindex
Don't track the per-device configuration in NMDnsManager by
the ifname, but by the ifindex. We should consistently treat
the ifindex as the ID of a link, like kernel does.

At the few places where we actually need the ifname, resolve
it by looking into the platform cache. That is not necessarily
the same as the ifname that is currently tracked by NMDevice,
because netdev interfaces can be renamed, and NMDevice updates
it's link properties delayed. However, the platform cache has
the most recent notion of the correct interface name for an
ifindex, so if we ever hit a race here, we do it now more
correctly.

This also temporarily drops support for mdns. Will be re-added next,
but differently.
2018-01-09 14:24:54 +01:00
Thomas Haller
fc40d91b97 core/trivial: rename local variable in merge_one_ip_config()
Next commit will unify naming of variables, do a trivial rename
first to make the diff smaller.
2018-01-09 14:24:54 +01:00
Thomas Haller
b0f1a54c9b dns: rework pending request-queue in NMDnsSystemdResolved
We had two separate queues, one for "SetLinkDNS" and one for
"SetLinkDomains". Merge them into one, and track the operation
as part of the new RequestItem structure.

A visible change to before is that we now would make all requests
per-interface first. Prevously, we would first make all SetLinkDNS
requests (for all interfaces) and then all SetLinkDomains requests.
It feels more correct to order the requests this way, not by
type.

The reason to merge is, that we will next get another operation
and in the current scheme we would need 3 GQueue instances.

While at it, refactor the code to use CList. We now anyway would
need a new struct to track the operation, requiring to allocate
and free it. Previously, we would only track the GVariant argument
as data of the GQueue.
2018-01-09 14:24:54 +01:00
Thomas Haller
4be4a3c21f dns: refactor update() in NMDnsSystemdResolved to use a hash table
Use a GHashTable instead of a GArray to construct the list of
@interfaces. Also, use NMCListElem instead of GList. With this,
the runtime is O(n*log(n)) instead of O(n^2).

I belive, we should take care that all our code has a reasonable
runtime complexity, even in common use-cases the number of elements
is small. This is not about performace, because likely we expect few
entries anyway, and the direct GArray implementation is likely faster
in those cases. It's about using the data structure that best suits the
access pattern.

The log(n) part comes from sorting the keys. I also believe we should
always aim for a stable behavior. When sending the D-Bus request to
resolved, the order of elements should be in ~some~ defined order.
2018-01-09 14:24:54 +01:00
Thomas Haller
4ccfa7a79a core: add nm_ip_config_get_ifindex() helper 2018-01-09 14:24:53 +01:00
Thomas Haller
7d4def2764 dns: merge IPv4 and IPv6 versions of add_ip_config() (part 2) 2018-01-09 14:24:53 +01:00
Thomas Haller
49fd1e4126 dns: merge IPv4 and IPv6 versions of add_ip_config() (part 1) 2018-01-09 14:24:53 +01:00
Thomas Haller
03cba93873 dns/trivial: move code 2018-01-09 14:24:53 +01:00
Thomas Haller
9d92848ada libnm: rename MDns flag UNKNOWN to DEFAULT
"UNKNOWN" is not a good name. If you don't set the property
in the connection explicitly, it should be "DEFAULT".

Also, make "DEFAULT" -1. For one, that ensures that the enum's
underlying integer type is signed. Otherwise, it's cumbersome
to test "if (mdns >= DEFAULT)" because in case of unsigned types,
the compiler will warn about the check always being true.
Also, it allows for "NO" to be zero. These are no strong reasons,
but I tend to think this is better.

Also, don't make the property of NMSettingConnection a CONSTRUCT property.
Initialize the default manually in the init function.

Also, order the numeric values so that DEFAULT < NO < RESOLVE < YES with
YES being largest because it enables *the most*.
2018-01-09 14:24:53 +01:00
Ismo Puustinen
25906eda9e dns: add mechanism for propagating mDNS setting.
Update nm-policy.c and nm-dns-manager.c so that the connection-specific
settings get propagated to DNS manger. Currently the only such value is
the mDNS status.

Add update_mdns() function to DNS plugin interface. If a DNS plugin
supports mDNS, it can set an interface with a given index to support
mDNS resolving or also register the current hostname.

The mDNS support is currently added only to systemd-resolved DNS plugin.
2018-01-09 14:24:53 +01:00
Ismo Puustinen
2e2ff6f27a mdns: add new connection property.
Add support for mDNS as a connection-level property. Update ifcfg-rh and
keyfile plugins to support it.
2018-01-09 14:24:53 +01:00
Thomas Haller
3d86429c9d core: reorder code in "src/dns/nm-dns-manager.c"
Just moving code around, no other changes.

Follow a certain prefered order of declarations
in source files.
2018-01-09 14:24:53 +01:00
Lubomir Rintel
f3b4053a91 platform-linux: reload qdiscs and tfilters after removing them
Kernel (as of 4.14) merely ACKs our RTM_DELQDISC and RTM_DELTFILTER, not
bothering to signal the full RTM_DEL* message unless the removal is
external to NetworkManager.

https://bugzilla.redhat.com/show_bug.cgi?id=1527197
2018-01-08 17:49:41 +01:00
Francesco Giudici
f9b9c5979e platform/tests: relax checking for signals in test-address-linux
# Start of ipv6 tests
  ../tools/run-nm-test.sh: line 193: 32194 Trace/breakpoint trap   (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  # NetworkManager-FATAL-ERROR: NMPlatformSignalAssert: ../src/platform/tests/test-address.c:153, test_ip6_address_general(): failure to accept signal [0,1] times: 'ip6-address-changed-changed' ifindex 11 (2 times received)
2018-01-08 16:48:56 +01:00
Iñigo Martínez
876de69e08 build/meson: don't include libnm when building src/systemd
"src/" must not include "libnm/". This also causes a build failure,
because it would include "libnm/nm-types.h", instead of "src/nm-types.h".

https://mail.gnome.org/archives/networkmanager-list/2018-January/msg00032.html

[thaller@redhat.com: original patch modified and commit message changed]
2018-01-08 13:03:53 +01:00
Thomas Haller
25ade39752 tests: use NMTST_EXPECT*() macros
Tests are commonly created via copy&paste. Hence, it's
better to express a certain concept explicitly via a function
or macro. This way, the implementation of the concept can be
adjusted at one place, without requiring to change all the callers.

Also, the macro is shorter, and brevity is better for tests
so it's easier to understand what the test does. Without being
bothered by noise from the redundant information.

Also, the macro knows better which message to expect. For example,
messages inside "src" are prepended by nm-logging.c with a level
and a timestamp. The expect macro is aware of that and tests for it

  #define NMTST_EXPECT_NM_ERROR(msg)      NMTST_EXPECT_NM (G_LOG_LEVEL_MESSAGE, "*<error> [*] "msg)

This again allows the caller to ignore this prefix, but still assert
more strictly.
2018-01-08 12:38:54 +01:00
Thomas Haller
66b80bd652 tests: add NMTST_EXPECT*() macros
Will be used next...
2018-01-08 12:38:53 +01:00
Thomas Haller
22ef6a507a build: refine the NETWORKMANAGER_COMPILATION define
Note that:

 - we compile some source files multiple times. Most notably those
   under "shared/".

 - we include a default header "shared/nm-default.h" in every source
   file. This header is supposed to setup a common environment by defining
   and including parts that are commonly used. As we always include the
   same header, the header must behave differently depending
   one whether the compilation is for libnm-core, NetworkManager or
   libnm-glib. E.g. it must include <glib/gi18n.h> or <glib/gi18n-lib.h>
   depending on whether we compile a library or an application.

For that, the source files need the NETWORKMANAGER_COMPILATION #define
to behave accordingly.

Extend the define to be composed of flags. These flags are all named
NM_NETWORKMANAGER_COMPILATION_WITH_*, they indicate which part of the
build are available. E.g. when building libnm-core.la itself, then
WITH_LIBNM_CORE, WITH_LIBNM_CORE_INTERNAL, and WITH_LIBNM_CORE_PRIVATE
are available. When building NetworkManager, WITH_LIBNM_CORE_PRIVATE
is not available but the internal parts are still accessible. When
building nmcli, only WITH_LIBNM_CORE (the public part) is available.
This granularily controls the build.
2018-01-08 12:38:53 +01:00
Thomas Haller
31b6abd4b5 config: adjust logging message for duplicate config prefix
The logging macros already prepend a "config: " prefix. Don't
repeat that in the message, otherwise we get

    config: config: signal SIGHUP (no changes from disk)

Now:

    config: signal: SIGHUP (no changes from disk)
2018-01-08 12:18:52 +01:00