Commit Graph

32561 Commits

Author SHA1 Message Date
Beniamino Galvani
3d61e6eebf systemd: add "BindsTo=dbus.service" to NetworkManager.service
Add "BindsTo=dbus.service" to NetworkManager.service so that when the
D-Bus service gets restarted, NM is also restarted instead of staying
stopped.

https://bugzilla.redhat.com/show_bug.cgi?id=2161915
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1605
2023-04-19 09:45:57 +02:00
Thomas Haller
105eb39cda nm-in-container: add commands to bash history 2023-04-18 20:47:32 +02:00
Thomas Haller
cae2011b08 contrib: show clang-format version in failure message
The actual formatting depends on the version of clang-format. Print the
used version, which is in particular interesting when we get an error in
our gitlab-ci check (which uses the correct version).
2023-04-18 19:05:02 +02:00
Beniamino Galvani
cab80c5129 device: emit dhcp-change dispatcher event also after a lease renewal
Fixes: e1648d0665 ('core: commit l3cd asynchronously on DHCP bound event')
Co-authored-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=2179537
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1609
2023-04-18 18:18:55 +02:00
Beniamino Galvani
230f3f5ce7 nm-in-container: install libselinux-utils
It contains "getenforce" and "setenforce", which are needed by some
NMCI tests.
2023-04-18 10:10:56 +02:00
Thomas Haller
5df19f5b26 ppp: merge branch 'th/ppp25'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1272
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1558

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1607
2023-04-18 08:27:13 +02:00
Thomas Haller
afe80171b2 ppp: move ppp code to "nm-pppd-compat.c"
Using the ppp code is rather ugly.

Historically, the pppd headers don't follow a good naming convention,
and define things that cause conflicts with our headers:

  /usr/include/pppd/patchlevel.h:#define VERSION          "2.4.9"
  /usr/include/pppd/pppd.h:typedef unsigned char  bool;

Hence we had to include the pppd headers in certain order, and be
careful.

ppp 2.5 changes API and cleans that up. But since we need to support
also old versions, it does not immediately simplify anything.

Only include "pppd" headers in "nm-pppd-compat.c" and expose a wrapper
API from "nm-pppd-compat.h". The purpose is that "nm-pppd-compat.h"
exposes clean names, while all the handling of ppp is in the source
file.
2023-04-17 18:27:50 +02:00
Eivind Næss
8469c09a50 ppp, adding support for compiling against pppd-2.5.0
This change does the following
* Adding in nm-pppd-compat.h to mask details regarding different
  versions of pppd.
* Fix the nm-pppd-plugin.c regarding differences in API between
  2.4.9 (current) and latet pppd 2.5.0 in master branch
* Additional fixes to the configure.ac to appropriately set defines used
  for compilation
2023-04-16 21:05:07 +02:00
Eivind Næss
0324098afa build: detect pppd version via pkg-config for PPPD_PLUGIN_DIR
Ppp 2.5 adds a pkg-config file, so we can detect the version.
Use it.

[thaller@redhat.com: split out patch]
2023-04-16 21:05:01 +02:00
Thomas Haller
290bac0af9 libnm: fix annotation for out_is_valid of nm_wireguard_peer_get_allowed_ip()
Fixes: 5d28a0dd89 ('doc: replace all (allow-none) annotations by (optional) and/or (nullable)')
2023-04-16 16:49:37 +02:00
Thomas Haller
7fa72645e5 gitlab-ci: make detached MR pipeline for external contributor's pipelines to run
The permissions for running CI will be restricted to external
contributors. It will only work for projects that use "detached MR
pipelines" ([1]).

Note that for it to actually work, a member with permission might have
to go to the "pipeline" tab of the merge request and click "run
pipeline". But this snippet is necessary for that.

[1] https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html

https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/540#what-it-means-for-me-a-maintainer-of-a-project-part-of-gitlabfreedesktoporg
2023-04-13 15:19:23 +02:00
Thomas Haller
31b5bd72eb gitlab: merge branch 'th/gitlab-ci-tiers'
Obsoletes: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1595

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1601
2023-04-13 14:30:55 +02:00
Thomas Haller
229163202d release.sh: adjust check for gitlab-ci for changes in pipeline
- We need to fetch more entries per page. 100 is the maximum without
  pagination, but that is enough for us.

- Previously, we checked all stages. Now, let's skip the "prep" and "tier3" stages.
  This change should work both with old and new pipelines.
2023-04-13 13:18:27 +02:00
Thomas Haller
5475f57d39 gitlab-ci: make tier tests automatic to simplify starting them manually
We want that the tier2+ tests are only run manually. As those tests
depend on the respective prep step, there are 3 possibilities:

1) make prep manual and the tier test automatic. That is what we would
   want, because then we can just manually trigger the prep step (one
   click). However, in the past this didn't work.

