Commit graph

12799 commits

Author SHA1 Message Date
Thomas Haller
ad5fdd9d62 Revert "IPv6 SLAAC: Clamp received PIO and RIO Lifetime Values"
This reverts commit 0cbd9193cd.
This reverts commit a5290915d5.
2020-04-21 08:37:48 +02:00
Thomas Haller
a88be01da2 Revert "IPv6 SLAAC: Honor small PIO Valid Lifetimes"
This reverts commit 2da092b592.
2020-04-21 08:37:03 +02:00
Beniamino Galvani
1dfd35da20 wifi: change return type of p2p-connect D-Bus method call
Fix the following error when invoking the Connect() p2p method:

 call-p2p-connect: failed with Method “fi.w1.wpa_supplicant1.Interface.P2PDevice.Connect” returned type “(s)”, but expected “()”

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit a5338affb5)
2020-04-20 17:13:39 +02:00
Thomas Haller
d78dadc9eb dns: add trust-ad DNS option only if all contributing settings agree
https://bugzilla.redhat.com/show_bug.cgi?id=1825285
(cherry picked from commit 5e47fb630b)
2020-04-20 15:55:51 +02:00
Beniamino Galvani
c5f0d325ad ifcfg-rh: add PKEY_ID to well-known keys
Fixes: 81e6fe963e ('ifcfg-rh: add functions to detect well-known ifcfg-rh keys')
(cherry picked from commit 70916a1183)
2020-04-17 09:50:40 +02:00
Antonio Cardace
2a5d9eb60b
bond: small cleanups
* Use an enum instead of a string, is faster for comparisons.
* Add debug assertions
* Have NMBondMode enum correspond to Kernel numbering
2020-04-10 17:46:22 +02:00
Beniamino Galvani
db37e530e8 ovsdb: retry calls in case of communication error with server
When the server is restarted the write to unix socket fails with
EPIPE. In such case, don't fail all the calls in queue; instead, after
a sync of the ovsdb state (through a monitor call), start processing
the queue again, including the call that previously failed.

Add a retry counter to avoid that calls are stuck in the queue forever
in a hypothetical scenario in which the write always fails.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/459
2020-04-09 17:26:18 +02:00
Beniamino Galvani
d213c3cd1a device: fix assertion failure configuring bridge ports
Fixes: 177ee2d7bf ('device/bridge: code cleanup in commit_option()')
2020-04-09 16:45:18 +02:00
Thomas Haller
177ee2d7bf device/bridge: code cleanup in commit_option() 2020-04-09 09:34:18 +02:00
Thomas Haller
36ab1e841f device/bridge: fix uninitialized variable in commit_option()
Fixes: 93e38cbe56 ('nm-setting-bridge: add 'group-address' bridge option')
2020-04-09 09:32:39 +02:00
Thomas Haller
95888e8861 dns: fix crash in rebuild_domain_lists()
Fixes: 103943776c ('dns: cleanup rebuild_domain_lists() constructing domains list')
2020-04-08 18:02:15 +02:00
Thomas Haller
9a74d2e023 dns: add FIXME comment about adding default "~" routing search domain 2020-04-08 12:41:32 +02:00
Thomas Haller
103943776c dns: cleanup rebuild_domain_lists() constructing domains list 2020-04-08 09:32:45 +02:00
Thomas Haller
c3969425ec systemd: merge branch systemd into master 2020-04-08 09:08:49 +02:00
Thomas Haller
c5189cffc1 systemd: update code from upstream (2020-04-08)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=8ff8ce62845e708186077d11eba83adae7b02e61

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files -z :/src/systemd/src/ \
                :/shared/systemd/src/ \
                :/shared/nm-std-aux/unaligned.h | \
  xargs -0 rm -f

nm_copy_sd_shared() {
    mkdir -p "./shared/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./shared/systemd/$1"
}

nm_copy_sd_core() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd_stdaux() {
    mkdir -p "./shared/nm-std-aux/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-std-aux/${1##*/}"
}

