Commit Graph

34035 Commits

Author SHA1 Message Date
Beniamino Galvani
404a3ec853 core: fix properties update for HSR devices
Fixes: 5426bdf4a1 ('HSR: add support to HSR/PRP interface')
2025-07-10 09:12:00 +02:00
Beniamino Galvani
62558d50be core: fix constant name for IPv4 method
Fix the name for consistency, even if this is harmless because the
IPv4 and IPv6 values are the same.
2025-07-10 09:12:00 +02:00
Beniamino Galvani
55765d2914 ovs: fix logging message
Fixes: a259303e1d ('ovs: add support for "other_config" settings')
2025-07-10 09:12:00 +02:00
Beniamino Galvani
253800238e libnm-core,core: accept uid/gid up to (2^32 - 2) for tun devices
Linux UIDs/GIDs are 32-bit unsigned integer, with 4294967295 reserved
as undefined.

Before:
  # useradd -u 4294967294 -M testuser
  useradd warning: testuser's uid -2 outside of the UID_MIN 1000 and UID_MAX 60000 range.
  # nmcli connection add type tun ifname tun1 owner 4294967294 ipv4.method disabled ipv6.method disabled
  Error: Failed to add 'tun-tun1' connection: tun.owner: '4294967294': invalid user ID

After:
  # useradd -u 4294967294 -M testuser
  useradd warning: testuser's uid -2 outside of the UID_MIN 1000 and UID_MAX 60000 range.
  # nmcli connection add type tun ifname tun1 owner 4294967294 ipv4.method disabled ipv6.method disabled
  Connection 'tun-tun1' (5da24d19-1723-45d5-8e04-c976f7a251d0) successfully added.
  # ip -d link show tun1
  2421: tun1: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 500
      link/none  promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
      tun type tun pi off vnet_hdr off persist on user testuser ...
                                                 ^^^^^^^^^^^^^
Fixes: 1f30147a7a ('libnm-core: add NMSettingTun')
2025-07-10 09:12:00 +02:00
Beniamino Galvani
45ab9d96f1 platform: use g_strdup() instead of strdup() in ethtool code
The string is freed with g_free(), it needs to be allocated with
g_strdup(). In practice, the GLib allocator uses malloc() nowadays,
but it is better to be consistent.
2025-07-10 09:12:00 +02:00
Beniamino Galvani
326fb8f9cf initrd: make parsing of VLANs more robust
We are missing some validations when parsing VLANs: a unexpected
argument can cause a crash, an assertion, or the connection being
dropped without any warning. Make it more robust.
2025-07-10 09:12:00 +02:00
Beniamino Galvani
eff8471de4 nmcli: fix format
Fixes: a9b66e254c ('nmcli: fix compile error')
2025-07-09 15:08:15 +02:00
Beniamino Galvani
959ddec2a4 contrib/nm-vpn-plugin-utils: add nm_vpn_plugin_utils_get_cert_path()
Add a function to generate the path for imported certificates.

See https://gitlab.gnome.org/GNOME/NetworkManager-openvpn/-/merge_requests/95
2025-07-09 15:06:51 +02:00
Beniamino Galvani
a9b66e254c nmcli: fix compile error
Running the build script with LTO disabled
("contrib/fedora/rpm/build_clean.sh -W lto") gives the following error:

  In file included from ../src/libnm-std-aux/nm-default-std.h:102,
                   from ../src/libnm-glib-aux/nm-default-glib.h:11,
                   from ../src/libnm-glib-aux/nm-default-glib-i18n-lib.h:13,
                   from ../src/libnm-client-aux-extern/nm-default-client.h:11,
                   from ../src/nmcli/connections.c:6:
  In function ‘_nm_auto_unref_ptrarray’,
      inlined from ‘do_connection_add’ at ../src/nmcli/connections.c:6069:35:
  ../src/libnm-std-aux/nm-std-aux.h:1106:12: error: ‘props’ may be used uninitialized [-Werror=maybe-uninitialized]
   1106 |         if (*v)                               \
        |            ^
  ../src/libnm-glib-aux/nm-macros-internal.h:91:1: note: in expansion of macro ‘NM_AUTO_DEFINE_FCN0’
     91 | NM_AUTO_DEFINE_FCN0(GPtrArray *, _nm_auto_unref_ptrarray, g_ptr_array_unref);
        | ^~~~~~~~~~~~~~~~~~~
  ../src/nmcli/connections.c: In function ‘do_connection_add’:
  ../src/nmcli/connections.c:6069:35: note: ‘props’ was declared here
   6069 |     gs_unref_ptrarray GPtrArray  *props;
        |                                   ^~~~~
  cc1: all warnings being treated as errors