2) make the prep automatic and the test manual. That works, the downside
   is that we often run the prep step when its not needed. This is what
   we used to do to workaround 1).

3) make prep and the test manual. Then there are no unnecessary tests
   run, but triggering a manual test is cumbersome. First click to start
   the prep step, then wait, then click again.

Revisit this. It seems 1) is working now. Yeay.

Also rename the prep stages, so that it's clear to which tier they
belong. I guess, I could move them instead to prep1, prep2, prep3
stages, but then there are a lot of columns on the web site.
2023-04-13 09:30:14 +02:00
Thomas Haller
afe098a928 gitlab-ci: extract base_type for distros to reduce redundant information
The distro.name is not just a pretty name, its the name under which we fetch
the container. It is thus a well-known name, that we can rely on.

The "base_type" only depends on the distro name, and it makes no sense
to ever choose a different name. Tracking it in the "distributions"
array is thus redundant.

Move the mapping of distro.name to the base type to a separate place.
2023-04-13 09:10:59 +02:00
Thomas Haller
8e37037e88 gitlab-ci: drop "tag"/"default_tag" from ci templates
The tag we actually use already contains a hash of the input files and
is generated (by `ci-fairy generate-templates`). There is no need for having
this fixed prefix. As also seens by having a date there, which is maintained
badly and meaningless.

Drop it.
2023-04-13 09:10:59 +02:00
Thomas Haller
31c05da92c gitlab-ci: rename "@container-prep" tests to "@prep"
The long name looks verbose and takes away space on the web page.
Shorten the name.
2023-04-13 09:10:59 +02:00
Thomas Haller
e41fe546f7 gitlab-ci: use parallel:matrix for tier1 tests
The benefit is that instead of one long running job for fedora:37 (the
current tier1 test), we have several smaller.

A minor downside is, that if the build is broken, then usually the very
first test would already fail. Previously, that meant that the follow up
tests were skipped. Now, they run all in parallel. However, test
failures should be the exception, so the wasted resources are probably
irrelevant. The upside is, that we can see which tests fail, and we run
them much faster (in parallel).

This is only done for the tier1 test, because those tests are started
automatically. Other tiers need to be triggered manually, which already
means a lot of clicking. Making those also matrix tests, would result in
an insane amount of clicking. As those other tests are run much more
seldom, having them huge is probably fine.
2023-04-13 09:08:04 +02:00
Thomas Haller
b06ddab9d4 gitlab-ci: add multiple stages/tiers for tests
We have many test configurations (i.e. distros like fedora:37,
debian:9).  Almost all of them run manually triggered, because running
them every time would be wasteful.

Still, even as we trigger those tests only seldom, whenever we trigger
them all together, they consume still too many resources of the
freedesktop.org gitlab infrastructure.

One possibility would be to just drop old distros (e.g. fedora:30).
Which tests are setup in gitlab-ci is constantly refined and adjusted.
So dropping some distros is not necessarily wrong and bound to happen
eventually.

However, I also don't find it great to just disable tests that are still
passing. If we want to avoid consuming too many resources, we can just
choose not to run those tests. We don't need to enforce that by deleting
tests. Once deleted, such a configuration cannot be tested anymore as it
would be too cumbersome to recreate the setup manually.

Instead, introduce stages/tiers to clearer mark configuration that we
should test even less frequently.

Note that it is still required from the developer to not trigger too
many tests at once, to not monopolize the CI resources. The stages
should make that clearer to see, but don't solve it. Deleting tests
might solve it, but only if we delete a significant number of those
tests, which seems not desirable.
2023-04-13 09:08:03 +02:00
Thomas Haller
d39fb6f014 gitlab-ci: use clearer names for NM_TEST_SELECT_RUN in "run-test.sh" 2023-04-13 09:08:03 +02:00
Thomas Haller
8da0f9f79d gitlab-ci: assert that NM_TEST_SELECT_RUN is valid in "run-test.sh"
The script now fails, if the user passes an invalid "$NM_TEST_SELECT_RUN"
or if the script references an invalid name.
2023-04-13 09:08:03 +02:00
Aleksandr Melman
513c7f0280 po: update Russian (ru) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1598
2023-04-12 13:24:03 +02:00
Peter Hutterer
aa74fec602 gitlab-ci: pass --break-system-packages to pip3 for the meson install
pip on Debian 12 semi-forces us to use a venv. That's hard enough but
even more so when we just want to run meson which only relies on the
standard library anyway.

Since that flag doesn't exist on earlier versions, try both and hope one
invocation succeeds.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1595
2023-04-11 13:49:57 +02:00
Beniamino Galvani
89a8f51235 device: stop activation when queueing the unmanaged state
When the unmanaged state is queued, we must ensure that the current
activation doesn't overwrite the queue stated with a new one. This can
happen for example if a dispatcher script or a firewall call
terminate, or if the next activation stage is dispatched.

