Commit Graph

21088 Commits

Author SHA1 Message Date
Andrew Zaborowski
bf7705a4b8 settings-connection: don't expect system_secrets always present
priv->system_secrets may be updated by e.g.
nm_settings_connection_new_secrets and nm_settings_connection_update,
but if the plugin creates the object with g_object_new, then adds some
settings but never adds any secrets there's no reason to call either of
those two methods.  A call to nm_settings_connection_get_secrets should
still be able to request new secrets (and may then update
priv->system_secrets as a result).

(cherry picked from commit f11246154e)
2018-06-22 16:46:05 +02:00
Andrew Zaborowski
d1163e9499 cli: use the hints from 802.1x secrets requests if given
If the hints parameter to the agent request wasn't empty, ask
specifically for the 802-1x keys listed in the hints and skip the
guessing.  I didn't add human readable names for all of the 802-1x
settings, it could be useful to do for at least the three 802-1x
properties that add_8021x_secrets already knows about because
those may have translations.

(cherry picked from commit 1a6e53808d)
2018-06-22 16:46:05 +02:00
Andrew Zaborowski
74bff39e0d iwd: don't set REQUEST_NEW secret request flag on first connection
Allow the IWD backend to use secrets provided in the connection settings
on initial connection attempt, only require new secrets on subsequent
connections when IWD asks for them -- it only asks if fresh secrets are
required.

(cherry picked from commit 24f5cf23e5)
2018-06-22 16:46:05 +02:00
Andrew Zaborowski
1e5e143679 iwd: handle new secret request types from IWD agent
The IWD DBus interface currently
(https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/doc/agent-api.txt?id=38952813dddd776f66d2ed5e88eca9a892964c06)
knows about 3 secret types related to 802.1x authentication in addition
to the PSK secret request.  Add support for the new methods and the new
secret types in NM's implementation of the IWD secret agent.  Note that
the secret types are mapped to NMSetting8021x property keys and they are
then sent to the NM Secret Agent in the hints parameter to GetSecrets,
this will need support in the NM clients as the exact usage of the
hints parameter is specified a little ambiguously, but this seems to be
one of the permitted usages.

Rework the IWD agent interface info initialization to use NM convenience
macros.

(cherry picked from commit 74d9e04a66)
2018-06-22 16:46:05 +02:00
Andrew Zaborowski
5c747f729c iwd: save secrets request invocation in request user_data
To improve the code logic and reduce space for bugs, don't save the
dbus invocation object as priv->secrets_request, instead move it to
the nm_act_request_get_secrets()'s user_data as we only need the
invocation object for exactly the life time of the request.  See
https://github.com/NetworkManager/NetworkManager/pull/139 for
discussion.

(cherry picked from commit ffd96edf76)
2018-06-22 16:46:05 +02:00
Andrew Zaborowski
b733bd66af iwd: in prepare stage check that matching AP exists
Check the return value of nm_wifi_aps_find_first_compatible in
act_stage1_prepare.  Also a small formatting fix.

(cherry picked from commit 0876332bae)
2018-06-22 16:46:05 +02:00
Andrew Zaborowski
78b14312ce iwd: handle empty wireless mode as Infrastructure
Blank mode property in the wireless settings is documented in
libnm-core/nm-setting-wireless.c to mean infrastructure mode.

(cherry picked from commit d01ba607a6)
2018-06-22 16:46:04 +02:00
Thomas Haller
5e8773ee63 wifi: merge branch 'balrog-kun:iwd-agent'
https://github.com/NetworkManager/NetworkManager/pull/139
2018-06-22 16:39:26 +02:00
Thomas Haller
31245cdd62 manager: return NULL for invalid ifindex in nm_manager_get_device_by_ifindex()
Internally, the device migth have negative or zero ifindex.
When calling nm_manager_get_device_by_ifindex(), the caller
wants to find a device with a valid ifindex, hence filter
out non-positive values.
2018-06-22 16:39:01 +02:00
Thomas Haller
aef5110fa6 wifi/iwd: downgrade error levels for agent-request failures
<error> level is for something really bad happening. When another party
(iwd in this case) sends a D-Bus request that we cannot meaningfully handle,
that is hardly reason to warn about. <debug> level is enough in this case.