Fix it.

Fixes: bb850fda0e ('nmcli: connection: process port-type, type and controller first')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2236
2025-07-08 11:21:02 +02:00
Lubomir Rintel
9bbb113987 device: don't disable IPv6 in stage3 on reapply
Currently, when a call to Reapply() results in stage3 being re-run, IPv6
ends up messed up. Like this:

  $ nmcli device modify eth0 ipv4.address ''
  $ nmcli device modify eth0 ipv4.address 172.31.13.37/24
  $

  NetworkManager[666]: <debug> [1751286095.2070] device[c95ca04a69467d81] (eth0): ip4: reapply...
  ...
  NetworkManager[666]: <debug> [1751286095.2104] device[c95ca04a69467d81] (eth0): ip6: addrgenmode6: set none (already set)
  NetworkManager[666]: <debug> [1751286095.2105] device[c95ca04a69467d81] (eth0): ip6: addrgenmode6: toggle disable_ipv6 sysctl after disabling addr-gen-mode
  NetworkManager[666]: <debug> [1751286095.2105] platform-linux: sysctl: setting '/proc/sys/net/ipv6/conf/eth0/disable_ipv6' to '1' (current value is '0')
  NetworkManager[666]: <debug> [1751286095.2106] platform-linux: sysctl: setting '/proc/sys/net/ipv6/conf/eth0/disable_ipv6' to '0' (current value is '1')
  NetworkManager[666]: <debug> [1751286095.2106] platform-linux: sysctl: setting '/proc/sys/net/ipv6/conf/eth0/accept_ra' to '0' (current value is identical)
  NetworkManager[666]: <debug> [1751286095.2106] platform-linux: sysctl: setting '/proc/sys/net/ipv6/conf/eth0/disable_ipv6' to '0' (current value is identical)

Not only is this unnecessary because addr-gen-mode already has the
desired value (as is logged), but also wipes off all IPv6 configuration.
This is fine on initial configuration, but not on Reapply().

Let's look at the device state first: if we've progressed past ip-config
state, then we can't possibly ever touch the offending sysctls. It's
okay -- we don't need to: addr-gen-mode is going to be set right if we
went through ip-config before.

Resolves: https://issues.redhat.com/browse/NMT-1681

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2232
2025-07-07 15:38:51 +02:00
Lubomir Rintel
2de6391f4b device: drop a redundant assert
This is essentially:

  a = b
  assert(a == b)

Not useful.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2233
2025-07-07 15:16:34 +02:00
Íñigo Huguet
a39fa7ee6c merge: branch 'ih/spec_git_tag'
spec: add git_tag_version

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2238
2025-07-07 13:09:50 +00:00
Íñigo Huguet
3cba4f2627 spec: add git_tag_version
The URL to the tarball needs the git tag, that might be 1.54-rc1 instead
of 1.53.90. Allow to define it as a separate variable in the spec file.
It can be set as `git_tag_version %{real_version}` when they are
identical.