Fixes-test: @preserve_master_and_ip_settings
https://bugzilla.redhat.com/show_bug.cgi?id=2178269
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1599
2023-04-11 09:19:03 +02:00
Thomas Haller
640c82710f platform/tests: fix unit test creating ip6gre tunnel with old iproute2
Older versions of iproute2 don't support the "enclimit" argument. Work
around that from the unit tests.

Fixes: 1505ca3626 ('platform/tests: ip6gre & ip6gretap test cases (ip6 tunnel flags)')
2023-04-07 17:25:26 +02:00
Thomas Haller
fe4e5c24e4 find-backports: improve git_ref_exists() to cache also the hashes themselves
git_ref_exists() memoizes the result. But while it looks up the SHA sum
for "ref", it also can cache the result for the SHA sum itself.
2023-04-07 17:23:13 +02:00
AsciiWolf
ee99a868f5 po: update Czech (cs) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1596
2023-04-07 14:07:11 +02:00
Thomas Haller
65ef6bc9bc find-backports: warn if any commits are not from the first reference
Every branch (for example "nm-1-40") has exactly one next branch, from
which patches should be backported (in that example that branch is
"nm-1-42").

While "find-backports" searches all newer branches for patches, it does
not make it clear form where the patch should come from.

That means, if you run the script `contrib/scripts/find-backports origin/nm-1-40`
it will check nm-1-42 and main branch, and might suggest to backport
patches that are only on main, but not "nm-1-42". That would be wrong,
because patches need to first go into nm-1-42, and then backported (from
there) further to nm-1-40.

Print a warning to highlight that.
2023-04-06 21:37:10 +02:00
Thomas Haller
9f89910852 find-backports: various cleanups in script
- avoid list([...]).
- use some f-strings.
2023-04-06 18:34:15 +02:00
Thomas Haller
efd23da26b find-backports: enable debug logging in script 2023-04-06 18:34:15 +02:00
Beniamino Galvani
24461954d0 dhcp: reset IPv6 DAD flag on lease update
If the client was waiting for IPv6 DAD to complete and the lease was
updated or lost, `wait_ipv6_dad` needs to be cleared; otherwise, at
the next platform change the client will try to evaluate the DAD state
with a different or no lease. In particular if there is no lease the
client will try to decline it because there are no valid addresses,
leading to an assertion failure:

 ../src/core/dhcp/nm-dhcp-client.c:997:_dhcp_client_decline: assertion failed: (l3cd)

Backtrace:

  __GI_raise ()
  __GI_abort ()
  g_assertion_message ()
  g_assertion_message_expr ()
  _dhcp_client_decline (self=0x1af13b0, l3cd=0x0, error_message=0x8e25e1 "DAD failed", error=0x7ffec2c45cb0) at ../src/core/dhcp/nm-dhcp-client.c:997
  l3_cfg_notify_cb (l3cfg=0x1bc47f0, notify_data=0x7ffec2c46c60, self=0x1af13b0) at ../src/core/dhcp/nm-dhcp-client.c:1190
  g_closure_invoke ()
  g_signal_emit_valist ()
  g_signal_emit ()
  _nm_l3cfg_emit_signal_notify () at ../src/core/nm-l3cfg.c:629
  _nm_l3cfg_notify_platform_change_on_idle () at ../src/core/nm-l3cfg.c:1390
  _platform_signal_on_idle_cb () at ../src/core/nm-netns.c:411
  g_idle_dispatch ()

Fixes: 393bc628ff ('dhcp: wait DAD completion for DHCPv6 addresses')

https://bugzilla.redhat.com/show_bug.cgi?id=2179890
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1594
2023-04-06 15:56:59 +02:00
Lubomir Rintel
23beb28771 release: bump version to 1.43.5 (development) 2023-04-05 13:45:17 +02:00
Thomas Haller
fba38266bc ovs: merge branch 'th/ovsdb'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1593
2023-04-05 08:46:42 +02:00
Thomas Haller
3a76d717da ovsdb: debug log all messages of socket buffer 2023-04-04 08:58:06 +02:00
Thomas Haller
0ee60b943d ovsdb: downgrade error logging to warnings
<error> is mostly about "really should not happen" scenarios. It's
closer to an assertion failure, and something that NetworkManager should
not happen.

