Commit graph

17312 commits

Author SHA1 Message Date
Gris Ge 7096f52a59 ovs: Do not allow OVS bridge and port to be parent
When creating VLAN over OVS internal interface which holding the same
name as its controller OVS bridge, NetworkManager will fail with error:

    Error: Connection activation failed: br0.101 failed to create
    resources: cannot retrieve ifindex of interface br0 (Open vSwitch
    Bridge)

Expanded the `find_device_by_iface()` with additional argument
`child: NmConnection *` which will validate whether candidate is
suitable to be parent device.

In `nm_device_check_parent_connection_compatible()`, we only not allow OVS
bridge and OVS port being parent.

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

Signed-off-by: Gris Ge <fge@redhat.com>
2024-03-15 16:12:37 +08:00
Fernando Fernandez Mancera 170e128215 core: deprecate master in NMActiveConnection internal API
PROP_INT_MASTER_READY and PROP_INT_MASTER are internal API only, that
means we can replace it right away. In addition, replace the functions
related to the properties.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1885
2024-03-13 18:24:47 +01:00
Fernando Fernandez Mancera 1f05526ed7 core: drop NMDevice master and introduce controller
The master property for NMDevice is internal only therefore we can
replace it directly with controller. In addition, I have adapted related
functions to use controller instead of master.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1881
2024-03-13 18:00:40 +01:00
Yegor Yefremov ecfd564161 build: remove a header defined twice
Fixes the following warning:

src/libnm-client-impl/meson.build:139: WARNING: Keyword argument "header" defined multiple times.
WARNING: This will be an error in future Meson releases.
2024-03-13 15:56:10 +01:00
Gris Ge 86d67da28d checkpoint: Allow rollback on internal global DNS
With `NM_CHECKPOINT_CREATE_FLAG_TRACK_INTERNAL_GLOBAL_DNS` flag set on
checkpoint creation, the checkpoint rollback will restore the
global DNS in internal configure file
`/var/lib/NetworkManager/NetworkManager-intern.conf`.

If user has set global DNS in /etc folder, this flag will not take any
effect.

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

Signed-off-by: Gris Ge <fge@redhat.com>
2024-03-13 20:52:37 +08:00
Beniamino Galvani b185d21c95 l3cfg: fix handling of ipv6 hop limit
Fixes: 5c48c5d5d6 ('l3cfg: set IPv6 sysctls during NML3Cfg commit')

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1883
2024-03-12 09:58:28 +01:00
Wen Liang db5b92fa03 libnm: use nm_setting_connection_get_controller() where possible
To enforce conscious language support, use
`nm_setting_connection_get_controller()` where possible and replace
`nm_setting_connection_get_master()`.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1882
2024-03-12 09:54:31 +01:00
Fernando Fernandez Mancera 3cb9065305 Revert "build: workaround -Wno-calloc-transposed-args warning in systemd code"
Upstream systemd code was re-imported and therefore the issue is now
solved. Enable the warning again.