It is not really needed here in the upstream spec file, as the "Source"
line is commented out, but add it as a reference for donwstream spec
files.
2025-07-07 09:27:05 +02:00
Íñigo Huguet
cc5306e1d0 NEWS: update 2025-07-07 09:14:34 +02:00
Beniamino Galvani
37c0e0860e NEWS: update 2025-07-01 14:26:44 +02:00
Beniamino Galvani
165e5df6e0 nmcli: accept certain IP settings on port connections
Commit bb850fda0e ('nmcli: connection: process port-type, type
and controller first') started correctly rejecting IP configuration
on port connections.

However, previously nmcli would accept IP parameters for ports when
using a specific parameters order. To avoid breaking user scripts that
may have relied on this behavior, introduce a backward compatibility
quirk.

Specifically, nmcli accepts a disabled/ignore IP method on a port
connection. For any other IP setting on a port connection, a specific
error message is now shown.

https://issues.redhat.com/browse/RHEL-90756
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2227
2025-07-01 14:21:23 +02:00
Beniamino Galvani
25a5fd7503 merge: branch 'bg/sriov-preserve-capability'
manager: add a capability for "sriov.preserve-on-down"

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2234
2025-07-01 07:37:17 +00:00
Beniamino Galvani
8e40f7e289 manager: add a capability for "sriov.preserve-on-down"
Add a new capability to indicate that NetworkManager supports the
"sriov.preserve-on-down" connection property. With this, clients can
set the property only when supported, without the risk of creating an
invalid connection.
2025-06-30 22:38:18 +02:00
Beniamino Galvani
ea6af6d806 libnm-core: change version of ip4-forwarding capability
NM_VERSION_INFO_CAPABILITY_IP4_FORWARDING was backported to branch
nm-1-54 before the 1.54 release. Update the symbol version.
2025-06-30 22:33:29 +02:00
Beniamino Galvani
5ab04c8f56 libnm: change "sriov.preserve-on-down" symbols version to 1.54
The "sriov.preserve-on-down" libnm symbols were backported to the 1.54
branch before the final release. Change their version on main to be
"1.54".

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2229
2025-06-27 14:11:47 +02:00
Beniamino Galvani
7bb898fa12 libnm: fix g-ir-scanner build warning
Fix the following build warning emitted by g-ir-scanner:

  ../src/libnm-core-public/nm-dbus-interface.h:103: Warning: NM: "@NM_VERSION_INFO_CAPABILITY_IP4_FORWARDING" parameter unexpected at this location:
   * @NM_VERSION_INFO_CAPABILITY_IP4_FORWARDING: Indicates that NetworkManager supports
      ^

Fixes: 6a13e8d369 ('core: expose the version info capability of IPv4 forwarding support')
2025-06-26 13:22:33 +02:00
Beniamino Galvani
9b4569bd94 merge: branch 'bg/route-via'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2222
2025-06-26 11:55:45 +02:00
Beniamino Galvani
24ab3308fe platform: add test for route via attribute 2025-06-26 11:37:17 +02:00
Beniamino Galvani
00257a9cf7 platform: parse the RT_VIA route attribute
Parse the "via" attribute in netlink routes received by kernel, so
that we can update the internal cache.
2025-06-26 11:37:16 +02:00
Beniamino Galvani
9c70a43775 platform: use the "via" attribute in route NMPObject methods
Update the cmd_obj_hash_update(), cmd_obj_cmp(), cmd_obj_to_string()
NMPObject methods for IPv4 routes to consider the "via" attribute.
2025-06-26 11:37:16 +02:00
Mary Strodl
2ffaebd4ae platform: support the RT_VIA attribute for IPv4 routes
The RT_VIA attribute is used to specify a gateway of a different
address family. It is currently used only for IPv4 routes.

[bgalvani@redhat.com: amended the commit message]
2025-06-26 11:37:15 +02:00
Wen Liang
84299ed17c merge: branch 'forwarding_version_info'
core: expose the version info capability sync of forwarding support

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2226
2025-06-24 13:12:28 +00:00
Wen Liang
6a13e8d369 core: expose the version info capability of IPv4 forwarding support
This commit adds NM_VERSION_INFO_CAPABILITY_IPV4_FORWARDING to the
VersionInfo D-Bus property, allowing clients such as nmstate to check
the NetworkManager's support of configuring per-device IPv4 sysctl
forwarding setting directly via the capabilities bitmask instead of
relying on the NetworkManager version comparisons.
2025-06-23 13:30:14 -04:00
Filip Pokryvka
e26e965134 release: bump version to 1.55.1 (development) 2025-06-20 09:19:23 +02:00
Beniamino Galvani
a78f8bbe1b merge: branch 'bg/systemd-fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2223
2025-06-19 15:09:07 +02:00
Beniamino Galvani
9f510533f1 systemd: ignore device_is_devtype()
The function uses symbol sd_device_get_devtype() which is currently
commented out. Therefore, NM dynamically links to the symbol from the
libsystemd shared object, which breaks on machines without systemd.

Before:
$ nm -u build/src/core/NetworkManager | grep sd_device
                 U sd_device_get_sysattr_value@LIBSYSTEMD_240
$

After:
$ nm -u build/src/core/NetworkManager | grep sd_device
$

Fixes: 6a4e6fab40 ('merge: branch 'systemd' into jv/systemd-merge')
2025-06-19 15:08:02 +02:00
Beniamino Galvani
77c99b61c0 Revert "sd-device: use sd_device_get_sysattr_value() to read special symlinks"
Revert systemd commit 6ebbdcc0ddba ("sd-device: use
sd_device_get_sysattr_value() to read special symlinks"). In the NM
codebase sd_device_get_sysattr_value() is currently commented out
because it depends on file chase.c which is not imported. Importing
that file would require another long chain of imports. Therefore,
revert the commit.

This reverts commit 6ebbdcc0ddbacce732001823cf2be2a1d4381c60.

Fixes: 6a4e6fab40 ('merge: branch 'systemd' into jv/systemd-merge')
2025-06-19 15:08:02 +02:00
Beniamino Galvani
fcc5352715 Revert "sd-device: use sd_device_get_sysattr_value() to read uevent file"
Revert systemd commit 17dc9ec4b6e8 ("sd-device: use
sd_device_get_sysattr_value() to read uevent file"). In the NM
codebase sd_device_get_sysattr_value() is currently commented out
because it depends on file chase.c which is not imported. Importing
that file would require another long chain of imports. Therefore,
revert the commit.

This reverts commit 17dc9ec4b6e82fc2a4f9809011e154f538eb8b9c.

Fixes: 6a4e6fab40 ('merge: branch 'systemd' into jv/systemd-merge')
2025-06-19 15:08:02 +02:00
Beniamino Galvani
1253cbad5a connectivity: fix compiler warning when building without concheck
Fix the following:

../src/core/nm-connectivity.c:958:1: warning: ‘check_platform_config’ defined but not used [-Wunused-function]
  958 | check_platform_config(NMConnectivity *self,
      | ^~~~~~~~~~~~~~~~~~~~~

Fixes: 91d447df19 ('device: don't start connectivity check on unconfigured devices')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2224
2025-06-19 15:06:53 +02:00
Íñigo Huguet
dd7f9fdf8e merge: branch 'ih/rm-forwarding-ignore'
ipv4: remove the forwarding=ignore value

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2221
2025-06-19 12:27:49 +00:00
Íñigo Huguet
82692cc75c ipv4: remove the forwarding=ignore value
It is not clear whether we can actually respect this value. For example,
we should not restore the kernel's default value on deactivation or
device's state change, but it is unclear if we can ensure that we'll
still have the connection's configuration in all possible changes of
state.

Also, it is unclear if it's a desirable value that we want to support.
At this point it is mostly clear that trying to configure NM managed
devices externally always ends being dissapointing, no matter how hard
we try.

Remove this value for now, while we discuss whether it makes sense or
not, so it doesn't become stable in the new 1.54 release.
2025-06-19 12:27:35 +00:00
Beniamino Galvani
a4ee55468f merge: branch 'bg/sriov-preserve-on-down'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2219
https://issues.redhat.com/browse/RHEL-69125
2025-06-18 13:22:35 +02:00
Beniamino Galvani
3588c48686 NEWS: update 2025-06-18 13:21:19 +02:00
Beniamino Galvani
6f219aa649 device: allow reapplying the sriov.preserve-on-down property
It is useful when there is an already active device and we want to
bring it down preserving the SR-IOV VFs. For example:

  $ nmcli connection add type ethernet ifname eni1np1 sriov.total-vfs 2 ipv4.method disabled ipv6.method disabled
  $ nmcli connection up ethernet-eni1np1

  $ ip link show eni1np1
  342: eni1np1: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
      link/ether 6e:cf:f0:08:74:f4 brd ff:ff:ff:ff:ff:ff
      vf 0     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ...
      vf 1     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ...

  $ nmcli device modify eni1np1 sriov.preserve-on-down yes
  $ nmcli connection down ethernet-eni1np1

  $ ip link show eni1np1
  342: eni1np1: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
      link/ether 6e:cf:f0:08:74:f4 brd ff:ff:ff:ff:ff:ff
      vf 0     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ...
      vf 1     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff, ...
2025-06-18 13:20:49 +02:00
Beniamino Galvani
c70b4a98a3 core: use the sriov.preserve-on-down property 2025-06-18 13:20:49 +02:00
Beniamino Galvani
eb0a22a162 libnm,nmcli: add sriov.preserve-on-down property
Add a new "sriov.preserve-on-down" property that controls whether
NetworkManager preserves the SR-IOV parameters set on the device when
the connection is deactivated, or whether it resets them to their
default value. The SR-IOV parameters are those specified in the
"sriov" setting, like the number of VFs to create, the eswitch
configuration, etc.
2025-06-18 13:20:49 +02:00
Beniamino Galvani
7212d8b8e9 version: add 1.56 macros 2025-06-18 13:20:49 +02:00
Beniamino Galvani
cceec45089 merge: branch 'bg/nmcli-wg-peers'
nmcli: allow setting the wireguard peers

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2220
2025-06-18 09:08:17 +00:00
Beniamino Galvani
b4dde691ec nmcli: add support for managing wireguard peers
Even if WireGuard is supported since long time in NetworkManager, it
is still not possible to manage the list of peers via nmcli. The
reason is that in the past we wanted to introduce a special syntax
that would allow to manage the peer list more easily. However, this
requires heavy changes to the nmcli output formatting code, and so it
never happened.

Since perfection is the enemy of good, abandon the idea of a custom
handling of peers and treat them as any other composite property. The
property is named "wireguard.peers" and exposes the peers indexed by
public key, with optional attributes.

Example:

  $ nmcli connection modify wg0 wireguard.peers "8Wgc1a0jJX3rQULwD5NFFLKrKQnbOnTiaNoerLneG1o= preshared-key=16uGwZvROnwyNGoW6Z3pvJB5GKbd6ncYROA/FFleLQA= allowed-ips=0.0.0.0/0 persistent-keepalive=10"
  $ nmcli connection modify wg0 +wireguard.peers "fd2NSxUjkaR/Jft15+gpXU13hKSyZLoe4cp+g+feBCc= allowed-ips=192.168.40.0/24 endpoint=172.25.10.1:8888"
  $ nmcli -g wireguard.peers connection show wg0
  8Wgc1a0jJX3rQULwD5NFFLKrKQnbOnTiaNoerLneG1o= allowed-ips=0.0.0.0/0 persistent-keepalive=10, fd2NSxUjkaR/Jft15+gpXU13hKSyZLoe4cp+g+feBCc= allowed-ips=192.168.40.0/24 endpoint=172.25.10.1\:8888
  $ nmcli connection modify wg0 -wireguard.peers 8Wgc1a0jJX3rQULwD5NFFLKrKQnbOnTiaNoerLneG1o=
  $ nmcli -g wireguard.peers connection show wg0
  fd2NSxUjkaR/Jft15+gpXU13hKSyZLoe4cp+g+feBCc= allowed-ips=192.168.40.0/24 endpoint=172.25.10.1\:8888
2025-06-16 13:20:02 +02:00
Beniamino Galvani
f13aca1aba NEWS: update 2025-06-16 10:23:25 +02:00
Jan Vaclav
9abe5658cc merge: branch 'jv/systemd-merge'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2213
2025-06-10 09:23:34 +02:00
Beniamino Galvani
46e0d2b4e4 ovs: set the tun interface up before stage3
When using the netdev datapath, we wait that the tun link appears, we
call nm_device_set_ip_ifindex() (which also brings the link up) and
then we check that the link is ready, i.e. that udev has announced the
link and the MAC address is correct. After that, we schedule stage3
(ip-config).

In this, there is a race condition that occurs sometimes in NMCI test
ovs_datapath_type_netdev_with_cloned_mac. In rare conditions,
nm_device_set_ip_ifindex() bring the interface up but then ovs-vswitch
changes again the flags of the interface without IFF_UP. The result is
that the interface stays down, breaking communications.

To fix this, we need to always call nm_device_bring_up() after the tun
device is ready. The problem is that we can't do it in
_netdev_tun_link_cb() because that function is already invoked
synchronously from platform code.

Instead, simplify the handling of the netdev datapath. Every
"link-changed" event from platform is handled by
_netdev_tun_link_cb(), which always schedule a delayed function
_netdev_tun_link_cb_in_idle(). This function just assigns the
ip-ifindex to the device if missing, and starts stage3 if the link is
ready. While doing so, it also bring the interface up.

Fixes: 99a6c6eda6 ('ovs, dpdk: fix creating ovs-interface when the ovs-bridge is netdev')

https://issues.redhat.com/browse/RHEL-17358

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2218
2025-06-06 16:35:12 +02:00
Beniamino Galvani
b678ceab9f merge: branch 'wpa3_transition_fix'
core: fix WPA2 fallback for WPA3 transition APs

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/2205
2025-06-05 16:15:49 +00:00
Conn O'Griofa
b00c6749d7 core: fix WPA2 fallback for WPA3 transition APs
When connecting to an AP configured for WPA3 transition mode, the
connection will fail if PMF is disabled on the client due to SAE and
FT-SAE being unconditionally added to the key_mgmt variable's
parameters.

By removing the "!is_ap ||" check, SAE and FT-SAE will no longer be
selected when PMF is disabled, allowing clients to connect via
WPA2/PSK mode as per the original intent of
a0988868ba.

Signed-off-by: Conn O'Griofa <connogriofa@gmail.com>
2025-06-05 11:54:16 +00:00
Jan Vaclav
eac9f828e8 tools/nm-in-container: add --skip-unavailable flag for installing debuginfo 2025-06-02 11:08:19 +00:00