Commit graph

26916 commits

Author SHA1 Message Date
Thomas Haller
ddb69b211c
shared/tests: add nmtst_g_source_nop() helper
(cherry picked from commit ca2b79d9aa)
2020-11-23 15:26:46 +01:00
Thomas Haller
4d572bea7e
platform/tests: better handling "timeout_msec" argument in nmtst_main_context_iterate_until()
nmtst_main_context_iterate_until() is a macro, and we don't want to restrict the
valid integer type (or range) of the "timeout_msec" argument.

In particular, if the user calculates a timeout with "timestamp_msec -
now_msec", the resulting "timeout_msec" might be a negative gint64.
We should handle that gracefully, and not let it be cast to a huge
unsigned int.

(cherry picked from commit 6cb6888404)
2020-11-23 15:19:35 +01:00
Thomas Haller
b6a9242b1a
dns: fix accessing NULL domains.reverse array in rebuild_domain_lists()
Fixes: fbf1683c1a ('dns: more debug logging for DNS settings in rebuild_domain_lists()')
(cherry picked from commit 937c8a4669)
2020-11-20 22:52:54 +01:00
Thomas Haller
9e83dafda4
dns: merge branch 'th/dns-resolved-fix-exclusive'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/687

(cherry picked from commit 4f19fd6ce2)
2020-11-20 19:14:33 +01:00
Thomas Haller
ab0dcafb6e
dns: set first Domains/DefaultRoute in systemd-resolved before DNS
(cherry picked from commit 95017dccdd)
2020-11-20 19:14:33 +01:00
Thomas Haller
3ce2ea7f12
dns: more debug logging for DNS settings in rebuild_domain_lists()
(cherry picked from commit fbf1683c1a)
2020-11-20 19:14:09 +01:00
Thomas Haller
b8dab47705
dns: fix handling default routing domains with systemd-resolved
We used to set "~." domains for all devices that should be used for
resolving unknown domains.

Systemd-resolved also supports setting "SetLinkDefaultRoute()".
We should only set the wildcard domain if we want that this
interface is used exclusively. Otherwise, we should only set
DefaultRoute. See ([1], [2], [3], [4]).

Otherwise the bad effect is if other components (wg-quick) want
to set exclusive DNS lookups on their link. That is achieved by
explicitly adding "~." and that is also what resolved's
`/usr/sbin/resolvconf -x` does. If NetworkManager sets "~." for
interfaces that are not important and should not be used exclusively,
then this steals the DNS requests from those external components.

In NetworkManager we know whether a link should get exclusive lookups
based on the "ipv[46].dns-priority" setting.

[1] https://www.freedesktop.org/software/systemd/man/org.freedesktop.resolve1.html
[2] https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
[3] https://github.com/systemd/systemd/issues/17529#issuecomment-730522444
[4] https://github.com/systemd/systemd/pull/17678

(cherry picked from commit ee9fab0361)
2020-11-20 19:10:44 +01:00
Thomas Haller
83c760014e
dns: assert domains are unset at start of rebuild_domain_lists()
(cherry picked from commit a875d154de)
2020-11-20 19:10:44 +01:00
Thomas Haller
0bfc2b6db9
dns: assert that priorities in rebuild_domain_lists() are increasing
This is nm_assert(). The compiler should be able to completely eliminate
this code in production.

(cherry picked from commit 05f8ccc817)
2020-11-20 19:10:44 +01:00
Thomas Haller
2502b88511
dns: cleanup handling of shadowed priorities rebuild_domain_lists()
domain_is_shadowed() only works, because we pre-sort all items. When
we call domain_is_shadowed(), then "priority" must be not smaller than
any priority already in the dictionary.

Let's add an nm_assert() for that.

While at it, I also found it ugly to rely on

  GPOINTER_TO_INT(g_hash_table_lookup(ht, domain))

returning zero to know whether the domain is tracked. While more
cumbersome, we should check whether the value is in the hash (and not).
Not whether the value does not translate to zero.

Add domain_ht_get_priority() for that.

(cherry picked from commit 5902f1c91f)
2020-11-20 19:10:43 +01:00
Thomas Haller
59d48fcc35
dns: track NMDnsConfigData as keys of a dictionary
There is unnecessary overhead of tracking a separate
key and value in a GHashTable.

Use g_hash_table_add().