nm_copy_sd_core "src/libsystemd-network/arp-util.c"
nm_copy_sd_core "src/libsystemd-network/arp-util.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/lldp-internal.h"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd_core "src/libsystemd-network/lldp-network.c"
nm_copy_sd_core "src/libsystemd-network/lldp-network.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.c"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd_core "src/libsystemd-network/sd-lldp.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-dhcp-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp-option.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ipv4acd.h"
nm_copy_sd_core "src/systemd/sd-ipv4ll.h"
nm_copy_sd_core "src/systemd/sd-lldp.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/async.h"
nm_copy_sd_shared "src/basic/cgroup-util.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/format-util.c"
nm_copy_sd_shared "src/basic/format-util.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_random.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_syscall.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.c"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/strxcpyx.c"
nm_copy_sd_shared "src/basic/strxcpyx.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/user-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/basic/util.c"
nm_copy_sd_shared "src/basic/util.h"
nm_copy_sd_shared "src/shared/dns-domain.c"
nm_copy_sd_shared "src/shared/dns-domain.h"
nm_copy_sd_shared "src/shared/web-util.c"
nm_copy_sd_shared "src/shared/web-util.h"
nm_copy_sd_stdaux "src/basic/unaligned.h"
2020-04-08 09:02:12 +02:00
Antonio Cardace
ad052c3d67
nm-setting-bridge: add 'multicast-querier' bridge option
https://bugzilla.redhat.com/show_bug.cgi?id=1755768
2020-04-06 09:56:11 +02:00
Antonio Cardace
a685cce70a
nm-setting-bridge: add 'multicast-query-use-ifaddr' bridge option
https://bugzilla.redhat.com/show_bug.cgi?id=1755768
2020-04-06 09:56:11 +02:00
Antonio Cardace
e01d3b4c2b
nm-setting-bridge: add 'multicast-router' bridge option
Also add related unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1755768
2020-04-06 09:56:11 +02:00
Antonio Cardace
bd30491f42
nm-setting-bridge: add 'vlan-stats-enabled' bridge option
https://bugzilla.redhat.com/show_bug.cgi?id=1755768
2020-04-06 09:56:11 +02:00
Antonio Cardace
f5352ff656
nm-setting-bridge: add 'vlan-protocol' bridge option
Also add related unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1755768
2020-04-06 09:56:11 +02:00
Antonio Cardace
93e38cbe56
nm-setting-bridge: add 'group-address' bridge option
Also add related unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1755768
2020-04-06 09:56:11 +02:00
Thomas Haller
fa86fe4ee2 wifi: rework scanning-prohibited tracking for Wi-Fi companion and OLPC device
This was previously tracked via a signal "scanning-prohibited".
However, I think it was buggy, because the signal didn't specify
a GSignalAccumulator, so when a NMDeviceOlpcMesh registered a handler,
NMDeviceWifi.scanning_prohibited() was ignored.

In theory, a GObject signal decouples the target and source of the
signal and is more abstract. But more abstraction is worse, if there
is exactly one target who cares about this signal: the OLPC mesh.
And that target is well known at compile time. So, don't pretend that
NMDeviceWifi or NMDeviceOlpcMesh aren't aware that they are together in
this.

Another downside of the signal is that you don't know when scanning gets
unblocked. You can only poll and asked whether it is blocked, but there
was no mechanism how NMDeviceWifi would be notified when scanning is
no longer blocked.

