Commit graph

25479 commits

Author SHA1 Message Date
Thomas Haller
24b2fbbfc7 shared: add nm_gbytes_get_empty() singleton getter
(cherry picked from commit 32664c72a5)
2020-04-29 12:29:55 +02:00
Thomas Haller
616c18a612 shared: add nm_gbytes_hash() and nm_gbytes_equal()
(cherry picked from commit 2a26562ec8)
2020-04-29 12:29:55 +02:00
Thomas Haller
e62dcb3c6b wifi/iwd: merge branch 'andhe:iwd-connect-hidden'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/285

(cherry picked from commit d0d91ed6ac)
2020-04-29 11:45:00 +02:00
Andreas Henriksson
4bb0e48b13 iwd: use ConnectHiddenNetwork to provision hidden network
The Station.ConnectHiddenNetwork will provision a network in the iwd
known-networks list. This should allow us to later use the
Network.Connect interface to connect in the future.
(Note: Attempts to use Station.ConnectHiddenNetwork on already provisioned
networks, i.e. networks iwd knows about, will fail.)

This commit squashed several fixups made by thaller.

(cherry picked from commit 69aeed4bdc)
2020-04-29 11:45:00 +02:00
Andreas Henriksson
dc115bf406 iwd: support connecting to hidden networks
Newer versions of iwd has supported connecting to hidden networks for a
while now. There's a separate "connect-hidden" command in iwctl that
needs to be used instead of the regular "connect" command.
The equivalent on dbus is to use ConnectHiddenNetwork instead of
Connect on the Station interface. NetworkManager however uses the
Network interface and given we the explicit SSID usage we can connect
to hidden networks with that.

This change disabled the explicit check that disallows even attempting
hidden networks when using iwd.

This has been tested to work with a previously known hidden network.
Tests connecting to a previously unknown network has failed.

(cherry picked from commit cd095f49dc)
2020-04-29 11:44:59 +02:00
Thomas Haller
da757f80cc libnm/doc: fix spelling in nm_client_add_and_activate_connection2() documentation
(cherry picked from commit c8a9703130)
2020-04-28 18:36:47 +02:00
Beniamino Galvani
0344a97105 device: flush IP configuration of slaves during activation
If a device only has an IPv6 link-local address, we don't generate an
assumed connection. Therefore, when a new slave connection (without IP
configuration) is activated on the device, we don't deactivate any
existing connection and the link-local address remains configured.

The IP configuration of an activated slave should be predictable and
not depend on the previous state; let's flush addresses and routes on
activation.

https://bugzilla.redhat.com/show_bug.cgi?id=1816517
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/480
(cherry picked from commit e302f5ff77)
2020-04-28 10:00:28 +02:00
Thomas Haller
cfc79124ef vpn: merge branch 'th/vpn-ipv6-addr-fix-assert'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/482

(cherry picked from commit d9dbe88427)
2020-04-28 09:42:32 +02:00
Thomas Haller
61e65e42dc vpn: cleanup loop in nm_vpn_connection_ip6_config_get()
I find it simpler to follow the pattern of checking conditions and
"erroring out", by going to the next entry. The entire loop already
behaves like that.

(cherry picked from commit f89b841b37)
2020-04-28 09:42:32 +02:00
Thomas Haller
c7586e6388 vpn: clear host part of IPv6 routes received from VPN plugin
Kernel would reject adding a route with a destination host part not
all zero. NetworkManager generally coerces such routes and there
are assertions in place to ensure that.

We forgot to ensure that for certain IPv6 routes from VPN plugins.
This can cause an assertion failure and wrong behavior.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/425

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/482
(cherry picked from commit b437bb4a6e)
2020-04-28 09:42:32 +02:00
Thomas Haller
a352a40a08 libnm/doc: clarify use of "ipv[46].gateway in nm-settings manual
(cherry picked from commit fc837cbb6f)
2020-04-26 13:30:13 +02:00
Michael Stapelberg
571520cf05 libnm/meson.build: stop using env -i (just env)
env -i starts with an empty environment, which is undesired when the build
environment needs certain environment variables to function.

One such example is a custom PYTHONPATH, which gets dropped by env -i and
results in the nm-settings-docs.xml generator not finding the gi Python module.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/478
(cherry picked from commit d4e33a0c2b)
2020-04-26 11:33:55 +02:00
Thomas Haller
dbe7b8749d wifi: merge branch 'th/cli-trigger-scan-retry'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/476