(cherry picked from commit d10d96a45c)
2020-11-20 19:10:43 +01:00
Thomas Haller
795eca6e1b
dns: cleanup allocation of NMDnsConfigData and NMDnsIPConfigData
(cherry picked from commit 190eeb5e9f)
2020-11-20 19:10:43 +01:00
Thomas Haller
0464c36a02
core/ovs: fix leak of "NMOvsdbPrivate.db_uuid
Also, never update the value to %NULL. If the current
message does not contain a UUID, keep the previous one.

Fixes: 830a5a14cb ('device: add support for OpenVSwitch devices')
(cherry picked from commit 609b08e2eb)
2020-11-19 14:33:38 +01:00
Thomas Haller
b9f802122a
build: fix handling NMTST_SKIP_PYTHON_BLACK for skipping make check-python-black test
Fixes: c537852231 ('build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1')
(cherry picked from commit ebbc2c9c0d)
2020-11-19 14:33:35 +01:00
Andrew Zaborowski
03b63a893f
iwd: Fix a use after free
In connection_removed we use the id.name that was being g_freed a few
lines further down.

Fixes: bea6c40367 ('wifi/iwd: handle forgetting connection profiles')
(cherry picked from commit c1ff06e119)
2020-11-19 14:33:32 +01:00
Thomas Haller
d535da216c
dns: fix _dns_manager_set_ip_config() for missing device
Fixes: 395665902b ('dns: don't apply DNS configuration for external connections')
(cherry picked from commit adaeb7a872)
2020-11-19 09:29:17 +01:00
Thomas Haller
ee4e679bc7
dns: don't apply DNS configuration for external connections
External connections are devices that are configured outside of
NetworkManager. Such devices should be mostly ignored and not
be interfered with.

Note that we tend to create external connection profiles for
such devices. That happens for example if you use wg-quick to
manage a WireGuard interface outside of NetworkManager. But it
really happens for any interface.

This generated profile has no DNS configuration. Unless we use
the systemd-resolved backend, they thus don't contribute to the DNS
settings (which is fine).

However, with systemd-resolved, NetworkManager would also reset
the DNS configuration of those external interfaces. That is clearly
wrong. NetworkManager should only care about the interfaces that it
actively manages and leave others alone.

How to reproduce: use systemd-resolved and configure an interface outside
of NetworkManager. Note that `nmcli device` shows the state as
"connected (externally)". Note that `resolvectl` shows the DNS configuration
on that external interface. Do something in NetworkManager to trigger
a DNS update (e.g. SIGHUB or reactivate a profile). Note in `resolvectl`
that the external interface's DNS configuration was wiped.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/563#note_673283
(cherry picked from commit 395665902b)
2020-11-17 18:51:59 +01:00
Aleksander Morgado
e0da93172f
wwan: update default connection timeout to 200s
The following merge request in ModemManager introduces a more or less
common timeout value for the connection attempts in all plugin and
protocol implementations:

  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/391

The value chosen by default for the steps that may take long to
complete in a connection attempt is 180s, and 120s for the steps in
the disconnection path.

Until now, every different plugin or protocol had a different timeout
value, all of them <= 180s, and with that change in ModemManager, the
values are now aligned for all.

Note, though, that this does not mean that a connection attempt will
take always less than 180s, as there may be multiple other steps in
addition to the one that took the maximum timeout. The value chosen
for NetworkManager is a compromise between the new defaults from MM
and what the user would expect under e.g. very low quality conditions.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/678
(cherry picked from commit 5b7ce438d9)
2020-11-16 16:08:30 +01:00
Beniamino Galvani
cd58512ba3 dns: sd-resolved: fix hash table initialization
The hash table was not initialized if there was no D-Bus connection at
the time of object creation.

Fixes: f70ee67058 ('dns: sd-resolved: reset interface configuration on deactivation')

https://bugzilla.redhat.com/show_bug.cgi?id=1894839
(cherry picked from commit d6457902d1)
2020-11-09 08:59:01 +01:00
Antonio Cardace
5d63508bb1
merge branch 'ac/bridge_mtu_autoadjust' into master
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/656

(cherry picked from commit c4b6962ed2)
2020-11-02 17:47:27 +01:00
Antonio Cardace
864872e9a8
bridge: force (hack)-set of the MTU when explicitly set in the profile
Kernel does a auto-mtu adjusting process whenever a port is added/removed from
the bridge, this can cause issues when NM wants to explicitly set an MTU which is
equal to the bridge default one (1500) because if later a port is added with a
different MTU the kernel will assign the bridge that port's MTU resulting in the bridge
runtime configuration differing from the bridge's NM connection profile.

What we can do is to always apply the MTU manually for the bridge (if explicitly
set by the profile), after doing so the kernel won't modify the MTU anymore,
which is what we want, problem is that kernel won't actually apply the MTU
to the netdev if it's not actually changing so we first apply it to
MTU-1 and then to the desired value.

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

Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit e23798a5e5)
2020-11-02 17:47:26 +01:00
Antonio Cardace
8d8017a620
bridge: set MTU at link creation time
https://bugzilla.redhat.com/show_bug.cgi?id=1778590

Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit 516c623618)
2020-11-02 17:47:26 +01:00
Antonio Cardace
05e8b018ec
platform: allow setting the MTU at link creation time
Add a parameter to the 'link_add()' virtual function so that
the MTU will be configured (via netlink) by the kernel when
creating the link.

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

Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit ba2ee46254)
2020-11-02 17:47:26 +01:00
Beniamino Galvani
a9c952d34c dns: sd-resolved: reset interface configuration on deactivation
If an update doesn't contain an interface but the previous update did,
the systemd-resolved DNS plugin must send a request to clear the
previous configuration. Otherwise the previous DNS configuration would
persist even after interface deactivation.