Also, give all messages a common prefix "agent-request" so that we have
something to grep for.
2018-06-22 16:39:01 +02:00
Thomas Haller
412a1fb46d wifi/iwd: fix leaking name-owner in agent_dbus_method_cb() 2018-06-22 16:39:01 +02:00
Thomas Haller
44cd60e820 wifi/iwd: don't check return value for nm_utils_random_bytes()
nm_utils_random_bytes() will always try its best to give some
random numbers. A failure only means, that the kernel interfaces
get_random() or /dev/urandom failed to provide good randomness. We
don't really need good random numbers here, so no need to handle
a failure.
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
f11246154e settings-connection: don't expect system_secrets always present
priv->system_secrets may be updated by e.g.
nm_settings_connection_new_secrets and nm_settings_connection_update,
but if the plugin creates the object with g_object_new, then adds some
settings but never adds any secrets there's no reason to call either of
those two methods.  A call to nm_settings_connection_get_secrets should
still be able to request new secrets (and may then update
priv->system_secrets as a result).
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
1a6e53808d cli: use the hints from 802.1x secrets requests if given
If the hints parameter to the agent request wasn't empty, ask
specifically for the 802-1x keys listed in the hints and skip the
guessing.  I didn't add human readable names for all of the 802-1x
settings, it could be useful to do for at least the three 802-1x
properties that add_8021x_secrets already knows about because
those may have translations.
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
24f5cf23e5 iwd: don't set REQUEST_NEW secret request flag on first connection
Allow the IWD backend to use secrets provided in the connection settings
on initial connection attempt, only require new secrets on subsequent
connections when IWD asks for them -- it only asks if fresh secrets are
required.
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
74d9e04a66 iwd: handle new secret request types from IWD agent
The IWD DBus interface currently
(https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/doc/agent-api.txt?id=38952813dddd776f66d2ed5e88eca9a892964c06)
knows about 3 secret types related to 802.1x authentication in addition
to the PSK secret request.  Add support for the new methods and the new
secret types in NM's implementation of the IWD secret agent.  Note that
the secret types are mapped to NMSetting8021x property keys and they are
then sent to the NM Secret Agent in the hints parameter to GetSecrets,
this will need support in the NM clients as the exact usage of the
hints parameter is specified a little ambiguously, but this seems to be
one of the permitted usages.

Rework the IWD agent interface info initialization to use NM convenience
macros.
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
ffd96edf76 iwd: save secrets request invocation in request user_data
To improve the code logic and reduce space for bugs, don't save the
dbus invocation object as priv->secrets_request, instead move it to
the nm_act_request_get_secrets()'s user_data as we only need the
invocation object for exactly the life time of the request.  See
https://github.com/NetworkManager/NetworkManager/pull/139 for
discussion.
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
0876332bae iwd: in prepare stage check that matching AP exists
Check the return value of nm_wifi_aps_find_first_compatible in
act_stage1_prepare.  Also a small formatting fix.
2018-06-22 16:39:01 +02:00
Andrew Zaborowski
d01ba607a6 iwd: handle empty wireless mode as Infrastructure
Blank mode property in the wireless settings is documented in
libnm-core/nm-setting-wireless.c to mean infrastructure mode.
2018-06-22 16:39:01 +02:00
Beniamino Galvani
64e4616a3d manager: fix typo in 'PrimaryConnectionType' D-Bus property name
Fixes: 297d4985ab
(cherry picked from commit a2b85d5c6e)
2018-06-22 16:00:58 +02:00
Beniamino Galvani
a2b85d5c6e manager: fix typo in 'PrimaryConnectionType' D-Bus property name
Fixes: 297d4985ab
2018-06-22 15:53:46 +02:00
Thomas Haller
ae21723d2a shared: use nm_hash_update() instead of c_siphash_append()
In our own code, there are very few places where we should
call c_siphash_append() directly. This is not one of them.
2018-06-22 14:19:49 +02:00
Thomas Haller
41a784d7f1 wifi: merge branch 'wowlan-settings' (restore part)
https://github.com/NetworkManager/NetworkManager/pull/124
2018-06-22 14:05:54 +02:00
Thomas Haller
a3289400d3 wifi: ensure wake-on-wlan restore only acts once
- in wake_on_wlan_restore(), if we decide that there is something
  to restore, also clear priv->wowlan_restore by setting it to
  IGNORE. That way, we are sure to only try resetting the value
  once after setting it.

