Commit graph

31904 commits

Author SHA1 Message Date
Beniamino Galvani 46ccc82a81 dns: consider the dns-type and the priority when hashing DNS configs
The dns-type must be included in the hash because it contributes to
the generated composite configuration. Without this, when the type of
a configuration changes (e.g. from DEFAULT to BEST), the DNS manager
would determine that there was no change and it wouldn't call
update_dns().

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

Fixes: 8995d44a0b ('core: compare the DNS configurations before updating DNS')
2023-02-01 09:00:56 +01:00
Beniamino Galvani 8a4632b56a core,libnm: move enum NMDnsIPConfigType
The enum will be used outside of core/dns.
2023-02-01 09:00:56 +01:00
Beniamino Galvani ec0a83b224 core: rename and move nm_ip_config_dns_hash()
The function operates on a NML3ConfigData, rename it and move it to
the right place.
2023-02-01 09:00:56 +01:00
Fernando Fernandez Mancera 7a844ecba9 netns: fix configuring onlink routes for ECMP routes
Kernel enforces that all nexthops must be reachable through a route.
L3Cfg is generating dependent onlink routes to solve this problem but
the IPv4 ECMP commit is happening before that.

To solve this we introduce two boolean fields "is_new" and "is_ready" to
know in which state is the L3Cfg affected. Initially, "is_new" is TRUE
and "is_ready" is FALSE. Here we schedule a commit on idle and we set
"is_new" to FALSE. When revisiting, we set "is_ready" to TRUE and then
we set the ECMP IPv4 routes.

When a reapply kicks in we reset the L3Cfg state by setting "is_new" to
TRUE.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1520
2023-01-31 17:55:53 +01:00
Wen Liang dbea79550f
version: add 1.44 macros 2023-01-30 11:14:14 +01:00
Thomas Haller e013074c89
glib-aux,all: merge branch 'th/g-random-int'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1517
2023-01-30 11:00:12 +01:00
Thomas Haller 6e96d71731
all: use nm_random_*() instead of g_random_*()
g_random_*() is based on GRand, which is not a CSPRNG. Instead, rely on
kernel to give us good random numbers, which is what nm_random_*() does.

Note that nm_random_*() calls getrandom() (or reads /dev/urandom), which
most likely is slower than GRand. It doesn't matter for our uses though.

It is cumbersome to review all uses of g_rand_*() whether their usage of
a non-cryptographically secure generator is appropriate. Instead, just
always use an appropriate function, thereby avoiding this question. Even
glib documentation refers to reading "/dev/urandom" as alternative. Which
is what nm_random_*() does. These days, it seems unnecessary to not use
the best random generator available, unless it's not fast enough or you
need a stable/seedable stream of random numbers.

In particular in nmcli, we used g_random_int_range() to generate
passwords. That is not appropriate. Sure, it's *only* for the hotspot,
but still.
2023-01-30 10:51:13 +01:00
Thomas Haller fb1d2da979
glib-aux: add nm_random_u64_range() helper 2023-01-30 10:48:53 +01:00
Thomas Haller 00affc7b6f
contrib/release.sh: add hint about publishing documentation on website 2023-01-30 09:32:01 +01:00
Thomas Haller 90df190a1a
platform/tests: merge branch 'th/platform-cache-test'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1513
2023-01-30 08:35:11 +01:00
Thomas Haller e99433866d
platform/tests: ignore ip-tunnel interfaces in nmtstp_assert_platform()
Certain ip-tunnel modules automatically create network interfaces (for
example, "ip_gre" module creates "gre0" and others).

Btw, that's not the same as `modprobe bonding max_bonds=1`, where
loading the module merely automatically creates a "bond0" interface. In
case of ip tunnel modules, these generated interfaces seem essential to
how the tunnel works, for example they cannot be deleted. I don't
understand the purpose of those interfaces, but they seem not just
regular tunnel interfaces (unlike, "bond0" which is a regular bond
interface, albeit automatically created).

Btw, if at the time when loading the module, an interface with such name
already exists, it will bump the name (for example, adding a "gre1"
interfaces, and so on). That adds to the ugliness of the whole thing,
but for our unit tests, that is no problem. Our unit tests run in a
separate netns, and we don't create conflicting interfaces. That is, an
interface named "gre0" is always the special tunnel interface and we
can/do rely on that.

Note that when the kernel module gets loaded, it adds those interfaces
to all netns. Thus, even if "test-route-linux" does not do anything with
ip tunnels, such an interface can always appear in a netns, simply by
running "test-link-linux" (or any other tool that creates a tunnel) in
parallel or even in another container.