https://bugzilla.redhat.com/show_bug.cgi?id=1888229
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/662
(cherry picked from commit f70ee67058)
2020-10-29 17:26:50 +01:00
Thomas Haller
40edd49025
device/wifi: don't reset the SSID of a NMWifiAP to unknown
For hidden networks, we usually don't have an SSID. We try to match
and fill the SSID based on the profiles that we have:

  <debug> [1603798852.9918] device[6b383dca267b6878] (wlp2s0): matched hidden AP AA:BB:CC:DD:EE:FF => "SSID"

However, we should not clear that value again on the next update:

  <trace> [1603798856.5724] sup-iface[66c1a0883a262394,0,wlp2s0]: BSS /fi/w1/wpa_supplicant1/Interfaces/0/BSSs/3 updated
  <debug> [1603798856.5726] device[6b383dca267b6878] (wlp2s0): wifi-ap: updated AA:BB:CC:DD:EE:FF (none)

Once we have a SSID, we can only update it to a better value,
but not clear it.

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

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit eb36380335)
2020-10-27 14:11:39 +01:00
Fernando Fernandez Mancera
d28133ad0d Makefile: remove "libnm.actions" explicitly when uninstalling
On Fedora 33 when compiling NetworkManager it is failing with the
following error:

```
ERROR: files left in build directory after distclean:
./docs/libnm/libnm.actions
make[1]: *** [Makefile:18427: distcleancheck] Error 1
make[1]: Leaving directory '/builddir/nm-build/NetworkManager/NetworkManager-1.27.90/_build/sub'
make: *** [Makefile:18356: distcheck] Error 1
Error make distcheck
```

Adding the file to the DISTCLEANFILES will enforce the removal of this
file.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/659
(cherry picked from commit 9a935e516e)
2020-10-26 15:57:52 +01:00
Thomas Haller
2bfe9becd9
shared: introduce opaque type NMUtilsUserData for nm_utils_user_data_pack()
This makes the usage slightly more type safe.

(cherry picked from commit 6e44842dc6)
2020-10-22 20:54:43 +02:00
Antonio Cardace
50adaf7414
manager: fix very bad usage of 'nm_utils_user_data_unpack'
This results in the args of 'nm_utils_user_data_unpack'
containing random data potentially also from the
previous stack-frame which is really really bad.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
Fixes: b50702775f ('device: implement auth-request as async operation nm_manager_device_auth_request()')
(cherry picked from commit b6a18e0593)
2020-10-22 20:54:41 +02:00
David Rheinsberg
eac2b67052
c-rbtree: align CRBTree with CRBNode
We sometimes store pointers to `CRBTree` in `CRBNode*` variables, so we
must make sure CRBTree has matching alignment guarantees. We already
check for that with static-assertions.

This commit aligns CRBTree with CRBNode for 2-byte aligned machines.
While at it, add a short comment explaining what the unions are for.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>

c795b7657f
(cherry picked from commit 1250fcc2b1)
2020-10-21 10:41:15 +02:00
Thomas Haller
72dd79e817
c-rbtree: fix struct alignment of CRBTree on m68k architectures
On m68k, 32bit integer are aligned to only 2 bytes. This breaks
assumptions and a static assertion of c-rbtree.

Explicitly require that the first field is aligned to at least 4 bytes.
This fixes the build and ensures that all valid pointers to a CRBTree have
the lowest two bits unset (so they can be used for storing 2 additional flags).

