Commit graph

33691 commits

Author SHA1 Message Date
Lubomir Rintel
cecea8f5fd test/nm-service: add support for creating a MACVLAN
...via AddAndActivate. nm-cloud-setup will do that.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
42db1c19f2 test/nm-service: create Vlan devices matching the parent by hwaddr
This is how OCI VLANS will be looking up their parents. Make sure the
mock is able to deal with this.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
5b5bb5ab7c test/nm-service: create software devices on AddAndActivate()
This will be useful for testing VLAN bringup.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
36e37c3916 test/nm-service: add MacvlanDevice class
We'll need to test the nm-cloud-setup OCI multiple VNIC support.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
2b74cfc3fe test/nm-service: add Device.HwAddress property
nm-cloud-setup finds devices by hwaddr. Let's expose it for all device
types, so that we're be able to test once we add VLANs and MACVLANs.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
3f20c10b73 test/cloud-meta-mock: do not print what we listen on if we got a FD
This message is useless for non-interactive use and clobbers over
otherwise very appealing test output.

The callers knows what we're going to listen on, it passed us the file
descriptor.
2025-01-20 06:18:45 +01:00
Íñigo Huguet
57c4cd3849 cloud-setup: oci: remove the max 2 phys NICs limit
Right now, on any baremetal only max. 2 physical NICs are available.
This might change in the future, so better to directly accept larger
nicIndex if we receive it. No behaviour change with this, just remove
an artificial limit.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
cf18e2f677 fixup! cloud-setup: parse OCI metadata related to VLAN config
nm-code-format
2025-01-20 06:18:45 +01:00
Lubomir Rintel
0728a79194 fixup! cloud-setup: parse OCI metadata related to VLAN config
.get_config_data is only alive while the get_config task is running. We
can't reach into it afterwards.

  ==92303== Invalid read of size 8
  ==92303==    at 0x41247D: _iface_data_free (nmcs-provider.c:228)
  ==92303==    by 0x4CB33C1: ??? (in /usr/lib64/libglib-2.0.so.0.6800.4)
  ==92303==    by 0x4CB8082: g_hash_table_unref (in /usr/lib64/libglib-2.0.so.0.6800.4)
  ==92303==    by 0x412425: nm_g_hash_table_unref (nm-shared-utils.h:2171)
  ==92303==    by 0x412425: nmcs_provider_get_config_result_free (nmcs-provider.c:133)
  ==92303==    by 0x407871: main (main.c:995)
  ==92303==  Address 0x63b63f8 is 8 bytes inside a block of size 64 free'd
  ==92303==    at 0x4847B4C: free (vg_replace_malloc.c:989)
  ==92303==    by 0x4CCB76C: g_free (in /usr/lib64/libglib-2.0.so.0.6800.4)
  ==92303==    by 0x4CE81DF: g_slice_free1 (in /usr/lib64/libglib-2.0.so.0.6800.4)
  ==92303==    by 0x411C7B: _get_config_done_cb (nmcs-provider-oci.c:247)
  ==92303==    by 0x4AF2489: ??? (in /usr/lib64/libgio-2.0.so.0.6800.4)
  ==92303==    by 0x4AF268A: ??? (in /usr/lib64/libgio-2.0.so.0.6800.4)
  ==92303==    by 0x40A91C: _poll_req_done_cb (nm-http-client.c:529)
  ==92303==    by 0x4AF2489: ??? (in /usr/lib64/libgio-2.0.so.0.6800.4)
  ==92303==    by 0x4AF268A: ??? (in /usr/lib64/libgio-2.0.so.0.6800.4)
  ==92303==    by 0x415381: _poll_return (nm-shared-utils.c:7174)
  ==92303==    by 0x416D97: _poll_done_cb (nm-shared-utils.c:7201)
  ==92303==    by 0x4AF2489: ??? (in /usr/lib64/libgio-2.0.so.0.6800.4)
  ==92303==  Block was alloc'd at
  ==92303==    at 0x484482F: malloc (vg_replace_malloc.c:446)
  ==92303==    by 0x4CCEB88: g_malloc (in /usr/lib64/libglib-2.0.so.0.6800.4)
  ==92303==    by 0x4CE8C64: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.6800.4)
  ==92303==    by 0x413113: nmcs_provider_get_config (nmcs-provider.c:304)
  ==92303==    by 0x4076BD: _get_config (main.c:359)
  ==92303==    by 0x4076BD: main (main.c:985)