Theoretically, we could just ensure that we load all the conflicting
ip-tunnel modules (with nmtstp_ensure_module()). There there are two
problems. First, there might be other tunnel modules that interfere but
are not covered by nmtstp_ensure_module(). Second, when kernel creates
those interfaces, it does not send correct RTM_NEWLINK notifications (a
bug), so our platform cache will not be correct, and
nmtstp_assert_platform() will fail.

The only solution is to detect and ignore those interfaces.  Also,
ignore all interfaces of link-type "unknown". Those might be from other
modules that we don't know about and that exhibit the same problem.
2023-01-30 08:19:51 +01:00
Thomas Haller 26592ebfe5
platform/tests: avoid recent route protocols in "/route/test_cache_consistency_routes" tests
Ubuntu 18.04 comes with iproute2-4.15.0-2ubuntu1.3. The
"/etc/iproute2/rt_protos" file from that version does not yet support
the "bgp" entry. Also the "babel" entry is only from 2014. Just choose
other entries. The point is that NetworkManager would ignore those, and
that applies to "zebra" and "bird" alike.
2023-01-30 08:19:51 +01:00
Thomas Haller acc0cee28e
platform/tests: use nmtstp_ensure_module() in test_software_detect()
This helper function already loads the module and performs
additional checks. Use it.
2023-01-30 08:19:50 +01:00
Thomas Haller 451cedf2bf
platform/tests: add nmtstp_ensure_module() helper
This will make sure that the IP tunnel module is loaded. It does so by
creating (and deleting) a tunnel interface.

That is important, because those modules will create additional interfaces
that show up in `ip link` (like "gre0"), and those interfaces can interfere
with the tests.

Also add nmtstp_link_is_iptunnel_special() to detect whether an
interface is one of those special interfaces.
2023-01-30 08:19:50 +01:00
Thomas Haller 4966f9d784
platform/tests: fix nmtstp_link_{gre,ip6gre,ip6tnl,ipip}_add() to support missing parent 2023-01-30 08:19:50 +01:00
Thomas Haller dba2fb5fff
gitlab-ci: use "meson test" for running unit tests
It seems that `meson test` is preferred over `ninja test`.  Also, pass
"--print-errorlogs" to meson, and pass "-v" to the build steps.

Note that `ninja test` already ends up calling `meson test
--print-errorlogs`, but it doesn't use "-v", so the logs are truncated.
2023-01-30 08:19:49 +01:00
Thomas Haller 13d9cf75ed
gitlab-ci: rerun meson test on failure with debugging
Like done for autotools. First we run the test without debugging option.
If it fails, we run it again to possibly trigger the failure again and
get better logs.
2023-01-30 08:19:49 +01:00
Thomas Haller 3f2ad76363
gitlab-ci: explicitly set "NMTST_DEBUG=debug,..." for second debug run
"debug" is implied when setting NMTST_DEBUG, but not specifying
"no-debug". This change has thus no effect, but it seems clearer to be
explicit.

The "debug" flag affects nmtst_is_debug(). Note that tests *must* not
result in different code paths based on debug, they may only

 1) print more debug logging
 2) do more assertion checks.

Having more assertion checks can result in different outcome of the
test, that is, that the additional assertion fails first. That is
acceptable, because failing earlier is possibly closer to the issue and
helps debugging. Also, when the additional failure is fixed and passes,
we still will fail at the assertion we are trying to debug.

In particular, an access to nmtst_get_rand*()/nmtst_rand*() must not
depend on nmtst_is_debug(), because then different randomized paths
are taken based on whether debugging is enabled.
2023-01-30 08:18:45 +01:00
Thomas Haller 3bad3f8b24
gitlab-ci: fix randomizing tests in "nm-ci-run.sh"
The code was just wrong. Usually in gitlab-ci, NMTST_SEED_RANDOM is
unset, so the previous code  would not have set it. Which means that our
tests run with NMTST_SEED_RANDOM="0".

Fuzzing (or randomizing tests) is very useful, we should do that for the
unit tests that run in gitlab-ci. Fix this.

But don't let the test choose a random number. Instead, let the calling
script choose it. That is, because we might run the tests more than once
(without debugging and no valgrind; in case of failure return with
debugging; with valgrind). Those runs should use the same seed.

