Commit Graph

33933 Commits

Author SHA1 Message Date
Jan Vaclav
92c776a88d po: update lists 2025-04-24 10:27:36 +02:00
Jan Vaclav
104be9da87 po: add test to check potfiles list contents
We often forget to add new files to POTFILES, and also
have some paths in the skip file that have not existed
for 15+ years. We should ensure that these files include
the paths that should be there, and nothing more.

This commit adds a test that checks whether all the files
in the po lists exist, and vice versa, that all the files
in the source tree that should be included in this list,
are indeed included in this list.
2025-04-24 10:27:36 +02:00
Beniamino Galvani
e22de07553 merge: branch 'carrier-less-conditions'
device: remove activated condition when the carrier was down

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2189
2025-04-22 16:24:52 +00:00
Friedrich Altheide
c7fc8a4d09 device: remove activated condition when the carrier was down
Call nm_device_update_dynamic_ip_setup every time the carrier was down or was seen down and is now up again, without checking if the state is NM_DEVICE_STATE_ACTIVATED.

Change discussed in https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2173
2025-04-21 19:30:30 +00:00
Beniamino Galvani
87453425ef merge: branch 'dnsconfd_vpn_fix'
dns: Make dnsconfd plugin respect dns-priority

Closes #1748

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2187
2025-04-18 12:32:27 +00:00
Tomas Korbar
e41558e08c dns: Make dnsconfd plugin respect dns-priority
Fixes #1748
2025-04-18 12:14:03 +00:00
Beniamino Galvani
7b2924b762 merge: branch 'bg/ethtool-netlink'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2169
2025-04-17 08:11:54 +02:00
Beniamino Galvani
3fb86182eb README: document the required kernel version
Add a new section in README.md that describes the required Linux
kernel version.
2025-04-17 08:10:54 +02:00
Beniamino Galvani
250475c0fd platform: replace ring ethtool ioctl calls with netlink 2025-04-17 08:10:53 +02:00
Beniamino Galvani
3580dfe517 platform: replace EEE ethtool ioctl calls with netlink 2025-04-17 08:10:51 +02:00
Beniamino Galvani
62c841afcf platform: use the new ethtool-netlink API for pause settings 2025-04-17 08:10:51 +02:00
Beniamino Galvani
79ba228c59 platform: add ethtool netlink implementation
Introduce some basic infrastructure to perform ethtool operations via
netlink. As a proof of concept, implement the pause settings.

Netlink has some advantages over ioctl():

 - it can be easily extended with new attributes;

 - it can return descriptive error messages via the extended ack
   mechanism. For example, when setting the ring parameters to a value
   outside the allowed range, userspace receives error code -EINVAL
   and message "requested ring size exceeds maximum". ioctl() gets
   only -EINVAL, which is shared among many error reasons;

 - since it's possible to specify an ifindex in the request, there are
   no race conditions when the interface name changes;

New ethtool API is available only via netlink; however it makes sense
to start using netlink also for the old API that NM is already using
(pause, eee, rings, etc.) over ioctl() because of the advantages
described above.
2025-04-17 08:10:50 +02:00
Beniamino Galvani
e8a3cd611e platform: move ethtool ioctl functions to a separate file
We're going to replace most of the ioctl-based ethtool functions with
a netlink-based equivalent. Move the ioctl ones to a separate file so
that it's easier to see what still needs to be converted. Also add a
common prefix to the function names.
2025-04-17 08:10:49 +02:00
Beniamino Galvani
88efe48916 libnm-setting: remove unused include 2025-04-17 08:10:49 +02:00
Beniamino Galvani
37785a57e0 platform: use consistent naming for ethtool functions
For unknown reasons (wrong copy and paste?) the getter functions had a
"link" in the name. Remove it.
2025-04-17 08:10:48 +02:00
Íñigo Huguet
a3dd1ef2c7 merge: branch 'ih/fix-ovs-timeout-crash'
core: ovs: fix NULL pointer dereference in ovsdb read timeout callback

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2192
2025-04-16 10:16:02 +00:00
Íñigo Huguet
dc9bf255ee core: ovs: fix NULL pointer dereference in ovsdb read timeout callback
Fixes: f7d321c6d6 ('ovsdb: add watchdog for unparsable JSON data in socket')
2025-04-16 10:15:42 +00:00
Jan Vaclav
b62a0ae7b3 merge: branch 'jv/nmtui-lo'
nmtui: add support for configuring loopback interface

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2175
2025-04-16 07:01:02 +00:00
Jan Vaclav
de56b482f3 nmtui/editor: hide "device" field for loopback connections
This field is irrelevant for this device type, since it will always
be just "lo".
2025-04-15 11:43:06 +00:00
Jan Vaclav
2953200a65 core/devices: generate connections with autoconnect=true
Previously, when a generated connection was edited, and the
machine was rebooted, the connection would not apply, and a
new generated connection would be made, because autoconnect
was set to FALSE.

