Commit Graph

32384 Commits

Author SHA1 Message Date
Thomas Haller
aede228974 core: assert that devices are not registered when disposing NMPolicy
NMDevice holds a reference to NMManager, which holds a reference to NMPolicy.
It is not possible that we try to dispose NMPolicy while there are still devices
registered. That would be a bug, that we need to find and solve
differently. Add an assertion instead of trying to handle it.
2023-04-27 08:40:12 +02:00
Thomas Haller
0dd4724446 core: don't take reference on NMDevice to track auto-activate
Add an assertion to nm_policy_device_recheck_auto_activate_schedule(),
that the device is currently registered in NMPolicy. Calling it outside
would be odd, and likely a bug.

But if we only register the auto-activate while being registered, we
don't need to take an additional reference. We know that the object must
be be alive (also, we have assertions that in fact it is still alive).
2023-04-27 08:40:12 +02:00
Thomas Haller
a22e5080a0 core: rework tracking of auto-activating devices in NMPolicy
Hook the information for tracking the activation of a device, to the
NMDevice itself. Sure, that slightly couples the NMPolicy closer to
NMDevice, but the result is still simpler code because we don't need a
separate ActivateData.

It also means we can immediately tell whether the auto activation check
for NMDevice is already scheduled and don't need to search through the
list.
2023-04-27 08:40:12 +02:00
Thomas Haller
520fcc8667 core: add nm_manager_get_policy() accessor
NMPolicy really should be merged into NMManager. It has not a clear responsiblity
so that there are two separate objects only makes things confusing. Anyway. It
is permissible to look up the NMPolicy instance of a NMManager. Add an accessor.
2023-04-27 08:40:12 +02:00
Thomas Haller
a81925ad32 core: call nm_manager_device_recheck_auto_activate_schedule() from "nm-manager.c"
No need to call down to the device, to call back up to the NMManager.
2023-04-27 08:40:12 +02:00
Thomas Haller
751b927cf2 core: rename nm_device_emit_recheck_auto_activate() to nm_device_recheck_auto_activate_schedule()
It's the better name. Especially since there is no more signal involved,
the term "emit" doesn't match.

Note also how the previous approach using a signal tried to abstract
what is happening. So we were no longer rechecking-autoconnect, instead,
we were emitting-a-signal-to-recheck-autoconnect. Just be plain about
what it is doing and don't go through a layer of signal.
2023-04-27 08:40:12 +02:00
Thomas Haller
3c59c6b393 core: drop NM_DEVICE_RECHECK_AUTO_ACTIVATE signal and call policy directly
GObject signals don't make the code easier to understand, on the
contrary.  They may have their purpose, when objects truly must/should
not be aware of each other, and need to be composed very loosely. That
is not the case here.

There really is only one subscriber to NM_DEVICE_RECHECK_AUTO_ACTIVATE
signal, and it only makes sense this way. Instead of going through a
signal invocation, just call the well known method directly. It becomes
clearer who calls this code (and it has a lower overhead).

When using cscope/ctags it also is easier to follow the code because the
tools understand function calls.
2023-04-27 08:35:28 +02:00
Thomas Haller
aa2569a9cd core: use GSource for tracking reset_connections_retries idle action
The numeric source IDs are discouraged. Use a GSource instead.
2023-04-27 08:35:28 +02:00
Thomas Haller
1559c37b9f core: use GSource for tracking _device_recheck_auto_activate_all_cb idle action
The numeric source IDs are discouraged. Use a GSource instead.
2023-04-27 08:35:28 +02:00
Thomas Haller
886786ee0b core: rename internal function nm_policy_device_recheck_auto_activate_all_schedule()
The "all" variant is strongly related to nm_policy_device_recheck_auto_activate_schedule().
Rename, so that the names express that better.
2023-04-27 08:35:28 +02:00
Thomas Haller
f1c15f0ae7 core: expose and rename nm_policy_device_recheck_auto_activate_schedule()
Let's simplify this part of the code. This is the first step.
2023-04-27 08:35:27 +02:00
Thomas Haller
49c1e01519 core: don't trigger recheck to auto activate for deleted devices
The delete_on_deactivate_link_delete() handler may be called after the
device was already removed from NMManager. Don't allow that.

Check whether the device is still exported on D-Bus as indication.
2023-04-27 08:35:27 +02:00
Thomas Haller
e66b93b01e core: merge branch 'th/rh2152864-ovs-autoactivate'
https://bugzilla.redhat.com/show_bug.cgi?id=2152864
Fixes-test: @NM_reboot_openvswitch_vlan_configuration_var2

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1603
2023-04-27 08:29:03 +02:00
Thomas Haller
e699dff46a device: trigger a recheck to autoconnect when unrealizing ovs-interface
NM_reboot_openvswitch_vlan_configuration_var2 test exposes a race. What
the test does, is to create OVS profiles and repeatedly restart
NetworkManager, checking that those profiles autoconnect and the OVS
configuration gets created.