This fixes commit 70487d9ff8 ('ci: randomize tests during our CI'),
but as fixing randomization can break previously running tests, we may
only want to backport this commit after careful evaluation.
2023-01-30 08:18:45 +01:00
Thomas Haller 67da2b8e42
gitlab-ci: fix test script to abort on failing first test
Fixes: 89cfd34ae0 ('gitlab-ci: extend run-test.sh script to manually select certain build steps to run')
2023-01-30 08:18:45 +01:00
Thomas Haller 14b1a7ba30
l3cfg/tests: temporarily disable failing tests "/l3cfg/$N"
Seems this test fails easily under gitlab-ci, if we set NMTST_SEED_RAND
to something else than "0". There is nothing particular special about
"0", except that a randomly different code paths are chosen.

A randomized test that doesn't pass on all systems with all random
paths, is broken. Disable for now. Needs to be fixed.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2165141
2023-01-30 08:18:44 +01:00
Thomas Haller 65ea47580f
client/tests: temporarily disable failing test test_monitor() 2023-01-30 08:18:44 +01:00
Thomas Haller 88c08721c3
po: fix marking "nm-setting-ovs-dpdk.c" for translation
Fixes: f930d55fea ('all: add support for ovs-dpdk n-rxq-desc and n-txq-desc')
2023-01-30 07:55:10 +01:00
Fernando Fernandez Mancera 9934be52cd device: use NMUnmanFlagOp enum members instead of literals
Replace TRUE or FALSE for their NMUnmanFlagOp enum member. It is more
intuitive for newcomers so they can understand what is being set without
looking at the values or function logic.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1516
2023-01-27 14:47:31 +01:00
Thomas Haller 4463a6c903
nmcli/style: fix clang-format style
Fixes: 8132045d5f ('nmcli: fix typos in nmcli output')
2023-01-27 08:32:54 +01:00
Thomas Haller 108ab677e4
nmcli/style: fix clang-format style
Fixes: 8132045d5f ('nmcli: fix typos in nmcli output')
2023-01-27 08:32:39 +01:00
Michael Biebl ae971c0019
nmcli: fix typos in nmcli output
Spotted by lintian:
  I: network-manager: spelling-error-in-binary writting writing [usr/bin/nmcli]
  I: network-manager: spelling-error-in-binary wihout without [usr/lib/x86_64-linux-gnu/NetworkManager/1.40.12/libnm-device-plugin-wifi.so]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1515
(cherry picked from commit 8132045d5f)
2023-01-27 08:00:51 +01:00
Michael Biebl 8132045d5f
nmcli: fix typos in nmcli output
Spotted by lintian:
  I: network-manager: spelling-error-in-binary writting writing [usr/bin/nmcli]
  I: network-manager: spelling-error-in-binary wihout without [usr/lib/x86_64-linux-gnu/NetworkManager/1.40.12/libnm-device-plugin-wifi.so]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1515
2023-01-27 08:00:02 +01:00
Fernando Fernandez Mancera 8e17e0c0bd merge: branch 'ff/fix_l3cfg_onlink'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1510
2023-01-26 11:11:51 +01:00
Fernando Fernandez Mancera f187e63fa8 l3-config-data: do not check route table to get direct routes
Kernel enforces that all route nexthop are reachable but it doesn't care
if the drect route to the nexthop is in a different route table.
2023-01-26 11:10:08 +01:00
Fernando Fernandez Mancera cbf70b4dca Revert "nm-netns: add onlink routes for ECMP routes"
ECMP IPv4 route nexthops requires an onlink route but we should trust
l3cfg when generating and managing such routes.

This reverts commit 737cb5d424.
2023-01-26 11:10:08 +01:00
Fernando Fernandez Mancera 9c492c6fc4 Revert "l3cfg: do not add dependent routes for non-default routes"
We must trust l3cfg when generating dependent onlink routes for all kind
of routes not default routes only. This was done by
"nm_platform_ip_route_sync()" so there is not change in behaviour at
all.

"nm_platform_ip_route_sync()" could be needed for other situation where
l3cfg cannot add the dependent onlink routes, so we are not removing
that logic.

This reverts commit 6b4123db1c.
2023-01-26 11:07:00 +01:00
Lubomir Rintel 4d75c43f1a dns-manager: always apply options from [global-dns]
Currently, the use of [global-dns] section for setting DNS options is
conditioned on presence of a nameserver in a [global-dns-domain-*] section.
Attempt to use the section for options alone results in an error:

  [global-dns]
  options=timeout:1