This reverts commit b1016e3be8.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1886
2024-03-12 09:47:06 +01:00
Jan Vaclav f9397a5740 test/client: set 802-11-wireless.mac-address-denylist 2024-03-11 11:42:19 +01:00
Jan Vaclav fda0f8435d all: use the new NMSettingWireless mac-address-denylist property 2024-03-11 11:42:19 +01:00
Jan Vaclav fa215c6a69 wireless: deprecate NMSettingWireless mac-address-blacklist property
To embrace inclusive language, deprecate the NMSettingWireless
mac-address-blacklist property and introduce mac-address-denylist property.
2024-03-11 11:42:19 +01:00
Jan Vaclav ec91aa3c70 libnm: add property_type argument to _nm_setting_property_define_direct_strv
The purpose of this is to allow overriding to_dbus_fcn and from_dbus_fcn when
necessary (such as for special behavior regarding a deprecated/aliased properties).
2024-03-11 11:42:19 +01:00
Jan Vaclav 8f9ed29e2c libnm: allow _nm_setting_property_define_direct_strv() to be used as expression
This is so that the resulting index can be used for aliasing properties.
2024-03-11 11:42:19 +01:00
Jan Vaclav 1bb73bd552 libnm: add _NM_DEPRECATED_INCLUSIVE_LANGUAGE_1_48 2024-03-11 11:42:19 +01:00
Fernando Fernandez Mancera ac4e63ddda ip: support dhcp-send-release in NMSettingIpConfig
Introduce a new option to NMSettingIpConfig. The new option is ternary
type being the default value set to disabled. When enabled,
NetworkManager will instruct the DHCP client to send RELEASE message
when IP addresses are being removed.
2024-03-06 11:14:16 +01:00
Fernando Fernandez Mancera 243cc433fb n-dhcp4: add new client probe function to send RELEASE message
The new function uses the client probe connection to send a RELEASE
message. Returns zero if successful otherwise returns non-zero value.
2024-03-06 11:14:16 +01:00
Fernando Fernandez Mancera 0f0f1bbf8a n-dhcp4: set xid value of the DHCP header for RELEASE and DECLINE message
The `xid` of the DHCP header must be initialized for RELEASE and DECLINE
messages [1].

[1] https://datatracker.ietf.org/doc/html/rfc2131#section-4.4.1
2024-03-06 11:14:16 +01:00
Fernando Fernandez Mancera 3be44c0aa8 device: rename _dev_ipdhcpx_cleanup() "release" argument
The argument might imply that when set to FALSE, the dhcp client won't
send a RELEASE message. This won't be true with the new
dhcp-send-release option that is going to be introduced.

Instead, change the name to "force_release", when set to TRUE it means
we are sending a RELEASE message even if not indicated by the user. When
set to FALSE, it will be up to the user.
2024-03-06 11:14:16 +01:00
Fernando Fernandez Mancera 32b20fbc8c merge: branch 'ff/fix_systemd'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1877
2024-03-06 11:03:38 +01:00
Fernando Fernandez Mancera bd38a19832 connection: add support to down-on-poweroff
The new option at NMSettingConnection allow the user to specify if the
connection needs to be down when powering off the system. This is useful
for IP address removal prior powering off. In order to accomplish that,
we listen on "Shutdown" systemd DBus signal.

The option is set to FALSE by default, it can be specified globally on
configuration file or per profile.
2024-03-04 18:16:54 +00:00
Fernando Fernandez Mancera c8cf02e6b8 manager: abstract code from do_sleep_wake() to reuse it
The code that is adding the devices to the sleeping list and taking them
down should be moved to a separated function. This way we can reuse it
and we avoid duplicating code.
2024-03-04 18:29:07 +01:00
Fernando Fernandez Mancera 05ef682bb5 power: remove monitoring of upower signals
UPower "Sleeping" and "Resuming" signals were dropped long ago [1].
Therefore we are also dropping the support of it.

[1] https://lists.freedesktop.org/archives/devkit-devel/2014-March/001575.html
2024-03-04 18:29:07 +01:00
Fernando Fernandez Mancera 5ab87886f3 power: rename NMSleepMonitor to NMPowerMonitor
In order to provide the NMSleepMonitor a more generic usage, let's
rename the whole module to NMPowerMonitor. Nothing is exposed to the API
so it is a trivial renaming.
2024-03-04 18:29:07 +01:00
Fernando Fernandez Mancera e7ad3d93ab merge: branch 'systemd' into ff/fix_systemd
Disabled unused code and adapted Makefile and meson files.
2024-03-04 18:19:25 +01:00
Fernando Fernandez Mancera bee8609c15 systemd: update code from upstream (2024-03-04)
This is a direct dump from systemd git.

  $ git clean -fdx && \
    git cat-file -p HEAD | sed '1,/^======$/ d' | bash - && \
    git add .

======

SYSTEMD_DIR=../systemd
COMMIT=20ba8a5a666d8ddfdcd718a4836450bd876aa3dd

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files -z :/src/libnm-systemd-core/src/ \
                :/src/libnm-systemd-shared/src/ \
                :/src/libnm-std-aux/unaligned-fundamental.h \
                :/src/libnm-std-aux/unaligned.h | \
  xargs -0 rm -f

