Commit graph

33310 commits

Author SHA1 Message Date
Íñigo Huguet
a3fabf163a CI: fix Debian not including policykit-1 and remove EOL'd C8S 2024-08-22 10:51:09 +02:00
Beniamino Galvani
3555dbd2f2 policy: retry hostname resolution when it fails
Currently if the system hostname can't be determined, NetworkManager
only retries when something changes: a new address is added, the DHCP
lease changes, etc.

However, it might happen that the current failure in looking up the
hostname is caused by an external factor, like a temporary outage of
the DNS server.

Add a mechanism to retry the resolution with an increasing timeout.

https://issues.redhat.com/browse/RHEL-17972
(cherry picked from commit 04ad4c86d0)
2024-08-22 10:30:02 +02:00
Íñigo Huguet
08eae55a7e platform: add small backoff time before resync
If the socket's RX buffer is full it's probably because other
process is doing lot of changes very quickly, faster than we
can process them. Let's give the writer a small time to finish:
1. Avoid contending the kernel's RTNL lock, so we don't make
   the whole situation even worse and it can finish earlier.
2. Avoid having to resync again and again due to trying to
   resync while the writer is still doing quick changes, so
   we are unable to catch up yet.

This won't help if this situation takes a long time or is
continuous, but that's unlikely to happen, and if it does,
it's the writer's fault for starving the whole system.

There is no need to progresively increase the backoff time
for the same reason: if this situation takes lot of time,
it's the writer's fault. It's neither a good idea because the whole NM
process will end being sleeping long times, not doing anything at all,
without being able to react when the Netlink messages burst stops.

(cherry picked from commit 830dd4ad9c)
2024-08-22 10:29:32 +02:00
Íñigo Huguet
d12ee5c3cf merge: branch 'bg/bridge-vlan-reapply'
Support reapplying bridge port VLANs

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2002

(cherry picked from commit 926bfab5b5)
2024-08-22 10:27:56 +02:00
Beniamino Galvani
92b366545b bridge: reapply port VLANs only when necessary
Don't touch the bridge VLANs if they are already set.

(cherry picked from commit 447e50d74e)
2024-08-22 10:27:55 +02:00
Beniamino Galvani
5b79bb2feb platform: add nmp_utils_bridge_normalized_vlans_equal()
Add a function to compare two arrays of NMPlatformBridgeVlan. It will
be used in the next commit to compare the VLANs from platform to the
ones we want to set.

To compare in a performant way, the vlans need to be normalized (no
duplicated VLANS, ranges into their minimal expression...). Add the
function nmp_utils_bridge_vlan_normalize.

Co-authored-by: Íñigo Huguet <ihuguet@redhat.com>
(cherry picked from commit 1c43fe5235)
2024-08-22 10:27:54 +02:00
Beniamino Galvani
dfaadf3d3e platform: support reading bridge VLANs
Add a function to read the list of bridge VLANs on an interface.

(cherry picked from commit 7ae4660a77)
2024-08-22 10:27:54 +02:00
Beniamino Galvani
cb5e3ceea7 device: support reapplying bridge-port VLANs
For now, always reapply the VLANs unconditionally, even if they didn't
change in kernel.

To set again the VLANs on the port we need to clear all the existing
one before. However, this deletes also the VLAN for the default-pvid
on the bridge. Therefore, we need some additional logic to inject the
default-pvid in the list of VLANs.

Co-authored-by: Íñigo Huguet <ihuguet@redhat.com>
(cherry picked from commit c5d1e35f99)
2024-08-22 10:27:53 +02:00
Beniamino Galvani
e41844467f bridge: change the signature for nm_platform_link_set_bridge_vlans()
Currently, nm_platform_link_set_bridge_vlans() accepts an array of
pointers to vlan objects; to avoid multiple allocations,
setting_vlans_to_platform() creates the array by piggybacking the
actual data after the pointers array.