Rework this. Instead, the OLPC mesh explicitly registers and unregisters
its blocking state with nm_device_wifi_scanning_prohibited_track().
2020-04-03 11:26:49 +02:00
Thomas Haller
f1da7cb452 wifi: add and use nm_device_wifi_get_scanning()
Don't read GObject properties. It's inefficient and harder to track
who calls who.
2020-04-03 11:26:49 +02:00
Thomas Haller
d2ee666dd7 wifi/iwd: drop unused signal NM_DEVICE_IWD_SCANNING_PROHIBITED 2020-04-03 11:26:49 +02:00
Thomas Haller
8cc78565b1 wifi: rename scan-interval variable to indicate they are in seconds 2020-04-03 11:26:49 +02:00
Thomas Haller
cf30e15aba wifi: parse RequestScan D-Bus arguments before authenticating request
It feels better to first parse input arguments before authenticating.
One argument for otherwise would be that we shouldn't reveal any
information about the request before authenticating it. Meaning: every
request (even with invalid arguments) should fail with
permission-denied.

However, I prefer this for minor reasons:

- what makes a valid request is no secret. And if somebody makes an
invalid request, it should fail with invalid-arguments first.

- we possibly can short cut the expensive authentication process, where
we ask PolicyKit.

- by extracting the options variant early and only pass on the SSIDs
array, we handle the encoding of the options array earlier and where
it belongs: closer to the D-Bus request that defines the meaning of
the argument.

