Commit Graph

32561 Commits

Author SHA1 Message Date
Thomas Haller
a740931204 core: merge branch 'th/autoconnect-cleanups'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1615
2023-05-04 10:34:41 +02:00
Thomas Haller
6e229a852f core: only trigger recheck when something changes in activate_slave_connections()
We need to detect when nothing relevant changes, and shortcut doing things when they
are unnecessary.
2023-05-04 10:34:12 +02:00
Thomas Haller
7e15b4d562 core: return whether anything changed from nm_manager_devcon_autoconnect_retries_reset() 2023-05-04 10:34:12 +02:00
Thomas Haller
5492945fdc core: use switch statement in device_state_changed()
It seems better for readability, because reacting based on the state-reason
is ugly already. This way, we access nm_device_state_reason_check(reason) only
at once place. With the if, it's not immediately obvious that both if/else
parts only switch on the reason too.
2023-05-04 10:34:12 +02:00
Thomas Haller
a019d965f7 core: avoid creating devcon data that we don't need
Otherwise, we create device × profiles entries, most of
them nonsensical.
2023-05-04 10:34:12 +02:00
Thomas Haller
87b46e1663 core: improve handling for blocking autoconnect
Cleanup logging to always print a "block-autoconnect:" prefix to related
lines. Also, make sure that everywhere where the state changes, a line
gets logged. Also, for devconf data print both the interface and the
profile.
2023-05-04 10:34:12 +02:00
Thomas Haller
fc624b8de8 core: assert for valid blocked reasons in autoconnect code
We only have a few blocked reasons. Some of them can be only set on the
devcon data, and some only on the settings connection. Assert that we
don't mix that up.
2023-05-04 10:34:12 +02:00
Thomas Haller
2e3fabae50 release: bump version to 1.43.7 (development) 2023-05-03 16:20:35 +02:00
Fernando Fernandez Mancera
859faa6509 merge: branch 'ff/bond_port_options'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1564
2023-05-03 10:52:35 +02:00
Fernando Fernandez Mancera
2f0571f193 bonding: add support to prio property in bond ports
Add per port priority support for bond active port re-selection during
failover. A higher number means a higher priority in selection. The
primary port still has the highest priority. This option is only
compatible with active-backup, balance-tlb and balance-alb modes.
2023-05-03 10:44:06 +02:00
Fernando Fernandez Mancera
e200b16291 platform: add support to prio property in bond ports 2023-05-03 10:43:58 +02:00
Fernando Fernandez Mancera
bb435674b5 platform: add netlink support for bond port options
sysfs is deprecated and kernel will not add new bond port options to
sysfs. Netlink is a stable API and therefore is the right method to
communicate with kernel in order to set the link options.
2023-05-03 09:55:45 +02:00
Fernando Fernandez Mancera
762cd06ffa libnm: fix ifcfg variable documentation at queue-id property
The correct variable for queue-id in ifcfg is BOND_PORT_QUEUE_ID.
2023-05-03 09:55:45 +02:00
Thomas Haller
d3b5496362 firewall: create "dynamic" sets for nft rules for slb-bonding
A workaround for a nftables issue ([1]). I don't know why that matters.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2177667

Fixes: e9268e3924 ('firewall: add mlag firewall utils for multi chassis link aggregation (MLAG) for bonding-slb')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1614
2023-05-03 08:12:15 +02:00
Thomas Haller
86e635dd4d dns: merge branch 'ts/1281-resolv-conf-non-public-tld'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1281

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1613
2023-05-02 11:48:12 +02:00
Thomas Haller
6a4097fe0b NEWS: update 2023-05-02 11:42:55 +02:00
Thomas Haller
db3da65c6c dns: refactor domain_is_valid() to combine #if blocks 2023-05-02 11:42:55 +02:00
Thomas Haller
4ddbf32f1b dns/trivial: rename check_public_suffix parameter of domain_is_valid()
Names are important. The previous name was counter intuitive for what
the behavior was.
2023-05-02 11:42:49 +02:00
Thomas Haller
601605dbea dns: use NM_STR_HAS_SUFFIX() instead of g_str_has_suffix()
It translates to a plain memcmp() as the argument is a string literal.
2023-05-02 11:40:34 +02:00
Thomas Haller
b4338de984 dns: fix logging for resetting the host-domain
The previous logging happened, when the value did not change. Log
instead, when the value changes.

Fixes: 86bb09c93b ('dns: generate correct search domain for hostnames on non-public TLD')
2023-05-02 11:40:33 +02:00
Tom Sobczynski
86bb09c93b dns: generate correct search domain for hostnames on non-public TLD
dns-manager uses the Mozilla Public Suffix List to determine an
appropriate search domain when generating /etc/resolv.conf. It is
presumed that if the hostname is "example.com", the user does not want
to automatically search "com" for unqualified hostnames, which is
reasonable.  To implement that, prior to the fix, domain_is_valid()
implicitly used the PSL "prevailing star rule", which had the
consequence of assuming that any top-level domain (TLD) is public
whether it is on the official suffix list or not. That meant
"example.local" or "example.localdomain" would not result in searching
"local" or "localdomain" respectively, but rather /etc/resolv.conf would
contain the full hostname "example.local" as the search domain and not
give users what they expect.  The fix here uses the newer PSL API
function that allows us to turn off the "prevailing star rule" so that
"local" and "localdomain" are NOT considered public TLDs because they
are not literally on the suffix list. That in turn gives us the search
domain "local" or "localdomain" in /etc/resolv.conf and allows
unqualified hostname lookups "e.g., resolvectl query example" to find
example.local while example.com still maintains the previous behavior
(i.e., search domain of "example.com" rather than "com").

[thaller@redhat.com: reworded commit message]

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1613
2023-05-02 11:23:09 +02:00
Thomas Haller
cb6f8b987c all: fix various wrong "return FALSE" for returning pointers 2023-05-02 08:37:20 +02:00
Thomas Haller
6428ee04a8 systemd: define ENABLE_GSHADOW to zero
To be consistent with other defines.
2023-05-02 08:36:37 +02:00
Thomas Haller
505356be48 service: increase start timeout of NetworkManager.service
With a large number of interfaces, it can take longer than 45 seconds
before NetworkManager is started (and the D-Bus name acquired). Increase
the start timeout.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1612
2023-04-28 11:01:33 +02:00
Marc Muehlfeld
0cb43c9e42 man: rewrite ipv4.method and ipv6.method man page descriptions
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1275

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1611
2023-04-27 09:09:11 +02:00
Thomas Haller
c07146bd0e core: merge branch 'th/auto-activate-rework'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1597
2023-04-27 09:02:12 +02:00
Thomas Haller
b48c314328 core: simplify tracking of delete_on_deactivate idle action
Before commit a42682d44f ('device: take reference to device object
before 'delete_on_deactivate''), we used a weak pointer to track the
idle action.

As we now use a strong reference, we can store all data about the idle
action in NMDevice itself. Drop DeleteOnDeactivateData.
2023-04-27 08:40:12 +02:00
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