(cherry picked from commit fe84237cf0)
2020-04-24 19:36:53 +02:00
Thomas Haller
2eb398648f wifi: add callback to nm_supplicant_interface_request_scan()
While we request a scan, we are not yet actually scanning. That means, the supplicant's
"scanning" property will only change to TRUE a while after we initiate the scan. It may
even never happen.

We thus need to handle that the request is currently pending and react when the
request completes.

(cherry picked from commit 16c1869476)
2020-04-24 19:36:53 +02:00
Thomas Haller
6d0ea83949 wifi: add more trace logging to supplicant interface
(cherry picked from commit 8ecc325f29)
2020-04-24 19:36:53 +02:00
Thomas Haller
455d42c3bd cli: repeatedly trigger Wi-Fi scans while waiting for scan result
NetworkManager will reject scan requests, if it is currently scanning.
That is very wrong. Even if NetworkManager wants to ratelimit scan
requests or not scan at critical moments, it should never reject a
request, but remember and start scanning as soon as it can.
That should be fixed.

But regardless, also nmcli can do better.

If you issue

  $ nmcli device wifi list --rescan yes

once, it works as expected.

If you issue it again right after, the scan request of nmcli will be
rejected. But nmcli cannot just merely complete and print the result.
Instead, it will wait in the hope that a scan result will be present
soon. But if the request was simply rejected, then the result will
never come, and nmcli hangs for the 15 seconds timeout.

Instead, repeatedly re-trigger scan requests, in the hope that as soon
as possible we will be ready.

(cherry picked from commit 27e2d51abc)
2020-04-24 19:36:53 +02:00
Thomas Haller
0119fa8c3d shared: add nm_utils_invoke_on_timeout()
Add nm_utils_invoke_on_timeout() beside nm_utils_invoke_on_idle().
They are fundamentally similar, except one schedules an idle handler
and the other a timeout.

Also, use the current g_main_context_get_thread_default() as context
instead of the singleton instance. That is a change in behavior, but
the only caller of nm_utils_invoke_on_idle() is the daemon, which
doesn't use different main contexts. Anyway, to avoid anybody being
tripped up by this also change the order of arguments. It anyway
seems nicer to first pass the cancellable, and the callback and user
data as last arguments. It's more in line with glib's asynchronous
methods.

Also, in the unlikely case that the cancellable is already cancelled
from the start, always schedule an idle action to complete fast.