Or via D-Bus API:

  # busctl set-property org.freedesktop.NetworkManager \
      /org/freedesktop/NetworkManager org.freedesktop.NetworkManager \
      GlobalDnsConfiguration 'a{sv}' 2 \
          "options" as 1 "timeout:1" \
          "domains" a{sv} 0
  ...
  Nov 24 13:15:21 zmok.local NetworkManager[501184]: <debug> [1669292121.3904]
      manager: set global DNS failed with error: Global
      DNS configuration is missing the default domain

The insistence on existence of [global-dns-domain-*] would make sense if
other [global-dns-domain-...] sections were present.

However, the user might only want to set the options in resolv.conf and
still use connection-provide nameservers for the actual resolving.

Lift the limitation by allowing the [global-dns] to be used alone, while
still insist on [global-dns-domain-*] being there in presence of other
domain-specific options.

https://bugzilla.redhat.com/show_bug.cgi?id=2019306
(cherry picked from commit 1f0d1d78d2)
2023-01-26 10:11:45 +01:00
Lubomir Rintel 164cc81569 config-data: style fix
(cherry picked from commit 051819a78e)
2023-01-26 10:11:43 +01:00
Lubomir Rintel e2246cb54b dns-manager: style fix
(cherry picked from commit f2f806f77d)
2023-01-26 10:11:42 +01:00
Lubomir Rintel d976683417 release: bump version to 1.41.91 (1.42-rc2) (development) 2023-01-26 09:55:15 +01:00
Thomas Haller 9297f319f0 glib-aux/trivial: fix code comment about nmtst_is_debug()
Fixes: c1b57a2c72 ('glib-aux/tests: enable TRACE logging level when debugging nmtst tests')
(cherry picked from commit 93424dc2c2)
2023-01-26 09:20:18 +01:00
Thomas Haller be848b3384 libnm: valide IPv4 ECMP routes in NMIPRoute as unicast routes
Kernel does not allow ECMP routes for route types other than unicast.
Reject that in NetworkManager settings too.

Fixes: 3cd02b6ed6 ('libnm,platform: fix range for "weight" property of next hops for routes')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1507
(cherry picked from commit 4f719da32d)
2023-01-26 09:20:18 +01:00
Lubomir Rintel bd4f5333e8 config: fix a reversed conditional
This effectively makes [*global-dns-domain-*] sections in configuration be
ignored unless [*global-dns] is also present. This happens because
nm_config_keyfile_has_global_dns_config() mixes the group names up and
attempts to loop up [.intern.global-dns-domain-*] in user configuration and
[global-dns-domain-*] in the internal one.

Fixes: da0ded4927 ('config: drop global-dns.enable option in favor of .config.enable')
(cherry picked from commit de1c06daab)
2023-01-26 09:20:18 +01:00
Lubomir Rintel b36af7ce3f release: bump version to 1.43.1 (development) 2023-01-26 09:05:56 +01:00
Lubomir Rintel 5e234fa0c9 libnm/client: don't consider client running if we got no NMManager
We silently tolerate NetworkManager not responding at all (easily
reproduced with e.g. pkill -STOP NetworkManager):

  $ LIBNM_CLIENT_DEBUG=trace nmcli c show dummy666
  libnm-dbus[23540]: <debug> [3316.81989] nmclient[ddafb84b8deebe4a]: new NMClient instance
  libnm-dbus[23540]: <debug> [3316.81998] nmclient[ddafb84b8deebe4a]: starting async initialization...
  libnm-dbus[23540]: <debug> [3316.82461] nmclient[ddafb84b8deebe4a]: name owner changed: (null) -> ":1.2"
  libnm-dbus[23540]: <debug> [3316.82464] nmclient[ddafb84b8deebe4a]: fetch all
  libnm-dbus[23540]: <debug> [3341.85715] nmclient[ddafb84b8deebe4a]: GetManagedObjects() call failed: Timeout was reached
  libnm-dbus[23540]: <debug> [3341.85740] nmclient[ddafb84b8deebe4a]: async init complete with success
  Error: dummy666 - no such connection profile.
  libnm-dbus[23540]: <debug> [3341.86723] nmclient[ddafb84b8deebe4a]: release all
  libnm-dbus[23540]: <debug> [3341.86798] nmclient[ddafb84b8deebe4a]: disposed
  $

As a comment in _dbus_get_managed_objects_cb() explains, this is sort of
intentional. NetworkManager might just be shutting down and the libnm
users will eventually see the objects once a new daemon starts up.

This may make some sense for long-running clients ("nmcli monitor",
various desktop environments), but not for one-shot invocations that
require the daemon running, such as those of "nmcli c ...".