- from nm_platform_wifi_get_wake_on_wlan(), return IGNORE if
  the value cannot be read. If we could not read the value
  we should not restore NONE, but don't restore.
2018-06-22 14:03:48 +02:00
Alfonso Sánchez-Beato
c6e40215ef devices: restore past WoWLAN when disconnecting wifi
Restore previous WoWLAN settings on disconnection in case we had
configured it when connecting.
2018-06-22 13:54:37 +02:00
Alfonso Sánchez-Beato
ac13027934 platform: add methods to retrieve current WoWLAN state 2018-06-22 13:54:37 +02:00
Francesco Giudici
20a8bc9e34 cli: list the 'print' command in the welcome message of the editor
https://bugzilla.redhat.com/show_bug.cgi?id=1588995
2018-06-21 16:56:50 +02:00
Thomas Haller
da81f346cd libnm: fix leaking filename in NMRemoteConnection
Fixes: bd6fe17815
(cherry picked from commit 9bc6ca96f6)
2018-06-21 16:09:14 +02:00
Thomas Haller
9bc6ca96f6 libnm: fix leaking filename in NMRemoteConnection
Fixes: bd6fe17815
2018-06-21 16:06:41 +02:00
Thomas Haller
3b1b6427d1 clients/tests: add more tests showing nmcli output
Of special interest here is

  $ nmcli --mode tabular -f all dev show eth0

to look how multiple available connections are printed.
2018-06-21 13:43:16 +02:00
Beniamino Galvani
cbfe9a6e16 device: merge branch 'bg/mtu-rh1586191'
https://bugzilla.redhat.com/show_bug.cgi?id=1586191
2018-06-20 19:05:34 +02:00
Beniamino Galvani
2f8917237f device: rework mtu priority handling
If commit_mtu() is called multiple times and dev->get_configured_mtu()
returns @is_user_config=FALSE, only the first call changes the
MTU. So, for example, when the parent MTU of a VLAN changes, we apply
the new MTU only the first time.

Rework the handling of MTU in NMDevice, and store the source of the
configured MTU. When commit_mtu() is called again, we ask the subclass
a MTU to configure and apply it only if the source has higher
priority, or when the parent MTU changed.
2018-06-20 18:50:44 +02:00
Beniamino Galvani
9f8b0697de device: introduce mtu source
Instead of returning a boolean @is_user_config value from
get_configured_mtu(), return an mtu-source enum with possible values
NONE,CONNECTION. This enum will be expanded later; for now there is no
change in behavior.
2018-06-20 18:49:56 +02:00
Beniamino Galvani
d9df1f1d05 device: introduce nm_device_get_configured_mtu_from_connection()
Deduplicate similar code from devices.
2018-06-20 18:30:56 +02:00
Thomas Haller
1388569fce device: require that device-factories support at least one link-type or setting-type
If a device-factory wouldn't support any link-type or setting-type,
we would not take an additional reference to the @factory instance
(because, the factory is not added to one of the static hash tables).

As such, we would invoke the callback with a factory instance, which
is about to be destroyed immediately afterwards. That would be unusual
for device-plugins, because usually a device-plugin is never destroyed
and essentially leaked at exit.

Just don't get into that situation. All device plugins are internal API,
and they are known to support at least something. Assert for that.

(cherry picked from commit 94200b03fe)
2018-06-20 16:42:15 +02:00
Thomas Haller
aa27007ff0 device: fix leaking internal device factories
Actually, we anyway leak them, because they are added to static hash tables
which are never released. Anyway, get the ref-count right.

(cherry picked from commit 4c43d7cad3)
2018-06-20 16:42:14 +02:00
Thomas Haller
2b2e9bba74 device: suppress info logging about internal device plugins
Internal device plugins are compiled-in. In fact, none of the
internal device plugins can currently be disabled via compile
time options. The user would have to patch the sources to
not include a particular device plugin.