Also, change the failure reason to return invalid-argument.
2020-04-03 11:26:49 +02:00
Thomas Haller
c1f473d342 wifi: drop workaround for bad values in nm_platform_wifi_get_quality()
This was first introduced by commit 4ed4b491fa ('2005-12-31  Dan
Williams  <dcbw@redhat.com>'), a very long time ago.

It got reworked several times, but I don't think this code makes sense
anymore. So, if nm_platform_wifi_get_quality() returns an error, we
would ignore it for three times, until we would set the strength to the
error code (presumably -1). Why? If we cannot read the strength via
nl80211/WEXT, then we should just keep whatever we got from supplicant.

Drop this.

Also, only accept the percentage if it is in a valid range from 0 to
100%. If the driver (or platform code) gives us numbers out of that
range, we have no idea what their meaning is. In that case, the value
must be fixed in the lower layers, that knows how to convert the value
from the actual meaning to the requested percentage.
2020-04-03 11:26:49 +02:00
Thomas Haller
2011392fb7 wifi: cleanup periodic_update() in "nm-device-wifi.c" 2020-04-03 11:26:49 +02:00
Thomas Haller
b10c382b1d wifi/trivial: rename function nm_supplicant_interface_state_is_operational() from upper case name 2020-04-03 11:26:49 +02:00
Thomas Haller
80e7e8845a wifi: fix and improve handling of Wi-Fi scanning state
In NMSupplicantInterface, we determine whether we currently are scanning
both on the "scanning" supplicant state and the "Scanning" property.

Extend that. If we currently are scanning and are about to clear the
scanning state, then pretend to still scan as long as we are still
initializing BSS instances. What otherwise happens is that we declare
that we finished scanning, but the NMWifiAP instances are not yet ready.
The result is, that `nmcli device wifi` will already start printing the
scan list, when we didn't yet fully process all access points.

Now, _notify_maybe_scanning() will delay switching the scanning state to
disabled, as long as we have BSS initializing (bss_initializing_lst_head).

Also, ignore the "ScanDone" signal. It's redundant to the "Scanning"
property anyway.

Also, only set priv->last_scan_msec when we switch the scanning state
off. That is the right (and only) place where the last-scan timestamp
needs updating.
2020-04-03 11:26:49 +02:00
Thomas Haller
85bccb6d28 wifi: print age of Wi-Fi access point with milliseconds precision
For a computer a second is a really long time. Rounding times
to seconds feels unnecessarily inaccurate.
2020-04-03 11:26:49 +02:00
Thomas Haller
68395ce7d5 wifi/trivial: rename field NMDeviceWifiPrivate.last_scan to last_scan_msec 2020-04-03 11:26:49 +02:00
Thomas Haller
4a302e28f5 supplicant: cleanup notify signals for combined properties in supplicant (2) 2020-04-03 11:26:49 +02:00
Thomas Haller
b480cda596 supplicant: cleanup notify signals for combined properties in supplicant
Certain properties (for example "scanning") are combined from multiple
other properties. So, we want to notify a changed signal, exactly when
something relevant changes. We also may not want to emit a signal while
we are still in the middle of changing multiple properties together.
Only at certain places we want to check and emit the signal.

Simplify the implementation for that by tracking the property value that
we currently expose, and keeping state about when it changes.
2020-04-03 11:26:49 +02:00
Thomas Haller
ebedd0d792 supplicant: log message whenever we request scanning
It's important to clearly see in the log when we actually request a scan.
2020-04-03 11:26:49 +02:00
Fernando Gont
2da092b592 IPv6 SLAAC: Honor small PIO Valid Lifetimes
This commit implements Section 4.2 of
<https://tools.ietf.org/html/draft-gont-6man-slaac-renum-05>, to improve the
reaction of IPv6 SLAAC to renumbering events.

Namely:

* It honors PIO Valid Lifetimes < 2 hours, deviating from item "e)"
  (pp. 19-20) of Section 5.5.3 of RFC4862.

[thaller@redhat.com: squash commits and adjust unit test]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/454
2020-04-02 13:19:13 +02:00
Thomas Haller
7e49f4a199 all: use wrappers for g_ascii_strtoll(), g_ascii_strtoull(), g_ascii_strtod()
Sometimes these function may set errno to unexpected values like EAGAIN.
This causes confusion. Avoid that by using our own wrappers that retry
in that case. For example, in rhbz#1797915 we have failures like:

    errno = 0;
    v = g_ascii_strtoll ("10", 0, &end);
    if (errno != 0)
        g_assert_not_reached ();

as g_ascii_strtoll() would return 10, but also set errno to EAGAIN.

Work around that by using wrapper functions that retry. This certainly
should be fixed in glib (or glibc), but the issues are severe enough to
warrant a workaround.

Note that our workarounds are very defensive. We only retry 2 times, if
we get an unexpected errno value. This is in the hope to recover from
a spurious EAGAIN. It won't recover from other errors.

https://bugzilla.redhat.com/show_bug.cgi?id=1797915
2020-04-01 17:18:37 +02:00
Thomas Haller
659ac9cc12 device/bluetooth: avoid g_ascii_strtoull() to parse capabilities
Avoid g_ascii_strtoull() calling directly. It has subtle issues, which is why
we have a wrapper for it.
2020-04-01 17:12:18 +02:00
Thomas Haller
3930ef194e ifupdown: use _nm_utils_ascii_str_to_int64() for converting netmask to string 2020-04-01 17:12:18 +02:00
Thomas Haller
9cbf4c2825 ifcfg-rh/tests: add unit test for reading DEVTIMEOUT (connection.wait-device-timeout) 2020-04-01 17:12:18 +02:00
Thomas Haller
2e4771be5e ifcfg: strip whitespaces around "DEVTIMEOUT"
Be more graceful and allow whitespaces around the floating point number
for DEVTIMEOUT. Note that _nm_utils_ascii_str_to_int64() is already graceful
against whitespace, so also be it with the g_ascii_strtod() code path.
2020-04-01 17:12:18 +02:00
Thomas Haller
d506823d4f initrd: fix setting VLan ID in reader_parse_vlan()
g_ascii_strtoull() returns a guint64, which is very wrong to directly pass
to the variadic argument list of g_object_set(). We expect a guint there
and need to cast.

While at it, use _nm_utils_ascii_str_to_int64() to parse and validate the input.
2020-04-01 17:12:18 +02:00
Thomas Haller
0cbd9193cd ndisc/trivial: stype fixes in receive_ra() 2020-04-01 15:12:53 +02:00
Fernando Gont
a5290915d5 IPv6 SLAAC: Clamp received PIO and RIO Lifetime Values
This commit implements Section 4.1.2 of
<https://tools.ietf.org/html/draft-gont-6man-slaac-renum-05>, to improve
the reaction of IPv6 SLAAC to renumbering events.

Namely:

* It caps the Preferred Lifetime of PIOs to the "Router Lifetime" value
  of the corresponding Router Advertisement Message, and the Valid Lifetime
  of PIOs to 48 * Router Lifetime.

Additionally, it also caps the Valid Lifetime of RIOs to "Router Lifetime".

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/455
2020-04-01 15:11:11 +02:00
Thomas Haller
46dd4d0fbf meson: merge branch 'inigomartinez/meson-license'
Add SPDX license headers for meson files.

As far as I can tell, according to RELICENSE.md file, almost everybody
who contributed to the meson files agreed to the LGPL-2.1+ licensing.
This entails the vast majority of code in question.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397
2020-03-28 12:45:19 +01:00
Thomas Haller
ff814923eb core: prevent multiple attempts to create default wired connection
Scenario:

  - have ethernet connection as unmanaged.
  - create (or have) a suitable profile for the connection.
  - make the device as managed. No default wired connection gets
    created.
  - delete the profile.

Note that NMManager does in manager_device_state_changed():

»···if (NM_IN_SET (new_state,
»···               NM_DEVICE_STATE_UNAVAILABLE,
»···               NM_DEVICE_STATE_DISCONNECTED))
»···»···nm_settings_device_added (priv->settings, device);

that means, when the device the next time goes through
UNAVAILABLE/DISCONNECTED states, we will suddenly create the
default "Wired connection 1" profile.

That doesn't seem right. When a device is suitable to have a
default-wired connection, we should only check once whether to
create it. We should not retry that later. The !no-auto-default
mechanism exists so we can start NetworkManager without a profile for
the device. It doesn't mean that we later one (after previously deciding
not to create a profile), we still create it.