(cherry picked from commit cd5157a0c3)
2020-04-24 19:36:53 +02:00
Beniamino Galvani
02a31e71af man: mention the meaning of may-fail in the nm-online man page
Commit b2a0738765 ('man: improve manual page for nm-online') removed
the explanation of how may-fail can be used to wait for a specific
address family during boot. I found that part useful. Add it again,
adapting it to the new behavior introduced by 1e5206414a ('device:
don't delay startup complete for pending-actions "autoconf", "dhcp4"
and "dhcp6"').

https://bugzilla.redhat.com/show_bug.cgi?id=1825666
(cherry picked from commit 25583de20b)
2020-04-23 17:43:58 +02:00
Thomas Haller
fae37528d9 cli: unset "ipv[46].never-default" when setting "ipv[46].gateway"
Since commit c1907a218a ('libnm-core: remove gateway when
never-default=yes in NMSettingIPConfig'), the gateway gets normalized
away when the profile has never-default set.

That means,

  $ nmcli connection modify "$PROFILE" ipv4.never-default yes ipv4.gateway 192.168.77.1

does not set the gateway. Likewise, if your profile has already never-default
enabled,

  $ nmcli connection modify "$PROFILE" ipv4.gateway 192.168.77.1

will have no effect. That is confusing and undesirable.

Note that we don't adjust the GObject property setter for "gateway" to clear
never-default. I feel, setting one property in libnm should preferably
not unset another (there are exceptions to the rule, like for team
properties). However, for nmcli it's clear in which order properties
are set, so this change is right for the client tool.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/475
(cherry picked from commit 411255d51f)
2020-04-22 21:06:24 +02:00
Thomas Haller
5a06b1b531 wireguard: merge branch 'th/wireguard-default-route-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/474

(cherry picked from commit ec1635dad4)
2020-04-22 15:05:39 +02:00
Thomas Haller
a9d726b447 NEWS: update
(cherry picked from commit a873c438a8)
2020-04-22 15:05:39 +02:00
Thomas Haller
112e8aff5b wireguard: don't let explicit gateway override WireGuard's peer route
The profile's "ipv4.gateway" and "ipv6.gateway" has only one real
purpose: to define the next hop of a static default route.

Usually, when specifying a gateway in this way, the default route from
other addressing methods (like DHCPv4 or IPv6 autoconf) gets ignored.

If you have a WireGuard peer with "AllowedIPs=0.0.0.0/0" and
"wireguard.peer-routes" enabled, NetworkManager would automatically add
a route to the peer. Previously, if the user also set a gateway, that
route was suppressed.

That doesn't feel right. Note that configuring a gateway on a WireGuard
profile is likely to be wrong to begin with. At least, unless you take
otherwise care to avoid routing loops. If you take care, setting a
gateway may work, but it would feel clearer to instead just add an
explicit /0 manual route instead.

Also, note that usually you don't need a gateway anyway. WireGuard is a
Layer 3 (IP) tunnel, where the next hop is alway just the other side of
the tunnel. The next hop has little effect on the routes that you
configure on a WireGuard interface. What however matters is whether a
default route is present or not.

Also, an explicit gateway probably works badly with "ipv[46].ip4-auto-default-route",
because in that case the automatism should add a /0 peer-route route in a
separate routing table. The explicit gateway interferes with that too.

Nonetheless, without this patch it's not obvious why the /0 peer
route gets suppressed when a gateway is set. Don't allow for that, and
always add the peer-route.

Probably the profile's gateway setting is still wrong and causes the
profile not to work. But at least, you see all routes configured, and
it's clearer where the (wrong) default route to the gateway comes from.

(cherry picked from commit 115291a46f)
2020-04-22 15:05:39 +02:00
Thomas Haller
0cb5343ce2 wireguard: suppress automatic "wireguard.peer-routes" for default routes if "ipv[46].never-default" is enabled
Enabling both peer-routes and never-default conflicts with having
AllowedIPs set to a default route. Let never-default win.

(cherry picked from commit 5da82ee3ea)
2020-04-22 15:05:39 +02:00
Thomas Haller
7e598a8aa7 core: add NMIPConfigFlags for NMIPConfig flags
This will be useful to set future options on the NMIPConfig.

Yes, the code duplication of NMIP[46]Config is horrible. Needs
to be unified in the future.

(cherry picked from commit e8b86f8445)
2020-04-22 15:05:39 +02:00
Thomas Haller
aa759765c5 platform: avoid undefined behavior comparing unrelated pointers in nmp_object_id_cmp()
Pointers cannot in general be compared directly. Cast to an int first
to avoid the undefined behavior.

(cherry picked from commit b2a5b179fd)
2020-04-22 09:53:17 +02:00
Thomas Haller
198563ad93 shared: add NM_CMP_DIRECT_PTR() macro
(cherry picked from commit 95ccfdb69a)
2020-04-22 09:53:16 +02:00
Beniamino Galvani
93b130c05a bluetooth: disconnect signal on dispose
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/417

Fixes: 4154d9618c ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data')
(cherry picked from commit 5c547fdab3)
2020-04-22 09:22:45 +02:00
Beniamino Galvani
2d06a4e11a supplicant: set error when interface creation fails and was cancelled
https://bugzilla.redhat.com/show_bug.cgi?id=1823164

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit fb023cc6e8)
2020-04-21 17:27:49 +02:00
Beniamino Galvani
3a0d817f69 dns: fix handling of trust-ad option
Fixes: 5e47fb630b ('dns: add trust-ad DNS option only if all contributing settings agree')
(cherry picked from commit cb9a6f3b92)
2020-04-21 10:55:11 +02:00
Beniamino Galvani
4cf63dfa15 dhcp-helper: retry in case of failure connecting to D-Bus unix socket
Connecting to the unix socket can fail with EAGAIN if there are too
many pending connections and the server can't accept them in time
before reaching backlog capacity. Ideally the server should increase
the backlog length, but GLib doesn't provide a way to change it for a
GDBus server. Retry for up to 5 seconds in case of failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1821594
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/471
(cherry picked from commit eefe5dacaa)
2020-04-21 08:57:30 +02:00
Thomas Haller
3192f65d3b ndisc: merge branch 'th/revert-ipv6-slaac-lifetimes' into nm-1-24
These two changes are from a draft. They may not yet be ready for our
1.24.0 stable release. Revert the change for now.

Note that for current "master" (1.25.0-dev), the change is still in
place. We will decide what to do about it before 1.26.0 release.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/396#note_462123
2020-04-21 08:43:23 +02:00
Thomas Haller
5409db9fbd NEWS: update 2020-04-21 08:43:11 +02:00
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
4938299a9b libnm: cleanup _nm_utils_dns_option_validate()
Avoid unnecessary string copies. Most option don't have a delimiter
and numerical argument, and there is no need to clone the string.

(cherry picked from commit 61a97f8b0f)
2020-04-20 15:55:52 +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
Thomas Haller
ccb043d78c libnm: document supported "ipv[46].dns-option" values
(cherry picked from commit e261e941fd)
2020-04-20 15:55:50 +02:00
Thomas Haller
24ab6b6cdc tests: abort test runner if exec fails
(cherry picked from commit 2ad8e6acae)
2020-04-20 11:52:11 +02:00
Beniamino Galvani
5b83609b01 libnm-core: add 'no-reload' and 'trust-ad' resolv.conf options
https://sourceware.org/git/?p=glibc.git;a=blob;f=resolv/res_init.c;h=95dce098aa7ec80f2e36f5c25022641d65e1d5e5;hb=9ea3686266dca3f004ba874745a4087a89682617#l681

https://bugzilla.redhat.com/show_bug.cgi?id=1825285
(cherry picked from commit 40b2cf7a0c)
2020-04-20 11:32:56 +02:00
Antonio Cardace
8d3b3a55b3 clients: merge branch 'ac/cli_hide_if_default'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/470

(cherry picked from commit f957359421)
2020-04-20 08:54:56 +02:00
Antonio Cardace
aacf8bd27d ethtool: refactor how options are hidden if default
Just use the new flag NMMetaPropertyInfo.

(cherry picked from commit a5916de599)
2020-04-20 08:54:55 +02:00
Antonio Cardace
486161cff4 bridge: make some advanced options hidden if default
The options are:
  * group-address
  * multicast-querier
  * multicast-query-use-ifaddr
  * multicast-router
  * vlan-stats-enabled
  * vlan-protocol

(cherry picked from commit 3af07fd415)
2020-04-20 08:54:55 +02:00
Thomas Haller
fc582312f7 cli: let _print_fill() hide option if NM_META_ACCESSOR_GET_OUT_FLAGS_HIDE is set
Regardless, whether the option is also currently the default.

(cherry picked from commit 69eca25391)
2020-04-20 08:54:55 +02:00
Antonio Cardace
fd37111986 clients: allow properties to be hidden if they have the default value
(cherry picked from commit b94fcb2a94)
2020-04-20 08:54:55 +02:00
Gilles Dartiguelongue
7b0130d5d7 build: remove subshells and fix invalid test syntax
Signed-off-by: Gilles Dartiguelongue <eva@gentoo.org>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/472
(cherry picked from commit e073491b9c)
2020-04-20 08:54:38 +02:00
Thomas Haller
1667be7cf5 contrib/rpm: fix spec file using bare words
error: bare words are no longer supported, please use "...":  no != "yes"
  error:                                                        ^
  error: /builds/NetworkManager/NetworkManager/contrib/fedora/rpm/NetworkManager.20200418-170120.dp5cp5/SPECS/NetworkManager.spec:596: bad %if condition:  no != "yes"

(cherry picked from commit ed94ab6e23)
2020-04-19 21:45:05 +02:00
Thomas Haller
c869d792a2 contrib/rpm: fix spec file using bare words
error: bare words are no longer supported, please use "...":  no != yes
  error: /builds/NetworkManager/NetworkManager/contrib/fedora/rpm/NetworkManager.20200418-163008.VM582H/SPECS/NetworkManager.spec:596: bad %if condition:  no != yes

(cherry picked from commit be78a12012)
2020-04-19 21:45:04 +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
Thomas Haller
f00d306ae7 keyfile: minor cleanup handling error in read_array_of_uint()
Why "if (length > G_MAXUINT)"? This is never going to hit. Also,
we probably should actual missing keys handle differently from
empty lists. If @error is set, return without setting the property.

(cherry picked from commit 2cf31bfef0)
2020-04-15 22:41:02 +02:00