Set autoconnect to be true by default, so that the modified
generated connection is applied.
2025-04-15 11:43:06 +00:00
Jan Vaclav
f489d213f2 nmtui: add page for configuring loopback interface 2025-04-15 11:43:06 +00:00
Beniamino Galvani
b571e2be5a man: fix syntax to match on connection-id
Fixes: 604c611cd0 ('core: add nm_utils_connection_match_spec_list()')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1746
2025-04-15 11:15:02 +02:00
Filip Pokryvka
ec6d122cc9 release: bump version to 1.53.3 (development) 2025-04-14 19:16:15 +02:00
Beniamino Galvani
065fd3e046 merge: branch 'bg/rto-min'
platform: always set the lock flag for RTO_MIN

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2179
2025-04-14 14:43:09 +00:00
Beniamino Galvani
6478e5158a platform: always set the lock flag for RTO_MIN
The rto-min value is ignored by kernel unless the lock flag is set.
2025-04-14 16:41:39 +02:00
Beniamino Galvani
2b922a93a5 platform: accept 0 as valid rto_min value
iproute2 and the kernel accept 0 as valid rto_min value:

  # ip route add 172.16.0.1 dev enp1s0 rto_min 0ms
  # ip route show
  172.16.0.1 dev enp1s0 scope link rto_min lock 0ms

Even if a value of 0ms would not be useful in practice, it is better
to exactly track what kernel reports, instead of assuming that when
the value is zero it is "not set".
2025-04-14 16:41:39 +02:00
Beniamino Galvani
14106431fb libnm-core: set ovs-dpdk and ovs-patch as non-base settings
Settings "ovs-dpdk" and "ovs-patch" are currently marked with priority
NM_SETTING_PRIORITY_HW_BASE, which makes them "base" settings. This
means that they can be used as connection type, for example via "nmcli
connection add type ovs-dpdk ...".

This is wrong, as both settings can only belong to a connection of
type "ovs-interface". Decrease their priority and make them non-base
settings.

The problem was spotted when trying to add a ovs-patch connection via
nmcli:

  # nmcli connection add type ovs-patch ifname p con-name q ovs-patch.peer r controller s port-type ovs-port
  Warning: controller='s' doesn't refer to any existing profile.

  (process:4580): nm-CRITICAL **: 10:15:42.807: file ../src/libnm-core-impl/nm-connection.c: line 1682 (_normalize_ovs_interface_type): should not be reached

  (process:4580): nm-WARNING **: 10:15:42.807: connection did not verify after normalization: ??

  (process:4580): nm-CRITICAL **: 10:15:42.807: file ../src/libnm-core-impl/nm-connection.c: line 2170 (_connection_normalize): should not be reached
  Error: Failed to add 'q' connection: ovs-interface.type: A connection with 'ovs-patch' setting must be of connection.type "ovs-interface" but is "ovs-patch"

Fixes: d0ec501163 ('cli: assert that valid_parts are set for base types')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2178
2025-04-14 13:39:13 +02:00
Beniamino Galvani
37d8945b13 libnm: fix memory leak when parsing IP configuration
When the dictionary contains keys "address" and "uri", the first value
is leaked.

  ==4730== 14 bytes in 1 blocks are definitely lost in loss record 51 of 1,755
  ==4730==    at 0x4841866: malloc (vg_replace_malloc.c:446)
  ==4730==    by 0x4CC5CB9: g_malloc (gmem.c:100)
  ==4730==    by 0x4CDF518: g_strdup (gstrfuncs.c:323)
  ==4730==    by 0x496A6B8: g_strdup_inline (gstrfuncs.h:321)
  ==4730==    by 0x496A6B8: nm_inet_ntop_dup (nm-inet-utils.h:355)
  ==4730==    by 0x496A95B: nm_inet_parse_str (nm-inet-utils.c:539)
  ==4730==    by 0x48AF3A3: _notify_update_prop_nameservers (nm-ip-config.c:179)

Fixes: 4422b14704 ('core, libnm: support per-connection DNS URIs')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2184
2025-04-14 13:36:57 +02:00
Íñigo Huguet
26f2673b90 merge: branch 'ih/nmcli-ovs-port-type'
nmcli: connection: process port-type, type and controller properties first

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2165
2025-04-14 10:08:28 +00:00
Íñigo Huguet
9f6562869b nmcli: improve the warning message about no controller found
When nmcli tries to match a controller it filters by its type. The
controller's type must match with the port's port-type. If no controller
matches, the printed warning was "doesn't refer to any existing
profile". However, the profile might exist, but with wrong type. Improve
the message so it makes that clear.