There is a race, where:

- the OVS interface exists, and an NMDeviceOvsInterface is created
- first ovsdb cleans up old interfaces, sending a json request.
- OVS deletes the interface, and NetworkManager first picks up the
  platform signal (there is a race here, usually the ovsdb request
  completes first, which will cleanup the NMDeviceOvsInterface in
  a different way).
- when the device gets unrealized, we don't schedule a
  check-autoactivate, so the device stays down.

See https://bugzilla.redhat.com/show_bug.cgi?id=2152864#c5 for a log
file with more details.

What should instead happen, is to autoactivate the OVS interface, which
then also fully configures the port and bridge interfaces.

Explicitly schedule an autoactivate when unrealizing devices.

Note that there are now several cases, where NetworkManager autoconnects
more eagerly. This even affects some CI tests and user-visible behavior.
But I think relying on "just don't call nm_device_emit_recheck_auto_activate()
to hope that autoconnect doesn't happen is wrong. It must always be
possible to trigger an autoconnect check, and the right thing must
happen. We only don't trigger autoconnect checks *all* the time, because
it would be a waste of CPU resources, but whenever we slightly suspect
that an autoconnect may happen, we must be allowed to trigger a check.
If a device is in a condition where it previously did not autoconnect,
and it also *should* not autoconnect, then we need to fix the code that
evaluates whether an autoconnect may happen (not avoid triggering a
check).

https://bugzilla.redhat.com/show_bug.cgi?id=2152864
Fixes-test: @NM_reboot_openvswitch_vlan_configuration_var2
2023-04-26 17:11:52 +02:00
Thomas Haller
840abc6c45 nm-in-container: set NMCI_DEBUG=1 in bashrc 2023-04-26 11:05:18 +02:00
Thomas Haller
14d429dd17 device: block autoconnect of profile when deleting device
Currently, when we delete a device then autoconnect does not kick in
right away. But that is only, because we happen not to schedule a
"autoactivate" recheck.

What should be happen, is that rechecking whether to autoconnect is
always allowed, and that we have the necessary state to know that
autoconnect currently should not work.

Instead, block autoconnect of the involved profile. That makes sense,
because clearly we don't want to autoconnect right again after `nmcli
device delete $iface`.
2023-04-26 11:05:18 +02:00
Thomas Haller
c68cbcb8fa device: minor cleanup of code path in delete_cb() 2023-04-26 11:05:18 +02:00
Thomas Haller
194c0d4b31 core: merge branch 'th/stable-id-default'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1610
2023-04-21 12:55:23 +02:00
Thomas Haller
7deea767d3 core: use NMStrBuf in nm_utils_stable_id_parse() 2023-04-21 12:51:43 +02:00
Thomas Haller
21cf2dc58f libnm,core: make "default${CONNECTION}" the built-in stable ID
The "connection.stable-id" supports placeholders like "${CONNECTION}" or
"${DEVICE}".

The stable-id can also be specified in global connection defaults in
NetworkManager.conf, by leaving it unset in the profile. Global
connection defaults always follow the pattern, that they correspond to a
per-profile property, and only when the per-profile value indicates a
special default/unset value, the global connection default is consulted.
Finally, if the global connection default is also not configured in
NetworkManager.conf, a built-in default is used (which may not be
constant either, for example ipv6.ip6-privacy's built-in default depends
on a sysctl value).

In any case, every possible configuration that can be achieved should be
configurable both per-profile and via global connection default. That
was not given for the stable-id, because the built-in default generated
an ID in a way that could not be explicitly expressed otherwise.

So you could not:
- explicitly set the per-profile value to the built-in default, to avoid
  that the global-connection-default overwrites it.
- explicitly set the global-connection-default to the built-in default,
  to avoid that a lower priority [connection*] section overwrites the
  stable-id again.

Fix that inconsistency to make it possible to explicitly set the
built-in default.

Change behavior for literally "default${CONNECTION}" and make it behave
as the built-in default. Also document that the built-in default has that
value.

It's unlikely that this breaks an existing configuration, but of course,
if any user configured "connection.stable-id=default${CONNECTION}", then
the behavior changes for them.
2023-04-21 12:49:18 +02:00
Thomas Haller
48a3682a75 NEWS: belatedly mention default for ipv6.addr-gen-mode
Fixes: e6a33c04eb ('all: make "ipv6.addr-gen-mode" configurable by global default')
2023-04-20 17:01:07 +02:00
Beniamino Galvani
c67d65f733 rpm: fix detection of ppp version for ppp >= 2.5.0
In ppp 2.5.0 the "patchlevel.h" header file was removed and pkg-config
must be used. Update the detection command to support both ways.
2023-04-20 11:55:49 +02:00
Beniamino Galvani
68c30bab16 release: bump version to 1.43.6 (development) 2023-04-19 13:51:50 +02:00
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