Let's not consider the client running unless we actually got the manager
object. That way the error message will make more sense:

  $ LIBNM_CLIENT_DEBUG=trace nmcli c show dummy666
  libnm-dbus[24730]: <debug> [5360.95480] nmclient[8cb898d3c891e210]: new NMClient instance
  libnm-dbus[24730]: <debug> [5360.95487] nmclient[8cb898d3c891e210]: starting async initialization...
  libnm-dbus[24730]: <debug> [5360.95901] nmclient[8cb898d3c891e210]: name owner changed: (null) -> ":1.2"
  libnm-dbus[24730]: <debug> [5360.95904] nmclient[8cb898d3c891e210]: fetch all
  libnm-dbus[24730]: <debug> [5385.98487] nmclient[8cb898d3c891e210]: GetManagedObjects() call failed: Timeout was reached
  libnm-dbus[24730]: <debug> [5385.98497] nmclient[8cb898d3c891e210]: async init complete with success
  Error: NetworkManager is not running.
  libnm-dbus[24730]: <debug> [5385.98571] nmclient[8cb898d3c891e210]: release all
  libnm-dbus[24730]: <debug> [5385.98698] nmclient[8cb898d3c891e210]: disposed
  $

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1502
2023-01-26 09:04:09 +01:00
Lubomir Rintel fd7175969c libnm/client: drop an unused argument
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1502
2023-01-26 09:04:07 +01:00
Lubomir Rintel b76ebc3bfc merge: branch 'lr/global-dns'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1377
2023-01-26 09:02:31 +01:00
Lubomir Rintel 1f0d1d78d2 dns-manager: always apply options from [global-dns]
Currently, the use of [global-dns] section for setting DNS options is
conditioned on presence of a nameserver in a [global-dns-domain-*] section.
Attempt to use the section for options alone results in an error:

  [global-dns]
  options=timeout:1

Or via D-Bus API:

  # busctl set-property org.freedesktop.NetworkManager \
      /org/freedesktop/NetworkManager org.freedesktop.NetworkManager \
      GlobalDnsConfiguration 'a{sv}' 2 \
          "options" as 1 "timeout:1" \
          "domains" a{sv} 0
  ...
  Nov 24 13:15:21 zmok.local NetworkManager[501184]: <debug> [1669292121.3904]
      manager: set global DNS failed with error: Global
      DNS configuration is missing the default domain

The insistence on existence of [global-dns-domain-*] would make sense if
other [global-dns-domain-...] sections were present.

However, the user might only want to set the options in resolv.conf and
still use connection-provide nameservers for the actual resolving.

Lift the limitation by allowing the [global-dns] to be used alone, while
still insist on [global-dns-domain-*] being there in presence of other
domain-specific options.

https://bugzilla.redhat.com/show_bug.cgi?id=2019306
2023-01-26 09:02:16 +01:00
Lubomir Rintel de1c06daab config: fix a reversed conditional
This effectively makes [*global-dns-domain-*] sections in configuration be
ignored unless [*global-dns] is also present. This happens because
nm_config_keyfile_has_global_dns_config() mixes the group names up and
attempts to loop up [.intern.global-dns-domain-*] in user configuration and
[global-dns-domain-*] in the internal one.

Fixes: da0ded4927 ('config: drop global-dns.enable option in favor of .config.enable')
2023-01-26 09:02:16 +01:00
Lubomir Rintel 051819a78e config-data: style fix 2023-01-26 09:02:16 +01:00
Lubomir Rintel f2f806f77d dns-manager: style fix 2023-01-26 09:02:16 +01:00
Yuri Chornoivan 66c9a5e849 po: update Ukrainian translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1508
2023-01-25 13:03:31 +01:00
Thomas Haller 621b41ebfa
platform: detect EINVAL as failure to set the MTU
Some drivers will reject an invalid MTU size with EINVAL.

Quote from [1]:

  While investigating, I did notice that do_change_link in
  nm-linux-platform.c really ought to count -EINVAL as an MTU out-of-range
  error and not just -ERANGE. Even if the hardware supports a large MTU,
  if the transmit FIFO is set too small, stmmac_change_mtu [2] will return
  -EINVAL. For example, on my device, the maxmtu is 9000 but in practice I
  can't set an MTU larger than 4096 unless I first run ethtool
  --set-channels eno1 tx 3.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1198#note_1738311
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c?h=v6.1#n5577
2023-01-25 09:05:58 +01:00
Thomas Haller fce8e572d0
contrib/copr: better detect git-ref in "nm-copr-build.sh" 2023-01-24 14:58:52 +01:00