Hence, the available device plugins depends exclusively on the
build itself. That is not worth <info> level logging. Especially,
as it was quite verbose, logging 13 lines.

(cherry picked from commit dff157b867)
2018-06-20 16:42:14 +02:00
Thomas Haller
7713a71910 device: don't attach unused device-plugin-path to device factory
(cherry picked from commit 3798f98829)
2018-06-20 16:42:13 +02:00
Thomas Haller
94200b03fe device: require that device-factories support at least one link-type or setting-type
If a device-factory wouldn't support any link-type or setting-type,
we would not take an additional reference to the @factory instance
(because, the factory is not added to one of the static hash tables).

As such, we would invoke the callback with a factory instance, which
is about to be destroyed immediately afterwards. That would be unusual
for device-plugins, because usually a device-plugin is never destroyed
and essentially leaked at exit.

Just don't get into that situation. All device plugins are internal API,
and they are known to support at least something. Assert for that.
2018-06-20 16:36:26 +02:00
Thomas Haller
4c43d7cad3 device: fix leaking internal device factories
Actually, we anyway leak them, because they are added to static hash tables
which are never released. Anyway, get the ref-count right.
2018-06-20 16:31:18 +02:00
Thomas Haller
dff157b867 device: suppress info logging about internal device plugins
Internal device plugins are compiled-in. In fact, none of the
internal device plugins can currently be disabled via compile
time options. The user would have to patch the sources to
not include a particular device plugin.

Hence, the available device plugins depends exclusively on the
build itself. That is not worth <info> level logging. Especially,
as it was quite verbose, logging 13 lines.
2018-06-20 16:17:03 +02:00
Thomas Haller
3798f98829 device: don't attach unused device-plugin-path to device factory 2018-06-20 16:11:49 +02:00
Thomas Haller
b6ff26fb2f platform/tests: fix race in tests
Otherwise, we easily get a failure

    test:ERROR:src/platform/tests/test-cleanup.c:78:test_cleanup_internal: assertion failed (addresses6->len == 2): (1 == 2)

Avoid that by waiting for kernel to add the link-local
address.

(cherry picked from commit fb63d8d706)
2018-06-20 14:53:41 +02:00
Thomas Haller
4ca064043a platform/tests: fix generating IPv6 link local address in fake-platform
(cherry picked from commit 07a34f2404)
2018-06-20 14:53:40 +02:00
Thomas Haller
945f51d623 tests: expose current state in local context of NMTST_WAIT()
Inside the loop-handler, it can be interesting to know the current iteration,
and how much time is left.

(cherry picked from commit 86dc1f1394)
2018-06-20 14:53:39 +02:00
Thomas Haller
fb63d8d706 platform/tests: fix race in tests
Otherwise, we easily get a failure

    test:ERROR:src/platform/tests/test-cleanup.c:78:test_cleanup_internal: assertion failed (addresses6->len == 2): (1 == 2)

Avoid that by waiting for kernel to add the link-local
address.
2018-06-20 14:46:07 +02:00
Thomas Haller
07a34f2404 platform/tests: fix generating IPv6 link local address in fake-platform 2018-06-20 14:46:07 +02:00
Thomas Haller
86dc1f1394 tests: expose current state in local context of NMTST_WAIT()
Inside the loop-handler, it can be interesting to know the current iteration,
and how much time is left.
2018-06-20 14:45:27 +02:00
Francesco Giudici
844ef9fbdb merge: branch 'fg/duid_enforce_as_bool'
https://github.com/NetworkManager/NetworkManager/pull/142
(cherry picked from commit 1dba7eda7a)
2018-06-20 11:39:53 +02:00
Francesco Giudici
c7d0363bee dhcp: look for DUID in both private and global DHCP client lease files
Option to check just in NM private dhcp client specific lease files has
been dropped: either get DUID from specific DHCP plugin or just use the
provided one.

This reverts commit f054c3fcaa.

(cherry picked from commit 08116409f3)
2018-06-20 11:39:27 +02:00