nm_copy_sd_shared() {
    mkdir -p "./src/libnm-systemd-shared/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-systemd-shared/$1"
}

nm_copy_sd_core() {
    mkdir -p "./src/libnm-systemd-core/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-systemd-core/$1"
}

nm_copy_sd_stdaux() {
    mkdir -p "./src/libnm-std-aux/"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-std-aux/${1##*/}"
}

nm_copy_sd_core "src/libsystemd-network/dhcp-duid-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-client-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/network-common.c"
nm_copy_sd_core "src/libsystemd-network/network-common.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-duid.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd/sd-device/device-internal.h"
nm_copy_sd_core "src/libsystemd/sd-device/device-private.c"
nm_copy_sd_core "src/libsystemd/sd-device/device-private.h"
nm_copy_sd_core "src/libsystemd/sd-device/device-util.h"
nm_copy_sd_core "src/libsystemd/sd-device/sd-device.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-device.h"
nm_copy_sd_core "src/systemd/sd-dhcp-duid.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-option.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-protocol.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/arphrd-util.h"
nm_copy_sd_shared "src/basic/btrfs.c"
nm_copy_sd_shared "src/basic/btrfs.h"
nm_copy_sd_shared "src/basic/cgroup-util.h"
nm_copy_sd_shared "src/basic/chase.h"
nm_copy_sd_shared "src/basic/constants.h"
nm_copy_sd_shared "src/basic/devnum-util.c"
nm_copy_sd_shared "src/basic/devnum-util.h"
nm_copy_sd_shared "src/basic/dns-def.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/format-util.c"
nm_copy_sd_shared "src/basic/format-util.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/glyph-util.c"
nm_copy_sd_shared "src/basic/glyph-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/inotify-util.c"
nm_copy_sd_shared "src/basic/inotify-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/iovec-util.h"
nm_copy_sd_shared "src/basic/label.c"
nm_copy_sd_shared "src/basic/label.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/locale-util.c"
nm_copy_sd_shared "src/basic/locale-util.h"
nm_copy_sd_shared "src/basic/lock-util.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_random.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_syscall.h"
nm_copy_sd_shared "src/basic/missing_threads.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/namespace-util.h"
nm_copy_sd_shared "src/basic/ordered-set.c"
nm_copy_sd_shared "src/basic/ordered-set.h"
nm_copy_sd_shared "src/basic/origin-id.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/pidref.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/ratelimit.c"
nm_copy_sd_shared "src/basic/ratelimit.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.c"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/strxcpyx.c"
nm_copy_sd_shared "src/basic/strxcpyx.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/user-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/fundamental/logarithm.h"
nm_copy_sd_shared "src/fundamental/macro-fundamental.h"
nm_copy_sd_shared "src/fundamental/memory-util-fundamental.h"
nm_copy_sd_shared "src/fundamental/sha256.c"
nm_copy_sd_shared "src/fundamental/sha256.h"
nm_copy_sd_shared "src/fundamental/string-util-fundamental.c"
nm_copy_sd_shared "src/fundamental/string-util-fundamental.h"
nm_copy_sd_shared "src/shared/dns-domain.c"
nm_copy_sd_shared "src/shared/dns-domain.h"
nm_copy_sd_shared "src/shared/log-link.h"
nm_copy_sd_shared "src/shared/web-util.c"
nm_copy_sd_shared "src/shared/web-util.h"
nm_copy_sd_stdaux "src/basic/unaligned.h"
nm_copy_sd_stdaux "src/fundamental/unaligned-fundamental.h"
2024-03-04 12:29:33 +01:00
Yegor Yefremov be872e193e build: specify run_command semantics
"check" argument will change its default value to "true" in the future
versions. Hence, set it explicitly to "false", to preserve current
semantics.

Fixes the following warning:

WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
2024-03-01 07:46:32 +00:00
Stanislas FAYE 11c59f8bcc test: disable vlan_xgress unit test
Disable the vlan_xgress unit test which was failing.
This test is currently being work and is going to be fixed soon.

(cherry picked from commit 6e30e37ebe)
2024-02-26 14:43:24 +01:00
Beniamino Galvani 5978fb2b27 manager: make generic devices compatible with all link types
If a generic device is present and the name matches, it is compatible
with any link type.

For example, if a generic connection has a device-handler that creates
a dummy interface, the link is compatible with the NMDeviceGeneric.
2024-02-21 11:16:06 +01:00
Beniamino Galvani f2613be150 core: persist state of software generic devices across restarts
When a generic connection has a custom device-handler, it always
generates a NMDeviceGeneric, even when the link that gets created is
of a type natively supported by NM. On service restart, we need to
keep track that the device is generic or otherwise a different device
type will be instantiated.
2024-02-21 11:16:05 +01:00
Beniamino Galvani df6c35ec75 device: support creating generic devices via device-handler
If the device-handler of the generic connection is set, the connection
is virtual and the device is created by invoking the device-handler
via NetworkManager-dispatcher service.

With this change, a generic device now represents two different device
classes:

 - existing interfaces that are not natively supported or recognized
   by NetworkManager. Those devices have the `has_device_handler`
   property set to FALSE;

 - interfaces that are created by NM by invoking the device-handler;
   they have `has_device_handler` set to TRUE.
2024-02-21 11:16:05 +01:00
Beniamino Galvani d72f26b875 dispatcher: read device-handler's stdout into a dictionary
Device handlers need a way to pass data back to NetworkManager, such
as the ifindex and an error message. Allow them to return a dictionary
on standard output, where each line contains a "$key=$value" pair.
In the daemon, the dictionary is returned via the callback function.
2024-02-21 11:16:04 +01:00
Beniamino Galvani ee5845063d dispatcher: support device-handler actions
"device-add" and "device-delete" actions are called for
device-handlers of generic devices. They differ from other actions in
the following aspects:

 - only one script is invoked, the one with name specified by the
   device-handler property;
 - the script is searched in the "device" subdirectory;
 - since there is only one script executed, the result and error
   string from that script are returned by NM in the callback function.
2024-02-21 11:16:04 +01:00
Beniamino Galvani 8fd0d39444 core/dispatcher: prefer the Action2() method and fall back to Action()
Call the Action2() method first, and fall back to the old Action() if
the new one is not available. This allows full interoperability
between different versions of the dispatcher service and NM.
2024-02-21 11:16:04 +01:00
Beniamino Galvani abf0f03d25 dispatcher: add Action2() D-Bus method
Currently, the dispatcher service implements an Action() method to
dispatch events. In the next commits, we'll need to add new
parameters, which is not possible with the current signature.

Introduce a new Action2() method, similar to the existing one but with
the following changes:

 - it accepts an additional "options" input parameter of type a{sv};
 - for each script executed, it also returns a dictionary of type
   a{sv}.

The new parameters will allow to easily extend functionality in the
future without having to implement an Action3().
2024-02-21 11:16:03 +01:00
Beniamino Galvani 703efdfbbf dispatcher: refactor building the result
Introduce request_dbus_method_return() and call it whenever we need to
return a result. Don't collect the list of scripts in case the
parameters can't be parsed.
2024-02-21 11:16:03 +01:00
Beniamino Galvani 98b73e88e6 core/dispatcher: refactor nm_dispatcher_need_device()
Remove the "nm_" prefix that is usually reserved for non-static
functions. Also, use NM_IN_SET.
2024-02-21 11:16:03 +01:00
Beniamino Galvani fa6ce51a0b core/dispatcher: factorize code
Move common code from nm_dispatcher_call_device() and
nm_dispatcher_call_device_sync() to a new function; it will also be
used in the next commits by a new variant of the function.
2024-02-21 11:16:02 +01:00
Beniamino Galvani e686ab35b3 libnm: add generic.device-handler property
Add a new "generic.device-handler" property that specifies the name of
a dispatcher script to be invoked to add and delete the interface for
this connection.
2024-02-21 11:16:01 +01:00
Beniamino Galvani d7c311eb85 dispatcher: pass user setting properties in the environment
Properties in the "user" setting are a convenient way to associate any
kind of user-provided metadata to connections.

However, nmcli doesn't support the user setting at the moment and
adding this feature requires a significant effort. Without nmcli
support, dispatcher scripts can only access user properties by either
parsing connection files or by using D-Bus (with or without libnm and
GObject introspection). Since both these solutions are not very
convenient, provide an alternative way: pass the properties as
environment variables.
2024-02-21 11:15:24 +01:00
Beniamino Galvani 38acb7a57d core: move functions for env variable name encoding to libnm-glib-aux
They will be used by the dispatcher service.
2024-02-21 11:15:24 +01:00
Beniamino Galvani 7b769e9e49 dispatcher: remove trailing dot from error messages
The error messages are logged by the dispatcher and passed back to
NetworkManager which also logs them. NetworkManager log messages
usually don't end with a dot: remove it.
2024-02-21 11:15:24 +01:00
Beniamino Galvani 010c54dce9 macsec: support the offload property 2024-02-21 10:51:57 +01:00
Beniamino Galvani aa418275cf libnm,nmcli: add macsec.offload property
Introduce a new property to control the MACsec offload mode.
2024-02-21 10:51:57 +01:00
Íñigo Huguet 7346c5b556 sriov: allow reading empty eswitch paramaters via Devlink
Probably not all drivers and devices return all parameters. Set them to
"unknown" if they are missing and let the caller to decide what to do.

In our case, if the sriov setting has a value different to "preserve" it
will try to set it (and will probably fail). But if the missing
parameter is set to "preserve" in the sriov setting we can continue,
just ignoring it.
2024-02-20 16:01:32 +01:00
Íñigo Huguet 27eaf34fcf sriov: don't fail if sriov_totalvfs sysfs file is missing
If sriov_totalvfs file doesn't exist we don't need to consider it a
fatal failure. Try to create the required number of VFs as we were doing
before.

Note: at least netdevsim doesn't have sriov_totalvfs file, I don't know
if there are real drivers that neither has it.
2024-02-20 16:01:30 +01:00
Íñigo Huguet 4669f01eb0 sriov: set the devlink's eswitch inline-mode and encap-mode
Set these parameters according to the values set in the new properties
sriov.eswitch-inline-mode and sriov.eswitch-encap-mode.

The number of parameters related to SR-IOV was becoming too big.
Refactor to group them in a NMPlatformSriovParams struct and pass it
around.
2024-02-20 16:01:29 +01:00
Íñigo Huguet bf654ef39e devlink: get and set eswitch inline-mode and encap-mode
The setter function allow to set to "preserve" to modify only some of
them.
2024-02-20 16:01:28 +01:00
Íñigo Huguet 8a88386e3a sriov: add eswitch-inline-mode and eswitch-encap-mode properties
Those are related to the eswitch mode and can be configured together.
2024-02-20 16:01:27 +01:00
Íñigo Huguet 770340627b platform: destroy VFs before changing the eswitch mode
It is not safe to change the eswitch mode when there are VFs already
created: it often fails, or even worse, doesn't fail immediatelly but
there are later problems with the VFs.

What is supposed to be well tested in all drivers is to change the
eswitch mode with no VFs created, and then create the VFs, so let's set
num_vfs=0 before changing the eswitch mode.

As we want to change num_vfs asynchronously in a separate thread, we
need to do a multi-step process with callbacks each time that a step
finish (before it was just set num_vfs asynchronously and invoke the
callback when it's done).

This makes link_set_sriov_params_async to become even larger and more
complex than it already was. Refactor it to make it cleaner and easier
to follow, and hopefully less error prone, and implement that multi-step
process.
2024-02-20 16:01:26 +01:00
Íñigo Huguet 837549ea94 sriov: set the devlink's eswitch mode
Use the new property sriov.eswitch-mode to select between legacy SRIOV
and switchdev mode.
2024-02-20 16:01:25 +01:00