2025-01-20 06:18:45 +01:00
Íñigo Huguet
1d412859c0 cloud-setup: parse OCI metadata related to VLAN config
Baremetal instances in Oracle Cloud require special VLAN config. Parse
the metadata related to it.
2025-01-20 06:18:45 +01:00
Íñigo Huguet
dd5b4fcf24 nmcs: remove nmcs_provider_*_get_type forward declaration
There is no need to avoid including the full header, they are small
headers with some GLib type system stuff and no more. Just include them
where they are needed.
2025-01-20 06:18:45 +01:00
Íñigo Huguet
7fc22ef5de nmcs: oci: use macro to log warnings 2025-01-20 06:18:45 +01:00
Lubomir Rintel
eb635c23a7 manager: create virtual devices on AddAndActivate()
If the connection didn't exist in advance, there's no unrealized device,
and find_device_by_iface() is not going to get us one.

Call system_create_virtual_device() afrer nm_utils_complete_generic()
completes the connection for virtual devices. Make sure we do proper
cleanup if we happen to fail the activation later, so that de device
doesn't end up hanging there.
2025-01-20 06:18:45 +01:00
Lubomir Rintel
57e140d961 manager: split device creation off from validate_activation_request()
Make validate_activation_request() only do the validation -- split the
determination of the device into find_device_for_activation().

The point of this is to be able complete the connection and actually
create a virtual device after the validation.

I believe this is also somewhat easier to follow now that the procedure
does what its name says.
2025-01-20 06:15:54 +01:00
Lubomir Rintel
25871f1971 manager: reword some error messages
They've been a little too cryptic and unnecessarily long before.
2025-01-20 06:13:59 +01:00
Lubomir Rintel
cfe6e730b3 device: don't log connection UUIDs on device creation
It's irrelevant, doesn't look good, and might possibly be not there
because the connection has not been normalized yet.
2025-01-20 06:13:59 +01:00
Lubomir Rintel
be034a1f3f device: simplify the nm_utils_complete_generic() machinery
The point is to get rid of device/connection type specific arguments, to
eventually be able to complete the connection on AddAndActivate before knowing
which factory is going to take care of creating the device.

Aside from that, the whole thing is pretty awful -- with complicated
macros and variadic argument (ugh). Let's get rid of that.
2025-01-20 06:13:59 +01:00
Lubomir Rintel
6635aeed99 device: get_connection_parent() accept incomplete connections
All of these are wrong asserting that a connection has a particular
setting. On AddAndActivate, the connection can be pretty much empty:

  impl_manager_add_and_activate_connection ()
    validate_activation_request ()
      nm_manager_get_best_device_for_connection ()
      iface = nm_manager_get_connection_iface ()
        find_parent_device_for_connection ()
          nm_device_factory_get_connection_parent () <====== *shriek*
        nm_device_factory_get_connection_iface ()
      find_device_by_iface (iface)
    nm_device_complete_connection ()

Remove those assertions.
2025-01-20 06:13:58 +01:00
Lubomir Rintel
b7a8486c53 device: cleanup get_connection_iface() callbacks
Some of them are wrong: they assert a connection has a particular
setting even though this can be called on AddAndActivate against a
connection that is not complete or normalized:

  impl_manager_add_and_activate_connection ()
    validate_activation_request ()
      nm_manager_get_best_device_for_connection ()
      iface = nm_manager_get_connection_iface ()
        find_parent_device_for_connection ()
          nm_device_factory_get_connection_parent ()
        nm_device_factory_get_connection_iface () <====== here
      find_device_by_iface (iface)
    nm_device_complete_connection ()

Fix those by removing the assertions.

Some of them are also fall back to just calling
nm_connection_get_interface_name() which is a pretty useless thing to do
because nm_device_factory_get_connection_iface() only calls the
device-specific routine if nm_device_factory_get_connection_iface()
doesn't return anything, to give the factory a chance to make up a name
(like <parent>.<vlan-id> for Vlan) on its own. Drop those.
2025-01-20 06:13:58 +01:00
Lubomir Rintel
e3d3f1315a device/factory: document that some callbacks get an incomplete connection
It's get_connection_parent() and get_connection_iface().
2025-01-20 06:13:58 +01:00
Íñigo Huguet
f7a30b3241 merge: branch 'ih/ci-check-tree-optional'
ci: make check-tree optional for branches other than main

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2095
2025-01-17 11:21:25 +00:00
Íñigo Huguet
9e47c9bc6a ci: make check-tree optional for branches other than main
Old branches tend to be formatted with a different versions of
clang-format, so when patches are backported, they introduce some
differences in formatting, making the check-tree job to fail.