Use a union instead of aligning __parent_and_flags itself. That is
because alignas() cannot lower the natural alignment, so if we would
want to align __parent_and_flags, we could only do

  alignas(sizeof(unsigned long) > 4 ? sizeof(unsigned long) : 4)

That would not be correct if "long" is 8 bytes long but had a natural
alignment of only 4. The union allows us to specify an alignment
of at least 4, but otherwise follow natural alignment.

10d973a9e6
(cherry picked from commit 143130066b)
2020-10-21 10:41:14 +02:00
Beniamino Galvani
07c80ceb68 release: bump version to 1.27.91 (1.28-rc2) (development) 2020-10-20 18:12:12 +02:00
Beniamino Galvani
f02dbdb0b8 NEWS: update 2020-10-20 17:14:35 +02:00
Beniamino Galvani
f091730ebc initrd: generate infiniband connections
Generate infiniband connections based on the interface name or MAC
address length.

https://bugzilla.redhat.com/show_bug.cgi?id=1883173
(cherry picked from commit 317171ed6e)
2020-10-20 09:27:08 +02:00
Thomas Haller
d585ccdb7c
shared: fix NM_CAST_STRV_CC() for "char **const" pointers
clang-3.4.2-9.el7.x86_64 otherwise fails:

    ../src/devices/wifi/nm-wifi-p2p-peer.c:410:44: error: controlling expression type 'const char **const' not compatible with any generic association type
        if (!nm_utils_strv_equal(priv->groups, peer_info->groups)) {
                                               ^~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-shared-utils.h:1689:78: note: expanded from macro 'nm_utils_strv_equal'
    #define nm_utils_strv_equal(strv1, strv2) (nm_utils_strv_cmp_n((strv1), -1, (strv2), -1) == 0)
                                                                                 ^
    ../shared/nm-glib-aux/nm-shared-utils.h:1687:74: note: expanded from macro 'nm_utils_strv_cmp_n'
        _nm_utils_strv_cmp_n(NM_CAST_STRV_CC(strv1), (len1), NM_CAST_STRV_CC(strv2), (len2))
                                                                             ^
    ../shared/nm-glib-aux/nm-macros-internal.h:706:21: note: expanded from macro 'NM_CAST_STRV_CC'
            (_Generic ((value), \
                        ^

(cherry picked from commit 8dc3f07d34)
2020-10-19 23:04:52 +02:00
Thomas Haller
4b11029df9
device/wifi: fix leak of NMSupplicantPeerInfo.peer_path in NMSupplicantInterface
Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit 3cf8620294)
2020-10-12 21:42:16 +02:00
Benjamin Berg
9cd4968b7b
wifi: re-add code for tracking a peers groups
The code to track the property was accidentally removed in commit
21d4a26188 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property')
causing all P2P connections to fail after 5 seconds.

Fixes: 21d4a26188 ('core: remove code for unused NM_WIFI_P2P_PEER_GROUPS property')

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/650
(cherry picked from commit dc54a946ac)
2020-10-12 21:41:12 +02:00
Juliano de Souza Camargo
817f2cb90e
po: update Portuguese (pt) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/648
(cherry picked from commit 0fe92f40fc)
2020-10-12 10:04:24 +02:00
Yuri Chornoivan
4747f99beb
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/647
(cherry picked from commit f660801a7b)
2020-10-12 10:01:32 +02:00
Beniamino Galvani
ff25a9b8d1 dns: merge branch 'bg/dns-vpn'
https://bugzilla.redhat.com/show_bug.cgi?id=1863041
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/631

(cherry picked from commit bba1ab0f21)
2020-10-09 10:31:18 +02:00
Beniamino Galvani
f10e4fe8c8 dns: change default DNS priority of VPNs to -50
Change the default DNS priority of VPNs to -50, to avoid leaking
queries out of full-tunnel VPNs.

This is a change in behavior. In particular:

 - when using dns=default (i.e. no split-dns) before this patch both
   VPN and the local name server were added (in this order) to
   resolv.conf; the result was that depending on resolv.conf options
   and resolver implementation, the name servers were tried in a
   certain manner which does not prevent DNS leaks.
   With this change, only the VPN name server is added to resolv.conf.

 - When using a split-dns plugin (systemd-resolved or dnsmasq), before
   this patch the full-tunnel VPN would get all queries except those
   ending in a local domain, that would instead be directed to the
   local server.
   After this patch, the VPN gets all queries.

To revert to the old behavior, set the DNS priority to 50 in the
connection profile.

(cherry picked from commit af13081bec)
2020-10-09 10:31:18 +02:00
Beniamino Galvani
c5b57526ac dns: add wildcard domain to VPNs with never-default=no and no domains
If a VPN has never-default=no but doesn't get a default route (this
can happen for example when the server pushes routes with
openconnect), and there are no search domains, then the name servers
pushed by the server would be unused. It is preferable in this case to
use the VPN DNS server for all queries.

https://bugzilla.redhat.com/show_bug.cgi?id=1863041
(cherry picked from commit cefd5ee322)
2020-10-09 10:31:18 +02:00
Beniamino Galvani
3ebe333492 core: add never-default field to NMIP{4,6}Config
(cherry picked from commit 9eba457426)
2020-10-09 10:31:18 +02:00
Beniamino Galvani
25de8a6a25 dns: slightly refactor rebuild_domain_lists()
Centralize wildcard domain assignment in a single place.

(cherry picked from commit e05550c34c)
2020-10-09 10:31:18 +02:00
Thomas Haller
bb802507e4
cli: fix showing active state for nmcli con show with fields
With "connection.multi-connect", a profile can be activated multiple
times on a device with `nmcli connection show`. Also, a profile may be
in the process of deactivating on one device, while activating on
another one. So, in general it's possible that `nmcli connection show`
lists the same profile on multiple lines (reflecting their multiple
activation states).

If the user requests no fields that are part of the activation state,
then the active connections are ignored. For example with `nmcli
-f UUID,NAME connection show`. In that case, each profile is listed only
once.

On the other hand, with `nmcli -g UUID,NAME,DEVICE connection show` the
user again requested also to see the activation state, and a profile can
appear multiple times.

To handle that, we need to consider which fields were requested.

There was a bug where the "ACTIVE" field was not treated as part of the
activation state. That results in `nmcli -f UUID,NAME,ACTIVE connection
show` always returning "no". Fix that.

Fixes: a1b25a47b0 ('cli: rework printing of `nmcli connection` for multiple active connections')

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/642
(cherry picked from commit 4eb3b5b9dd)
2020-10-09 10:24:02 +02:00
Thomas Haller
aab2775acf
cli: honor and prefer color schemes with ".scheme" extension
According to `man terminal-colors.d`, the extension should be ".scheme"
and not ".schem". Prefer that, but keep honoring ".schem" file, if it
exists.

https://bugzilla.redhat.com/show_bug.cgi?id=1886336
(cherry picked from commit f1830ab0de)
2020-10-09 09:56:11 +02:00
Michael Biebl
dfd54b7f2e
systemd: basic/missing_syscall: fix syscall numbers for mips*
Thanks Christian Brauner @brauner

cd20659891

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/545
(cherry picked from commit e9c6561ffa)
2020-10-08 10:37:25 +02:00
David Rheinsberg
282fac4afb
c-rbtree: reduce alignment constraints
There are some Debian-supported architectures where `max_align_t` is
only aligned to 4-bytes. This is unfortunate and breaks our assumptions.
While glibc-malloc still guarantees 8 / 16 bytes alignment, this is not
necessarily guaranteed by the C standard (and alternative allocators
will deviate (see jemalloc, for instance)).

Fortunately, we only need 2 flags, so a 4-byte alignment is more than
enough.

Reported-by: Thomas Haller
Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>

https://github.com/c-util/c-rbtree/pull/4
(cherry picked from commit 1554936e33)
2020-10-07 16:24:04 +02:00
Thomas Haller
b569687f5f
platform/tests: skip test_platform_ip_address_pretty_sort_cmp() on non-amd64 archs
The test only works on amd64, because it relies on the memory layout of
the structures.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/546
(cherry picked from commit 6cf7c6739f)
2020-10-07 09:15:52 +02:00
Thomas Haller
36ccbcc550
platform/tests: print details about test failure for test_platform_ip_address_pretty_sort_cmp()
When the test is about to fail, print the wrong data to help debugging
the test failure.

(cherry picked from commit 3576f54100)
2020-10-07 09:15:51 +02:00
Thomas Haller
07868a535f
platform/tests: adjust regeneration of test code for test_platform_ip_address_pretty_sort_cmp()
Since re-formatting our source code, the generated output no longer
matched the required formatting. Adjust it.

(cherry picked from commit 4fc7973498)
2020-10-07 09:15:51 +02:00