In the next commits, the array will need to be manipulated and
extended, which is difficult with the current structure. Instead, pass
separately an array of objects and its size.

(cherry picked from commit e00c81b153)
2024-08-22 10:27:53 +02:00
Beniamino Galvani
b2eb4a927e platform: add define for IFLA_BOND_SLAVE_PRIO
The enum value was added in kernel 5.19; add a define for it so that
the compilation doesn't fail with earlier kernels.

Fixes: 79221f79a2 ('src: drop most slave references from the code')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1596
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2012
(cherry picked from commit 7d3bfb101f)
2024-08-20 13:31:50 +02:00
Fernando Fernandez Mancera
62d745fc9f merge: branch 'th/lldp-fix-crash'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2007

(cherry picked from commit 79c1f8c93a)
2024-08-19 15:21:53 +02:00
Thomas Haller
a1c18ce20d lldp: fix multiple access to argument in logging macro
Fixes: 630de288d2 ('lldp: add libnm-lldp as fork of systemd's sd_lldp_rx')
(cherry picked from commit 4365de5226)
2024-08-19 15:21:53 +02:00
Thomas Haller
8a2f7bd6e0 lldp: fix crash dereferencing NULL pointer during debug logging
During nm_lldp_neighbor_parse(), the NMLldpNeighbor is not yet added to
the NMLldpRX instance. Consequently, n->lldp_rx is NULL.

Note how we use lldp_x for logging, because we need it for the context
for which interface the logging statement is.

Thus, those debug logging statements will follow a NULL pointer and lead
to a crash.

Fixes: 630de288d2 ('lldp: add libnm-lldp as fork of systemd's sd_lldp_rx')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1550
(cherry picked from commit c2cddd3241)
2024-08-19 15:21:53 +02:00
Wen Liang
8243425c6d policy: unblock the autoconnect for children when parent is available
When parent is available and in the process of activation, we should
unblock the autoconnect and schedule an auto activate for the children.
Notice that when the parent is the ovs-interface, the kernel link is
only created in stage3, if we only unblock the children in the stage1,
then the children device and connection will be blocked again due
to the fact the kernel link for the parent ovs-interface is not
existed yet, thus, we have to separately unblock the children
when the parent ovs-interface is in the activated state.

https://issues.redhat.com/browse/RHEL-46904
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2003
https://gitlab.freedesktop.org/NetworkManager/NetworkManager-ci/-/merge_requests/1735
(cherry picked from commit 5f64f292e6)
2024-08-13 08:33:46 -04:00
Fernando Fernandez Mancera
28ef9dae0b release: bump version to 1.48.9 (development) 2024-08-09 17:14:26 +02:00
Fernando Fernandez Mancera
575134dd67 release: bump version to 1.48.8 2024-08-09 17:14:26 +02:00
Isidro Arias
87ec6ae44e examples: fix print parenthesis place in get_ips.py
Fixes: 797d9c4403 ('python: make dbus, gi examples, and debug-helper.py python3 ready')
(cherry picked from commit 75350b3e76)
2024-08-09 17:03:21 +02:00
Lubomir Rintel
5a1f1f669f po/ru: back out unintended changes to the metadata
Seems like and older or broken template has snuck in at some point,
replacing "NetworkManager" with "PACKAGE" and removing copyright notices
of other translations. Bring that back.

Fixes: 3444af517f ('po: update Russian (ru) translation')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1996
(cherry picked from commit 2cd40063c2)
2024-08-09 16:58:38 +02:00
Beniamino Galvani
8445076d55 ndisc: preserve router preferences
If we add multiple default routes with the same metric and different
preferences, kernel merges them into a single ECMP route, with overall
preference equal to the preference of the first route
added. Therefore, the preference of individual routes is not
respected.

To avoid that, add routes with different metrics if they have
different preferences, so that they are not merged together.

We could configure only the route(s) with highest preference ignoring
the others, and the effect would be the same. However, it is better to
add all routes so that users can easily see from "ip route" that there
are multiple routers available.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1468
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1983

Fixes: 032b4e4371 ('core: use router preference for IPv6 routes')
(cherry picked from commit c437625a76)
2024-08-09 16:57:07 +02:00
Fernando Fernandez Mancera
a5fc92b986 merge: branch 'ff/drop_offensive_code'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1984

(cherry picked from commit ccee88ad5a)
2024-08-09 16:53:18 +02:00
Fernando Fernandez Mancera
7bf05b7fa5 config: parse autoconnect-ports value on config
As part of the conscious language effort we must provide an alternative
option to configure autoconnect-ports system-wide on NetworkManager
configuration file.

(cherry picked from commit ad68b28843)
2024-08-09 16:53:17 +02:00
Fernando Fernandez Mancera
7db5ce8c65 dbus-interface: rename activation flag to use conscious language
(cherry picked from commit 3203eb3df0)
2024-08-09 16:53:17 +02:00
Fernando Fernandez Mancera
0ba2d9256e src: drop most slave references from the code
While we cannot remove all the references to "slave" we can remove most
of them.

(cherry picked from commit 79221f79a2)
2024-08-09 16:53:17 +02:00
Fernando Fernandez Mancera
345667f893 src: drop most master references from the code
While we cannot remove all the references to "master" we can remove most
of them.

(cherry picked from commit 090d617017)
2024-08-09 16:53:17 +02:00
Fernando Fernandez Mancera
8e54352ec8 keyfile: do not write offensive terms into keyfile
As part of the conscious language efforts we are not writing offensive
terms into keyfiles anymore. This won't break users upgrading as we
still read such values if they are present into the keyfile.

For existing profiles, NetworkManager will remove the offensive terms
when editing the keyfile.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2009
(cherry picked from commit 9f6ecbae69)
2024-08-09 16:52:32 +02:00
Fernando Fernandez Mancera
63dfd3b60b ovs: fix triggering stage3 activation without DHCP client initialized
It is possible that we learn the link is ready on stage3_ip_config
rather than in link_changed event due to a stage3_ip_config scheduled by
another component. In such cases, we proceed with IP configuration
without allocating the resources needed like initializing DHCP client.

In order to avoid that, if we learn during stage3_ip_config that the
link is now ready, we need to schedule another stage3_ip_config to
allocate the resources we might need.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2004

Fixes: 83bf7a8cdb ('ovs: wait for the link to be ready before activating')
(cherry picked from commit 40d51b9104)
2024-07-31 11:08:53 +02:00
Fernando Fernandez Mancera
8ab31ce62f release: bump version to 1.48.7 (development) 2024-07-25 22:33:13 +02:00
Fernando Fernandez Mancera
27f130ab0c release: bump version to 1.48.6 2024-07-25 22:33:13 +02:00
Beniamino Galvani
1b51404703 policy: assert that the auto-activate list is empty on dispose
We are currently asserting that the list of devices waiting for
auto-activation in NMPolicy is not empty. This condition is always
false because:

 - NMDevice holds a reference to NMManager
 - NMManager holds a reference to NMPolicy
 - on dispose, NMDevice asserts that it's not in NMPolicy's
   auto-activate list

Therefore if there is any NMDevice alive, NMPolicy must be alive as
well. Instead, if there is no NMDevice alive the list must be empty.

The assertion could fail only when the NMPolicy instance gets
disposed, which usually doesn't happen because it's still referenced
at shutdown.

Fixes: aede228974 ('core: assert that devices are not registered when disposing NMPolicy')
(cherry picked from commit 27b646cfa1)
2024-07-25 13:30:08 +02:00
Fernando Fernandez Mancera
00e178351b ovs: wait for the link to be ready before activating
When activating an ovs-interface we already wait for the cloned MAC
address to be set, ifindex is present and platform link also present but
in some cases this is not enough.

If an udev rule is in place it might modify the interface when it is in
a later stage of the activation causing some race conditions or
problems. In order to solve that, we must wait until the link is fully
initialized.

(cherry picked from commit 83bf7a8cdb)
2024-07-25 10:41:50 +02:00
Gris Ge
3f3d1a4f54 activation: Allow changing controller of exposed active connection
When activating a port with its controller deactivating by new
activation, NM will register `state-change` signal waiting controller to
have new active connections. Once controller got new active connection,
the port will invoke `nm_active_connection_set_controller()` which lead
to assert error on
    g_return_if_fail(!nm_dbus_object_is_exported(NM_DBUS_OBJECT(self)))

because this active connection is already exposed as DBUS object.

To fix the problem, we remove the restriction on controller been
write-only and notify DBUS object changes for controller property.

Signed-off-by: Gris Ge <fge@redhat.com>
(cherry picked from commit 83a2595970)
2024-07-12 14:53:37 +02:00
Stanislas FAYE
c89debd716 release: bump version to 1.48.5 (development) 2024-07-05 17:02:16 +02:00
Stanislas FAYE
62a0fa9fcb release: bump version to 1.48.4 2024-07-05 17:02:16 +02:00
Jan Vaclav
f6f466ccf8 agent: print error message character in hex form if it's unprintable
Currently, when the agent manager is sent a registration request
containing UTF-8 characters, it will form an invalid error message
using only one of the bytes from the UTF-8 sequence, which causes
an assertion in glib to fail, which replaces the returned error message
with "[Invalid UTF-8]". It will also print an assertion failure to the
console, or crash NetworkManager on non-release builds.

This commit makes it so that it instead prints out the character in
hexadecimal form if it isn't normally printable, so that it is once
again a valid UTF-8 string.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1965

Fixes: a30cf19858 ('agent: add agent manager and minimal agent class')
(cherry picked from commit c9327b2e8b)
2024-07-05 16:51:18 +02:00
Jan Vaclav
f1888900bd nmtui: handle write() errors correctly in nmt_newt_edit_string
It might happen that write() returns -1, but the errno is not EINTR.
In that case, the length would be incremented by 1, and the data pointer
to the data being written would be moved back by 1 byte on every error.

Make it so that the function exits with an error if it indicates an error.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1971

Fixes: 3bda3fb60c ('nmtui: initial import of nmtui')
(cherry picked from commit 13317bd536)
2024-07-05 16:51:09 +02:00
Beniamino Galvani
69bbc0f4e9 merge: branch 'bg/hostname-fallback-hosts'
Consider entries in /etc/hosts for hostname resolution

https://issues.redhat.com/browse/RHEL-33435
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1974
(cherry picked from commit 5aa5d87ed6)
2024-07-05 14:09:34 +02:00
Beniamino Galvani
9f09d4d364 docs: document the hostname management workflow
(cherry picked from commit 543ebef32b)
2024-07-05 14:09:09 +02:00
Beniamino Galvani
cb54fe7ce9 core: also use /etc/hosts for hostname resolution
Before introducing the hostname lookup via nm-daemon-helper and
systemd-resolved, we used GLib's GResolver which internally relies on
the libc resolver and generally also returns results from /etc/hosts.

With the new mechanism we only ask to systemd-resolved (with
NO_SYNTHESIZE) or perform the lookup via the "dns" NSS module. In both
ways, /etc/hosts is not evaluated.

Since users relied on having the hostname resolved via /etc/hosts,
restore that behavior. Now, after trying the resolution via
systemd-resolved and the "dns" NSS module, we also try via the "files"
NSS module which reads /etc/hosts.

Fixes: 27eae4043b ('device: add a nm_device_resolve_address()')
(cherry picked from commit 410afccb32)
2024-07-05 14:08:29 +02:00
Beniamino Galvani
c36a74f698 nm-daemon-helper: add "service" argument
Introduce a new argument to specify a comma-separated list of NSS
services to use for the "resolve-address" command. For now only accept
"dns" and "files"; the latter can be used to do a lookup into
/etc/hosts.

Note that previously the command failed in presence of extra
arguments. Therefore, when downgrading NetworkManager without
restarting the service, the previously-installed version of the daemon
(newer) would spawn the helper with the extra argument, and the
newly-installed version of the helper (older) would fail. This issue
only impacts hostname resolution and can be fixed by just restarting
the daemon.

In the upgrade path everything works as before, with the only
difference that the helper will use by default both "dns" and "files"
services.

Don't strictly check for the absence of extra arguments, so that in
the future we can introduce more arguments without necessarily break
the downgrade path.

(cherry picked from commit 229bebfae9)
2024-07-05 14:07:55 +02:00
Beniamino Galvani
57dfb9c96e ovs: allow specifying a system OVS interface by MAC address
The OVS interface can be matched via MAC address; in that case, the
"connection.interface-name" property of the connection is empty.

When populating the ovsdb, we need to pass the actual interface name
from the device, not the one from the connection.

Fixes: 830a5a14cb ('device: add support for OpenVSwitch devices')

https://issues.redhat.com/browse/RHEL-34617
(cherry picked from commit be28a11735)
2024-07-05 14:07:37 +02:00
Beniamino Galvani
b2239fa2a8 release: bump version to 1.48.3 (development) 2024-06-24 10:39:14 +02:00
Beniamino Galvani
e73b4894e2 release: bump version to 1.48.2 2024-06-24 10:39:14 +02:00
Beniamino Galvani
fd70c74752 NEWS: update 2024-06-24 10:33:40 +02:00
Beniamino Galvani
96f30a4772 release: bump version to 1.48.1 (development) 2024-06-24 10:18:12 +02:00
Beniamino Galvani
cfc3f3fed7 release.sh: update version check 2024-06-24 10:00:15 +02:00
Beniamino Galvani
a02a21dbb3 Revert "release.sh: stop doing "-dev" releases on stable branches"
The change is happening from release 1.50.

This reverts commit de5cce5972.
2024-06-24 09:56:52 +02:00
Beniamino Galvani
627d0edbf6 crypto: regenerate PKCS#12 certificates
The PKCS#12 certificates are using SHA1 and RC2-40, which are deprecated;
regenerate them with:

 $ openssl pkcs12 -export -in test_key_and_cert.pem -inkey test_key_and_cert.pem -certfile test_ca_cert.pem -name "test-pkcs12" -out test-cert.p12
 (key: test)

 $ openssl pkcs12 -export -in test2_key_and_cert.pem -inkey test2_key_and_cert.pem -certfile test2_ca_cert.pem -name "test2-pkcs12" -out test2-cert.p12
 (key: 12345testing)

Before:
 $ openssl pkcs12 -info -in test-cert.p12
 MAC: sha1, Iteration 2048
 MAC length: 20, salt length: 8
 PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048

After:
 $ openssl pkcs12 -info -in test-cert.p12
 MAC: sha256, Iteration 2048
 MAC length: 32, salt length: 8
 PKCS7 Encrypted data: PBES2, PBKDF2, AES-256-CBC, Iteration 2048, PRF hmacWithSHA256
(cherry picked from commit 0d657af256)
2024-06-24 09:56:36 +02:00
Beniamino Galvani
bd2edfd6fc valgrind: update suppression for memmove and inet_pton6
inet_pton6() can be called from different functions, make the
suppression more generic.

(cherry picked from commit d2536a7d7f)
2024-06-21 23:08:55 +02:00
Fernando Fernandez Mancera
69fde80f8f src: fix code formatting to last clang version
(cherry picked from commit a4bbdeaf54)
2024-06-21 13:21:02 +02:00
Beniamino Galvani
8ade818e0c NEWS: update 2024-06-21 11:41:35 +02:00