These changes in formatting are normally small, and we don't pay much
attention to them, causing that the pipelines are always red, increasing
the work required to check if there are important failures or not.

Make check-tree optional for branches other than main. This way,
failures will be shown as a "warning", and if a pipeline only shows a
warning we don't need to inspect it.
2025-01-17 12:16:43 +01:00
Beniamino Galvani
16b932c200 merge: branch 'pr/precedence'
man/NetworkManager-dispatcher: document /{etc,usr} precedence

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2081
2025-01-16 16:12:12 +00:00
Jonathan Lebon
99bb6b7593 man/NetworkManager-dispatcher: document /{etc,usr} precedence
This seems to be left implied but let's document it explicitly.
2025-01-16 16:11:09 +00:00
Jan Vaclav
191aaf0fb2 merge: branch 'jv/fix-qos-mapping'
platform/vlan: fix incorrect type for ingress/egress qos mappings

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2109
2025-01-16 11:09:13 +00:00
Jan Vaclav
4107a6883f platform/test: reenable xgress qos tests
Fixes: 6e30e37ebe ('test: disable vlan_xgress unit test')
2025-01-16 11:08:44 +00:00
Jan Vaclav
84bcc0eab9 platform/vlan: fix incorrect type for ingress/egress qos mappings
The kernel was updated to add stricter validation to netlink messages,
which revealed this bug:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6c21660fe221a15c789dee2bc2fd95516bc5aeaf

Fixes: a5ea141956 ('platform/vlan: add support for ingress/egress-qos-mappings and changing flags')
2025-01-16 11:08:44 +00:00
Jan Vaclav
9ed9037465 ci: use default_distro for coverity job
Previously, the coverity scheduled job seemed to fail
randomly because the image that it expected to use was
not available, due to not depending on the "prep" job.

This commit resolves the problem by making sure
the image is always built when coverity runs.
2025-01-16 11:21:39 +01:00
Beniamino Galvani
7633b5e493 merge: branch 'bg/fix-routed-dns'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2106
2025-01-15 09:05:01 +01:00
Beniamino Galvani
bf3ecd9031 l3cfg: fix DNS routes
The current approach is flawed. During a commit of the L3
configuration we do a RTM_GETROUTE to find the next-hop to the DNS
server on the current interface, in order to create the DNS route to
inject into the l3cd. However, we haven't added routes to kernel yet
and so the result of the RTM_GETROUTE is going to be wrong.

In some cases, for example when IPv4 DAD is enabled, the bug can't be
easily noticed because we perform multiple commits for the interface,
and the regular routes are already set in kernel from the 2nd commit
on.

To fix the problem, do the following: during a commit we first add
addresses and routes to platform. Then, we create a list of DNS routes
to configure, we collect the old DNS routes, and do a comparison. If
they changed, we need to add the DNS routes to platform in a 2nd step.

Note that in the previous approach we tracked the routes in the
committed-l3cd object of the l3cfg, and so they were applied to kernel
automatically. Because of the 2-step requirement, that no longer works
and we must apply the DNS routes manually.

Fixes: 5449b18a94 ('core: support automatically adding DNS routes')
2025-01-14 23:31:59 +01:00
Beniamino Galvani
aefc7732f0 l3cfg: add the DNS routing rule only when needed
Don't try to add the routing rule that points to the table containing
DNS routes at every commit.

Instead, look into the platform cache to see if the rule already
exists and add it only when needed.
2025-01-14 23:31:59 +01:00
Wen Liang
d3da1d56fd merge: branch 'wl/fix_dhcp_send_release'
dhcp-client4: do not send release message when there is no lease

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2084
2025-01-14 16:13:38 +00:00
Wen Liang
55710d3d7c n-dhcp4: send request directly to avoid unnecessary retransmission timeout
Using `n_dhcp4_c_connection_start_request()` will cause staying in
`connection->request`, as a result, it will cause the resending of
DHCPRELEASE and DHCPDECLINE message, thus, use
`n_dhcp4_c_connection_send_request()` directly instead to avoid
unnecessary retransmission timeout, as suggested by
f030927a54 (r1531834009).
2025-01-14 10:58:36 -05:00
Wen Liang
bccf031591 n-dhcp4: do not send the release message in wrong connection state
We should not send the DHCP release message when udp socket is still in
the PACKET state, this state is typically used during the discovery and
offer phases, where the client broadcasts DHCP packets like DHCPDISCOVER
and receives responses like DHCPOFFER. At this point, the client has no
lease because it has not yet completed the DHCP handshake.
2025-01-14 10:58:36 -05:00
Wen Liang
96ff17fd48 dhcp-client4: do not send release message when there is no lease
The daemon crashes when NM tries to send the release message when there
is no lease yet and the UDP socket is still in the PACKET state, which
causes an assertion failure as the result.