Of course, things can go wrong, but <warn> is a sufficient. When ovsdb
gives unexpected communication, it's just a warning. At least, that's
also what all the similar cases in "nm-ovsdb.c" already do
2023-04-04 08:43:21 +02:00
Thomas Haller
25c97817d2 ovsdb: limit maxiumum data size for receive buffer from ovsdb 2023-04-04 08:43:21 +02:00
Thomas Haller
f7d321c6d6 ovsdb: add watchdog for unparsable JSON data in socket 2023-04-04 08:43:21 +02:00
Thomas Haller
7e12d437fe ovsdb: use the FD directly instead of GSocketConnection/GOutputStream
GSocketConnection/GOutputStream/GInputStream seems rather unnecessary.
Maybe they make sense when you want to write portable code (for
Windows). Otherwise, watching a file descriptor and reading/writing it
directly is simpler (and also more efficient).

For example, we passed no GCancellable to g_input_stream_read_async().
What does that mean w.r.t. destroying the NMOvsdb instance? I suspect
it's wrong, but it's hard to say, because there are so many layers of
code.

Note that we anyway keep state in NMOvsdb, namely the data we want to
send (output_buf) and the data we partially received (input_buf). All we
need, are poll notifications when the file descriptor is ready. To
those, we hook up the read/write callbacks. Also before was the code
async, and there were callbacks when when read/write was done. That does
not simplify the code in any way.

- we no longer use separate NMOvsdbPrivate.buf and NMOvsdbPrivate.input
  buffers. There is just a NMOvsdbPrivate.input_buf that can we can fill
  directly.
2023-04-04 08:43:21 +02:00
Thomas Haller
f862d4bbce ovsdb: use nm_auto_free cleanup attribute in "nm-ovsdb.c" 2023-04-04 08:43:21 +02:00
Thomas Haller
64825b4f58 ovsdb: don't track buffer offset in NMOvsdb data and refactor parsing JSON messages
The "priv->bufp" offset is only used while parsing a message at a time.
It's unnecessary to track it in NMOvsdbPrivate and keep it between
parsing messages. Tracking the state in NMOvsdbPrivate makes it more
complicated to understand, because one needs to reason at which times
the state is used (when it really is not used).

Also, move the parsing to a separate function.
2023-04-04 08:43:21 +02:00
Thomas Haller
1378ed7d96 core: drop unnecessary initialization in nm_utils_spawn_helper()
We did not initialize "child_stderr". If that were necessary, we would need
to add it too. However, it is clearly not necessary to initialize those fields.
2023-04-04 08:43:21 +02:00
Thomas Haller
ce414933a7 core: use nm_io_fcntl_setfl_update_nonblock() helper 2023-04-04 08:43:21 +02:00
Thomas Haller
f4943e07f1 glib-aux: add nm_io_fcntl_setfl_update_nonblock() helper 2023-04-04 08:43:20 +02:00
Thomas Haller
31fd8f60cf all: use G_SPAWN_CLOEXEC_PIPES with g_spawn_async_with_pipes()
G_SPAWN_CLOEXEC_PIPES is supported since glib 2.40, which we already
depend on.
2023-04-04 08:43:20 +02:00
Thomas Haller
17ae6a4413 platform: drop unused nl_socket_set_nonblocking() function
It's not used. It's better to use SOCK_NONBLOCK flag for socket(), as we do.

Also, the implementation that blindly calls F_SETFL without merging the
existing flags from F_GETFL is just wrong. Drop it altogether.
2023-04-04 08:43:20 +02:00
Thomas Haller
20bd6b6803 core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: df1d214b2e ('clients: polkit-agent: implement polkit agent without using libpolkit')
2023-04-04 08:43:20 +02:00
Thomas Haller
62a85fa845 core: fix setting FD flags in _rfkill_update_system()
F_SETFL will reset the flags. That is wrong, as we only want to add
O_NONBLOCK flag and leaving the other flags alone. Usually, we would
need to call F_GETFL first.

Note that on Linux, F_SETFL can only set certain flags, so the
O_RDWR|O_CLOEXEC flags were unaffected by this. That means, most likely
there are no other flags that our use of F_SETFL would wrongly clear.
Still, it's ugly, because it's not obvious whether there might be other
flags.

Avoid that altogether, by setting the flag already during open().

Fixes: 67e092abcb ('core: better handling of rfkill for WiMAX and WiFi (bgo #629589) (rh #599002)')
2023-04-04 08:43:20 +02:00
Thomas Haller
d1f7e439c6 core: fix setting non-blocking stderr in nm_utils_spawn_helper()
Fixes: d65702803c ('core: print stderr from nm-daemon-helper')
2023-04-04 08:43:20 +02:00
Thomas Haller
fd123315e5 core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: 6ac21ba916 ('core: add infrastructure for spawning a helper process')
2023-04-04 08:43:20 +02:00
Beniamino Galvani
a2db213a45 merge: branch 'bg/rh2054933'
https://bugzilla.redhat.com/show_bug.cgi?id=2054933
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1569
2023-04-04 08:22:39 +02:00