Fixes: aa12bb353b ('cli: discover slave type for a connection with a master')
2025-04-14 10:08:01 +00:00
Íñigo Huguet
87a5d89f75 nmcli: choose the right port-type for OVS
Normally it is possible not to define port-type in nmcli and it deduces
it from connection.type or connection.controller. Some types like 'bond-slave'
have a single possible value for port-type. In other cases nmcli deduces
the port-type by getting the controller's type, like 'bond'.

For OVS connections, the second method of guessing by the controller's
type was used.  However, in OVS it is common to have different devices
with the same name, causing nmcli to use "ovs-interface" as port-type
if it matched by controller name.

Fix if by deducing the port-type from the connection's type. An ovs-port
connection must always have port-type=ovs-bridge, and an ovs-interface
connection must always have port-type=ovs-port.

Note that this is something that should be done in the daemon, not in
the clients, but this is a small patch that makes it to work in nmcli,
at least. Without this, the mechanism of guessing from the parent would
act, leading to wrong results.

Ideally, all this should be done in the daemon, but currently many
checks in nmcli/libnm depends on having the port-type set, and it
would be lot of work to change it.

Fixes: c5324ed285 ('nmcli: streamline connection addition')
2025-04-14 10:08:01 +00:00
Íñigo Huguet
6a133d10a1 nmcli: connection: don't overwrite port-type if explicitly set
When processing the "type" property we deduce the port-type in some
cases and set it. If the user has chosen a port-type we must not
overwrite it. In any case, we should raise an error when validating the
connection.

Fixes: c5324ed285 ('nmcli: streamline connection addition')
2025-04-14 10:08:01 +00:00
Íñigo Huguet
bb850fda0e nmcli: connection: process port-type, type and controller first
If the connection is a port we need to set the connection.port-type
property. Usually this property is guessed by nmcli depending on the
connection type or the chosen controller, so it doesn't need to be
specified by the user. However, if it is explicitly set by the user
we should not guess, but just use it.

When we process arguments like "controller" or "type" we call custom
functions like set_connection_controller that will guess the port-type
if needed. By processing port-type first, it will be set in the
connection by the time that these other properties are processed, so they
won't try to guess.

After port-type, process connection.type and connection.controller, as we
are usually capable of deducing the port-type from them. Type needs to
be processed first because some types like bond-slave or ovs-port have
only one possible port-type value so we must not try to guess from the
controller.

Fixes: c5324ed285 ('nmcli: streamline connection addition')
2025-04-14 10:08:01 +00:00
Beniamino Galvani
fcf304bbf1 merge: branch 'carrier-down'
device: renew dhcp lease if carrier was down

Closes #1663

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2173
2025-04-14 07:48:44 +00:00
Friedrich Altheide
163c2574d8 device: renew dhcp lease only if carrier was down
Make sure nm_device_update_dynamic_ip_setup is called every time a carrier was down before and the link is now up again.
Previously the dhcp lease was not renewed if the carrier went down and then up again quickly enough.
This led to cases where an old IP was retained even though the device was connected to a different network with a different DHCP server.

This commit introduces device_link_carrier_changed_down

Fixes: d6429d3ddb ('device: ensure DHCP is restarted every time the link goes up')
2025-04-14 07:04:03 +02:00
Lubomir Rintel
fe0b6ad68c merge: branch 'lr/oci-vm-new-conn'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2180
2025-04-11 12:09:49 +02:00
Lubomir Rintel
cb7157f552 test-client: add test for OCI VNIC on VM
Tests that we create a connection for disconnected device.
2025-04-11 11:44:05 +02:00
Lubomir Rintel
c42322bd0d test-client: split up _mock_devices()
The new VM OCI VNIC tests will need to create the devices, but leave one
disconnected.
2025-04-11 11:44:05 +02:00
Lubomir Rintel
39db524d94 test-client: expand MAC addresses from variable
Less literals, more expanded variables. Makes it a little easier to read
for me.
2025-04-11 11:44:05 +02:00
Lubomir Rintel
79b1877c02 test/nm-service: default the devices to DISCONNETED not UNAVAILABLE
It is a little odd that client tests connect "UNAVAILABLE" devices, and
the devices return to "DISCONNECTED" after deactivation.