Add the condition to guarantee that n-dhcp4 only sends the release
message when there is a lease.

Resolves: https://issues.redhat.com/browse/RHEL-69132

Stack trace of the crash:
0  0x00007f5ac248bacc __pthread_kill_implementation (libc.so.6 + 0x8bacc)
1  0x00007f5ac243e686 __GI_raise (libc.so.6 + 0x3e686)
2  0x00007f5ac2428833 __GI_abort (libc.so.6 + 0x28833)
3  0x00007f5ac242875b __assert_fail_base (libc.so.6 + 0x2875b)
4  0x00007f5ac24373c6 __assert_fail (libc.so.6 + 0x373c6)
5  0x00005607ec7f194a n_dhcp4_c_connection_udp_send (NetworkManager + 0x8594a)
6  0x00005607eca228cc n_dhcp4_c_connection_start_request (NetworkManager + 0x2b68cc)
7  0x00005607eca14b31 nm_dhcp_client_stop (NetworkManager + 0x2a8b31)
8  0x00005607eca8a4ce _dev_ipdhcpx_cleanup (NetworkManager + 0x31e4ce)
9  0x00005607ecac144d _cleanup_ip_pre (NetworkManager + 0x35544d)
10 0x00005607ecac3f04 _cleanup_generic_pre (NetworkManager + 0x357f04)
11 0x00005607ecad5006 nm_device_cleanup (NetworkManager + 0x369006)
12 0x00005607ecac5230 _set_state_full (NetworkManager + 0x359230)
13 0x00005607ecac8c4a nm_device_state_changed (NetworkManager + 0x35cc4a)
14 0x00007f5ac2daa47b g_idle_dispatch (libglib-2.0.so.0 + 0x5147b)
15 0x00007f5ac2dadf4f g_main_dispatch (libglib-2.0.so.0 + 0x54f4f)
16 0x00007f5ac2e03268 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xaa268)
17 0x00007f5ac2dad5a3 g_main_loop_run (libglib-2.0.so.0 + 0x545a3)
18 0x00005607ec7c3eed main (NetworkManager + 0x57eed)
19 0x00007f5ac24295d0 __libc_start_call_main (libc.so.6 + 0x295d0)
20 0x00007f5ac2429680 __libc_start_main_impl (libc.so.6 + 0x29680)
21 0x00005607ec7c43f5 _start (NetworkManager + 0x583f5)
2025-01-14 10:58:36 -05:00
Wen Liang
5993ee8a8a nm-dhcp-client: add argument controlling whether to get next or current lease
In the scenario for sending the release message, we need to guarantee
that NM only sends the release message when the client received a lease
from the server. However, there is some distinction between the
`l3cd_curr` and `l3cd_next` when ACD is pending, because `l3cd_curr` is
NULL but `l3cd_next` is not NULL when ACD is pending. Regardless of
whether ACD is pending or completed, these are all considered the client
have received the release from the server. Therefore, adapt the function
`nm_dhcp_client_get_lease()` to control whether to get next or current
lease.
2025-01-14 10:58:36 -05:00
Fernando Fernandez Mancera
6819f05644 contrib/makerepo.sh: adapt to "fedpkg prep" new behavior
Now "fedpkg prep" command is generating a directory with the "-build"
suffix containing the build directory inside. We need to extract it.

Real example:

If the script is used for a branch related to nm-1-46, the "fedpkg prep"
command will generate a NetworkManager-1.46-build/ directory containing
the NetworkManager-1.46/ sources directory. We just need to move the
NetworkManager-1.46/ out.
2025-01-13 13:29:17 +01:00
Beniamino Galvani
9be28970a6 merge: branch 'bg/encrypted-dns'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2090
2025-01-08 14:44:08 +01:00
Beniamino Galvani
2b194b9f24 NEWS: update 2025-01-07 15:41:46 +01:00
Beniamino Galvani
8f569814ae libnm-core: remove old DNS parsing functions
They are no longer used.
2025-01-07 15:41:45 +01:00
Beniamino Galvani
dd09af121b dispatcher: fix serialization of DNS servers
In the "Action()" D-Bus method, the "nameservers" key used to contain
an array of binary addresses. If we change the key to contain
something else, there can be problems when the NM and the
NM-dispatcher versions mismatch (right after an upgrade or a
downgrade).

To avoid such problem, still send the old key in the old format, and
introduce a new key for the new format. The new format carries the
name servers as a string list, and can encode encrypted DNS servers.
2025-01-07 15:41:45 +01:00
Beniamino Galvani
4c7f1857df initrd-generator: add support for the "rd.net.dns" command line option
Introduce a new kernel command line option named "rd.net.dns" that can
be used to specify a global name server. It accepts name server in a
URI-like form, as for example:

  rd.net.dns=dns+tls://[fd01::1]:5353#mydomain.com
2025-01-07 15:41:44 +01:00
Beniamino Galvani
4422b14704 core, libnm: support per-connection DNS URIs
Accept name servers with a URI syntax in the ipv4.dns and ipv6.dns
properties; and accept them everywhere else in the core and libnm.
2025-01-07 15:41:44 +01:00
Beniamino Galvani
8416a58e26 core: accept DNS URIs in global configuration
Accept name servers specified with an URI syntax in the global
configuration. A plugin that doesn't support a specific scheme can
decide to ignore it and use only the servers it understands. At the
moment there is no plugin that supports DNS-over-TLS servers in the
global configuration.
2025-01-07 15:41:43 +01:00
Beniamino Galvani
4dee109b8d libnm-core: add new functions for DNS parsing
Introduce new functions to parse and normalize name servers. Their
name contains "dns_uri" because they also support a URI-like syntax
as: "dns+tls://192.0.2.0:553#example.org".
2025-01-07 15:41:43 +01:00
Beniamino Galvani
28668f8698 core: simplify nm_l3_config_data_add_nameserver_detail()
Remove unused "server_name" argument. It is still possible to pass the
server name, if needed, with the nm_l3_config_data_add_nameserver()
function. After this change, rename the function to
nm_l3_config_data_add_nameserver_addr(), since the function only
accepts an address.
2025-01-07 15:41:43 +01:00
Wen Liang
85484ab2d3 merge: branch 'wl/vpn_routing_rules'
vpn: fix routing rules support in vpn conenctions

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2092
2025-01-07 14:23:42 +00:00
Wen Liang
308e34a501 vpn: fix routing rules support in vpn conenctions
This commit introduces the ability to manage routing rules specifically
for VPN connections. These rules allow finer control over traffic
routing by enabling the specification of policy-based routing for
traffic over the VPN.

- Updated the connection backend to apply rules during VPN activation.
- Ensured proper cleanup of routing rules upon VPN deactivation.

This enhancement improves VPN usability in scenarios requiring advanced
routing configurations, such as split tunneling and traffic
prioritization.

Resolves: https://issues.redhat.com/browse/RHEL-70160
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2092
https://gitlab.freedesktop.org/NetworkManager/NetworkManager-ci/-/merge_requests/1842
2025-01-07 08:57:11 -05:00
eaglegai
9c42177d09 mptcp: fix error handling rp_filter when kernel don't support mptcp
When the kernel don't support mptcp, NetworkManager should disable mptcp
and shouldn't change rp_filter from 1 to 2. However, when checking file
/proc/sys/net/mptcp/enabled, val v's type is defined to guint32, and
nm_platform_sysctl_get_int32 return -1, v becomes a very large number
and can't set mptcp_flags to NM_MPTCP_FLAGS_DISABLED.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1686
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2093

Fixes: c00873e08f ('mptcp: rework "connection.mptcp-flags" for enabling MPTCP')
2025-01-07 11:20:16 +01:00
Íñigo Huguet
83d99669f5 distros_support.py: always put CentOS Stream at least as Tier 3
We only add to Tier 3 distro versions that ship a version of NM equal or
older to the one that we are testing. As CentOS Stream uses "main", no
stable version will be tested on it.

Force to test CentOS Stream as Tier 3.
2024-12-24 14:42:45 +01:00