https://bugzilla.redhat.com/show_bug.cgi?id=1687937

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/450
2020-03-28 11:01:05 +01:00
Beniamino Galvani
c84a4579b2 initrd: fix build error with assertions disabled
$ meson -Dmore_asserts=0 meson-build
$ ninja -C meson-build
[712/859] Compiling C object 'src/initrd/b383957@@nmi-core@sta/nmi-cmdline-reader.c.o'.
../src/initrd/nmi-cmdline-reader.c: In function ‘nmi_cmdline_reader_parse’:
../src/initrd/nmi-cmdline-reader.c:871:4: warning: ‘s_ip’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  871 |    nm_setting_ip_config_add_dns (s_ip, ns);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/initrd/nmi-cmdline-reader.c:835:21: note: ‘s_ip’ was declared here
  835 |  NMSettingIPConfig *s_ip;
      |                     ^~~~

Fixes: 25a2b6e14f ('initrd: rework command line parsing')
2020-03-27 16:27:06 +01:00
Arnaud Ferraris
0cf7f1d2f5 nm-modem: don't fail if secrets request times out
When starting with a locked modem, it may take some time for the user to
enter the PIN code, leading to the secrets request timing out. In that
case, we want the connection activation to be retried automatically once
the modem is unlocked, which can't be achieved if we propagate the error,
as the device will change state to 'failed'.

This patch ignores the 'no-secrets' error, as it means either the
request has timed out, or the user cancelled the request without
notifying NetworkManager. By doing this, we allow the connection to be
re-activated once the modem is unlocked.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
2020-03-27 11:01:41 +01:00
Arnaud Ferraris
df20a98aa4 nm-device-modem: deactivate device when modem unlocked
When the modem is unlocked externally to NetworkManager, it is kept in
the 'need-auth' state. The current connection activation continues as
if nothing had changed, and the secrets request for the PIN code (which
is no longer necessary) eventually times out. The device state is then
changed to 'failed', meaning there won't be a new try at activating the
default connection automatically.

In order to prevent this, and retry activating the default connection
when the modem gets unlocked, we change the device state to
'deactivating' when we identify the modem has been unlocked externally.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
2020-03-27 11:01:41 +01:00
Beniamino Galvani
99e0188886 initrd: add 'reader_' prefix to functions acting on Reader 2020-03-26 22:03:56 +01:00