It differs from what happens in reality, and some client tools
(hey nm-cloud-setup) can break when they rightly assume that the
device is not ready for activation when it's "UNAVAILABLE" not
"DISCONNECTED".
2025-04-11 11:44:05 +02:00
Lubomir Rintel
548e27ef5f cloud-setup: configure disconnected wired devices on OCI
On OCI VMs (virtual machines, as opposed to BM -- bare metal), the VNICs
don't get their addresses via DHCP and need us to get the address from
the metadata and apply it.

https://issues.redhat.com/browse/NMT-1432
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2180
2025-04-11 11:44:05 +02:00
Lubomir Rintel
0540b3c9bc cloud-setup: add a chicken bit variable for creation of new connections
Make it possible to opt in or out of the behavior of creating
connections for disconnected devices. It's not clear why such policy was
in place, and the feature might come useful outside OCI.

Let's add an (undocumented) knob to configure the behavior. We might
remove it (and perhaps make the behaviour default everywhere), or
document and keep it if it turns out we need to use it.
2025-04-11 11:43:28 +02:00
Lubomir Rintel
93960639e8 cloud-setup: factor out creation of new connection
We're going to create connections on wired devices for OCI VM VNICs, and
they're going to also need the same user setting. Factor it out.
2025-04-11 11:43:20 +02:00
Lubomir Rintel
9895540a24 cloud-setup: add device argument to nmcs_add_and_activate()
This will allow us to add & complete connections for existing devices,
such as VNICs on OCI VMs.
2025-04-11 11:43:00 +02:00
Lubomir Rintel
961be7d971 cloud-setup: split up _nmc_skip_connection_by_type()
Split _nmc_skip_connection_by_type() so that we can get a little
more finely grained error reporting.
2025-04-11 11:42:54 +02:00
Íñigo Huguet
95b9b4b678 merge: branch 'ih/coverity'
Fix some defects detected by Coverity

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2174
2025-04-07 14:15:27 +00:00
Íñigo Huguet
9edfc0438c n-dhcp4: fix resource leaks
The function n_dhcp4_c_connection_send_request does not release or take
ownership of its request argument. Because of that, setting it to NULL
in the caller prevents the auto-cleanup of the variable to be executed,
causing a resource leak. Fix it.

Fixes: e23b3c9c3a ('Squashed 'shared/n-dhcp4/' content from commit fb1d43449')
Fixes: 243cc433fb ('n-dhcp4: add new client probe function to send RELEASE message')
2025-04-07 14:15:09 +00:00
Íñigo Huguet
ae7de5b353 core: fix use after free in ping operations
Detected by coverity, the ping_op pointers are used after being freed in
cleanup_ping_operations. Although calling to g_list_remove is probably
safe because it only needs the value of the pointer, not to dereference
it, better to follow best practices. One of the use after free was
actually an error because we dereference ping_op->log_domain.

Fixes: 658aef0fa1 ('connection: Support connection.ip-ping-addresses')
2025-04-07 14:15:09 +00:00
Íñigo Huguet
42edb37499 bond-slb: initialize dest hw address in GARP packets
Detected by Coverity:
    1. NetworkManager-1.53.1/src/core/nm-bond-manager.c:885:5: var_decl: Declaring variable "data" without initializer.
    7. NetworkManager-1.53.1/src/core/nm-bond-manager.c:948:13: uninit_use_in_call: Using uninitialized value "data". Field "data.d_hw_addr" is uninitialized when calling "sendto".
       946|               unaligned_write_ne32(data.s_ip_addr, tmp_addr);
       947|               unaligned_write_ne32(data.d_ip_addr, tmp_addr);
       948|->             if (sendto(sockfd, &data, sizeof(data), 0, (struct sockaddr *) &addr, sizeof(addr)) < 0)
       949|                   return FALSE;
       950|           }

Fixes: 3f2f922dd9 ('bonding: send ARP announcement on bonding-slb link/carrier down')
2025-04-07 14:15:09 +00:00
Lubomir Rintel
cc0222ba01 nmcli/connections: fix build with libedit
This has always been broken (libedit-0:3.1-17.20160618cvs.fc26 is too
old to work and libedit-0:3.1-20.20170329cvs.fc27.x86_64 has this type
mismatch), but new GCC complains (14, 15).

  ../src/nmcli/connections.c: In function ‘nmcli_editor_tab_completion’:
  ../src/nmcli/connections.c:6862:64: error: assignment to ‘void (*)(char **, int,  int)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
   6862 |                             rl_completion_display_matches_hook = uuid_display_hook;
        |                                                                ^
  ../src/nmcli/connections.c:6909:60: error: assignment to ‘void (*)(char **, int,  int)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
   6909 |                         rl_completion_display_matches_hook = uuid_display_hook;
        |                                                            ^

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2172
2025-04-07 15:27:59 +02:00