Commit graph

34212 commits

Author SHA1 Message Date
Íñigo Huguet
72b2485042 spec: Add missing epoch to some obsoleted versions
An rpm linter has complained with:
Missing epoch prefix on the version-release in 'Obsoletes: NetworkManager < 1.0.0' for NetworkManager-team
2023-10-25 10:20:03 +00:00
Íñigo Huguet
f084eaf58b merge: branch 'jv/fix-meson-doc-libnm'
Fix building libnm documentation with meson

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1717
2023-10-25 10:14:26 +00:00
Jan Vaclav
848a303d3d build: add missing source dirs to meson doc build
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1717
2023-10-25 10:13:53 +00:00
Jan Vaclav
df285fbaa9 libnm/docs: fix building libnm documentation with meson
Currently, the libnm documentation fails to build with meson due to meson replacing backslashes with slashes.
This commit introduces a workaround -- replacing the `ignore_decorators` RegEx with an equivalent one that does not use backslashes.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1717
2023-10-25 10:13:53 +00:00
Íñigo Huguet
56b1a2c06a merge: branch 'ishitatsuyuki-main-patch-08142'
connectivity: Make curl timeout callback non-repeating.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1756
2023-10-25 10:10:06 +00:00
Tatsuyuki Ishi
abc6e1cf25 connectivity: Make curl timeout callback non-repeating.
This reverts commit 05c31da4d9.

In the linked commit the callback was made repeating on the assumption
that forward progress would result in the callback getting canceled in
cb_data_complete. However, this assumption does not hold since a timeout
callback does not guarantee completion (or error out) of a request.

curl tweaked some internals in v8.4.0 and started giving 0 timeouts, and
a repeating callback is firing back-to-back without making any progress
in doing so.

Revert the change and make the callback non-repeating again.

Fixes: 05c31da4d9 ('connectivity: don't cancel curl timerfunction from timeout')
2023-10-24 13:25:02 +02:00
Thomas Haller
8316eb0303
all: merge branch 'th/strv-contains'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1768
2023-10-23 10:10:55 +02:00
Thomas Haller
3cb10bdd1e
glib-aux/trivial: rename arguments in nm_strv_cleanup() function
"skip_repeated" sounds as if the function would only drop duplicate
elements that follow each other (in which case, the operation would be
O(n)). But it does search the entire array to prevent duplicates (resulting
in O(n^2)). Rename the argument "skip_repeated" to "no_duplicates"
to make that clearer.

Also, rename "skip_{empty,duplicates}" to "no_{empty,duplicates}". The
function removes those elements from the list, so "skip" is a bit
misleading too.
2023-10-23 10:09:12 +02:00
Thomas Haller
5cd0fdb2dd
all: use nm_strv_contains() instead of nm_strv_find_first() for membership check
nm_strv_find_first() is useful (and used) to find the first index (if
any). I can thus also used to check for membership.

However, we also have nm_strv_contains(), which seems better for
readability, when we check for membership. Use it.
2023-10-23 10:09:07 +02:00
Beniamino Galvani
e44909321c device: fix indentation
Fixes: 50a6386c3b ('device: disable IPv6 in NetworkManager when disabled in kernel')
2023-10-22 09:28:08 +02:00
Íñigo Huguet
ce31bc3ddc merge: branch 'main'
device: disable IPv6 in NetworkManager when disabled in kernel

Closes #1040

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1738
2023-10-20 06:25:31 +00:00
Yuki Inoguchi
50a6386c3b device: disable IPv6 in NetworkManager when disabled in kernel
When IPv6 is disabled in kernel but ipv6.method is set to auto, NetworkManager repeatedly attempts
IPv6 configuration internally, resulting in unnecessary warning messages being output infinitely.

  platform-linux: do-add-ip6-address[2: fe80::5054:ff:fe7c:4293]: failure 95 (Operation not supported)
  ipv6ll[e898db403d9b5099,ifindex=2]: changed: no IPv6 link local address to retry after Duplicate Address Detection failures (back off)
  platform-linux: do-add-ip6-address[2: fe80::5054:ff:fe7c:4293]: failure 95 (Operation not supported)
  ipv6ll[e898db403d9b5099,ifindex=2]: changed: no IPv6 link local address to retry after Duplicate Address Detection failures (back off)
  platform-linux: do-add-ip6-address[2: fe80::5054:ff:fe7c:4293]: failure 95 (Operation not supported)
  ipv6ll[e898db403d9b5099,ifindex=2]: changed: no IPv6 link local address to retry after Duplicate Address Detection failures (back off)

To prevent this issue, let's disable IPv6 in NetworkManager when it is disabled in the kernel.

In order to do it in activate_stage3_ip_config() only once during activation,
the firewall initialization needed to be moved earlier. Otherwise, the IPv6 disablement could occur
twice during activation because activate_stage3_ip_config() is also executed from subsequent of fw_change_zone().
2023-10-20 06:24:11 +00:00
Thomas Haller
c670ed4c69
core/trivial: fix typo in code comment 2023-10-19 16:31:31 +02:00
Thomas Haller
de5ba4c605
glib-aux: use nm_streq() in _nm_strv_find_first() instead of strcmp()
nm_streq() is better for readability. Prefer it over strcmp(). Note that
nm_streq() will be inlined, so it should make no difference performance
wise.

While at it, drop wrong comment.
2023-10-18 16:02:42 +02:00
Íñigo Huguet
94ead251de release: bump version to 1.45.5 (development) 2023-10-18 11:06:37 +02:00
Íñigo Huguet
2d956f4d51 merge: branch 'bg/ethtool-channels'
Add ethtool channels support

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1754
2023-10-18 06:54:00 +00:00
Beniamino Galvani
6c41cb3a58 device: support ethtool channels properties
Apply the new ethtool channels properties when activating a device,
and reset them on disconnect.
2023-10-18 06:53:07 +00:00
Beniamino Galvani
c3e538e1cd platform: support ethtool channels properties
Support setting the ethtool channels properties in platform via
ETHTOOL_GCHANNELS and ETHTOOL_SCHANNELS ioctls.
2023-10-18 06:53:07 +00:00
Beniamino Galvani
80dd179ffd libnm: add ethtool channels properties
ethtool "channels" parameters can be used to configure multiple queues
for a NIC, which helps to improve performances. Until now, users had
to use dispatcher scripts to change those parameters. Introduce native
support in NetworkManager by adding the following properties:

 - ethtool.channels-rx
 - ethtool.channels-tx
 - ethtool.channels-other
 - ethtool.channels-combined
2023-10-18 06:53:07 +00:00
Beniamino Galvani
48eaee471f device: remove duplicated checks when resetting ethtool settings
`_ethtool_*_reset()` functions already check that the state is not
NULL, no need to check it before. The only exception was for "feature"
settings, where the check was missing.
2023-10-18 06:53:07 +00:00
Beniamino Galvani
55d31ab11d ethtool: fail build on missing handling of ethtool types
Convert the open-coded conditions to a switch/case so that the
compilation will fail if a new ethtool type is added and is not
handled in various places.
2023-10-18 06:53:07 +00:00
Íñigo Huguet
123ca26770 nmcli: don't warn version mismatch with daemon not running
Fixes: fb851f3294 ('nmcli: warn if daemon version mismatch')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1750
2023-10-18 08:13:22 +02:00
Íñigo Huguet
81fdd4da3a gitignore: ignore nm-settings-docs-gir-*.xml
The old src/libnm-client-impl/nm-settings-docs-gir.xml has been splitted
into different files specific for nmcli, keyfile, ifcfg-rh and dbus.
Ignore these files that are autogenerated.

We don't expect to add more variants, but better to use a wilcard to
cover this possibility. Also for the nm-property-infos-*.xml files.

Fixes: f4fbc59a16 ('man nm-setting-*: proper format for gtkdoc constants')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1748
2023-10-18 08:04:44 +02:00
Íñigo Huguet
ef6ccc0ee8 dhcp: allow to not send client-id (option 61) in IPv4
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1742
2023-10-18 08:02:34 +02:00
Íñigo Huguet
c794363ce9 dhcp: document the new ipv4.dhcp-client-id special value "none"
Also, improve the explanation about what happens when no default value
is set, and the client-id value is left dependant on the plugin.
2023-10-18 08:01:09 +02:00
Íñigo Huguet
8639a3e5f7 dhcp (dhclient): honor ipv4.dhcp-client-id=none
If the client-id has been set to "none", the DHCP client-id option
(option 61) mustn't be sent. Honor this when the dhclient plugin is
used.

If dhclient has been called with the -i option (Use  a DUID with DHCPv4
clients), it will send a Client-ID even without setting one in dhclient.conf.
In this case, this option needs to be explicitly overwritten with:
  send dhcp-client-identifier = "";

At least in RHEL 8, dhclient is launched with `-i` turned on by default.
2023-10-18 08:01:09 +02:00
Íñigo Huguet
12f694902d dhcp (dhclient): refactor config file generation
The function merge_dhclient_config was called only once from
create_dhclient_config. The content of both of them is short and simple,
so moving the content from merge_dhclient_config to the caller
improves the readability and makes the functions call chain easier to
follow. Also, both functions takes a long list of arguments which are
almost the same, so we can avoid having to pass them over and over in a
long call chain.
2023-10-18 08:01:09 +02:00
Íñigo Huguet
583e5c4fc0 dhcp (internal): honor ipv4.dhcp-client-id=none
If the client-id has been set to "none", the DHCP client-id option
(option 61) mustn't be sent. Honor this in the internal DHCP client.
2023-10-18 08:01:09 +02:00
Íñigo Huguet
320e386b09 n-dhcp4: allow not to send the client-identifier
Sending the client-identifier (DHCP Option 61) is not mandatory,
although it's recommended, and there are some weird cases where
clients need not to send it.

Allow not to send it by leaving client_id unset.
2023-10-18 08:01:09 +02:00
Íñigo Huguet
f78a18bf16 dhcp: allow to not send client-id (option 61) in IPv4
Sending a client-id is not mandatory according to RFC2131. It is
mandatory according to RFC4361 that superseedes it.

Some weird DHCP servers conforming RFC2131 can get confused and break
existing DHCP leases if they start receiving a client-id when it was not
being previously received. Users that were using other DHCP client like
dhclient, but want to use NetworkManager's internal DHCP client, can
suffer this problem.

Add "none" as accepted value in ipv4.dhcp-client-id to specify that
client-id must not be sent. Note that this is generally not recommended
unless it's explicitly needed for some reason like the explained above.

Client-id is mandatory in DHCPv6.

This commit allow to set the "none" value and properly parse it in the
NMDhcpClientConfig struct. Next commits will modify the different DHCP
plugins to honor it.
2023-10-18 08:01:08 +02:00
Beniamino Galvani
5b16c128bb l3cfg: fix pruning of ACD data (take 2)
If a commit is invoked without any change to the l3cd or to the ACD
data, in _l3cfg_update_combined_config() we skip calling
_l3_acd_data_add_all(), which should clear the dirty flag from ACDs.
Therefore, in case of such no-op commits the ACDs still marked as
dirty - but valid - are removed via:

 _l3_commit()
   _l3_acd_data_process_changes()
     _l3_acd_data_prune()
       _l3_acd_data_prune_one()

Invoking a l3cfg commit without any actual changes is allowed, see the
explanation in commit e773559d9d ('device: schedule an idle commit
when setting device's sys-iface-state').

The bug is visible by running test 'bond_addreses_restart_persistence'
with IPv4 ACD/DAD is enabled by default: after restart IPv6 completes
immediately, the devices becomes ACTIVATED, the sys-iface-state
transitions from ASSUME to MANAGED, a commit is done, and it
incorrectly prunes the ACD data. The result is that the IPv4 address
is never added again.

Fix this by doing the pruning only when we update the dirty flags.

This is a respin of commit ed565f9146 ('l3cfg: fix pruning of ACD
data') that was reverted because it was causing a crash. The crash was
caused by unconditionally clearing `acd_data_pruning_needed` in
_l3cfg_update_combined_config(), while we need to do it only when
actually committing the configuration.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1749
2023-10-16 16:58:46 +02:00
Jan Vaclav
aa84b5f935 device: fix assertion failure caused by DAD array reuse
This commit fixes an assertion failure caused by the `conflicts` array being reused
when both IPv4 and IPv6 duplicate address detection occurs.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1747
Fixes: afa208c862 ('core: return conflicting addresses from nm_l3cfg_check_ready()')
2023-10-11 08:14:40 +00:00
Beniamino Galvani
8ed1b8daec merge: branch 'bridge-netlink'
platform: add netlink support for bridge port options

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1685
2023-10-09 12:27:00 +00:00
Javier Sánchez Parra
b38e8c053b platform: add netlink support for bridge port options
sysfs is deprecated and kernel will not add new bridge port options to
sysfs. Netlink is a stable API and therefore is the right method to
communicate with kernel in order to set the link options.
2023-10-09 12:25:45 +00:00
Beniamino Galvani
6fa4a45470 man: merge branch 'bg/man-license'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1744
2023-10-06 13:30:06 +02:00
Beniamino Galvani
abf41bc282 man: improve NM-dispatcher man page 2023-10-06 13:27:59 +02:00
Beniamino Galvani
7a07a0b92d man: replace license blurb with SPDX tag 2023-10-06 13:27:59 +02:00
Beniamino Galvani
6971d53901 docs,m4: remove paragraph about writing to FSF
The Free Software Foundation has changed addresses in the past, and
may do so again. NetworkManager already includes a copy of the
licenses.
2023-10-06 13:27:59 +02:00
Beniamino Galvani
b777cbf5a5 man: remove old version of nmtui man page
The man page is now generated from the docbook xml.

Fixes: 5216307b5a ('man: convert nmtui(1) manual to docbook refentry')
2023-10-06 13:27:59 +02:00
Beniamino Galvani
6a63d79fe6 Revert "l3cfg: fix pruning of ACD data"
The commit causes the following assertion failure:

  0  0x00007f4187e22884 in __pthread_kill_implementation () from target:/lib64/libc.so.6
  1  0x00007f4187dd1afe in raise () from target:/lib64/libc.so.6
  2  0x00007f4187dba87f in abort () from target:/lib64/libc.so.6
  3  0x00007f4188386f4e in g_assertion_message (domain=domain@entry=0x6fc1bc "nm", file=file@entry=0x722e94 "../src/core/nm-l3cfg.c", line=line@entry=2134,
     func=func@entry=0x727730 <__func__.49> "_l3_acd_data_add_all", message=message@entry=0x23b3bb0 "assertion failed: (acd_data->info.track_infos[i]._priv.acd_dirty_track)")
     at ../glib/gtestutils.c:3450
  4  0x00007f41883f1597 in g_assertion_message_expr (domain=domain@entry=0x6fc1bc "nm", file=file@entry=0x722e94 "../src/core/nm-l3cfg.c", line=line@entry=2134,
     func=func@entry=0x727730 <__func__.49> "_l3_acd_data_add_all", expr=expr@entry=0x726450 "acd_data->info.track_infos[i]._priv.acd_dirty_track") at ../glib/gtestutils.c:3476
  5  0x0000000000587209 in _l3_acd_data_add_all (self=self@entry=0x23a7020, infos=infos@entry=0x0, infos_len=infos_len@entry=0, reapply=reapply@entry=1)
     at ../src/core/nm-l3cfg.c:2134
  6  0x0000000000587702 in _l3cfg_update_combined_config (self=self@entry=0x23a7020, to_commit=to_commit@entry=1, reapply=reapply@entry=1, out_old=out_old@entry=0x7ffd09ea4ca8,
     out_changed_combined_l3cd=out_changed_combined_l3cd@entry=0x7ffd09ea4c7c) at ../src/core/nm-l3cfg.c:3858
  7  0x000000000058a202 in _l3_commit (self=0x23a7020, commit_type=commit_type@entry=NM_L3_CFG_COMMIT_TYPE_REAPPLY, is_idle=is_idle@entry=0) at ../src/core/nm-l3cfg.c:5046
  8  0x000000000058a49f in nm_l3cfg_commit (self=<optimized out>, commit_type=commit_type@entry=NM_L3_CFG_COMMIT_TYPE_REAPPLY) at ../src/core/nm-l3cfg.c:5115
  9  0x00000000004856cd in nm_device_l3cfg_commit (self=self@entry=0x23ab870, commit_type=commit_type@entry=NM_L3_CFG_COMMIT_TYPE_REAPPLY, commit_sync=commit_sync@entry=1)
     at ../src/core/devices/nm-device.c:4155
  10 0x00000000004b1814 in nm_device_cleanup (self=self@entry=0x23ab870, reason=reason@entry=NM_DEVICE_STATE_REASON_NEW_ACTIVATION,
     cleanup_type=cleanup_type@entry=CLEANUP_TYPE_DECONFIGURE) at ../src/core/devices/nm-device.c:15884
  11 0x00000000004b26c9 in _set_state_full (self=self@entry=0x23ab870, state=state@entry=NM_DEVICE_STATE_DISCONNECTED, reason=NM_DEVICE_STATE_REASON_NEW_ACTIVATION,
     quitting=quitting@entry=0) at ../src/core/devices/nm-device.c:16291
  12 0x00000000004b2fe4 in nm_device_state_changed (self=self@entry=0x23ab870, state=state@entry=NM_DEVICE_STATE_DISCONNECTED, reason=<optimized out>)
     at ../src/core/devices/nm-device.c:16505
  13 0x00000000004b69de in queued_state_set (user_data=user_data@entry=0x23ab870) at ../src/core/devices/nm-device.c:16532
  14 0x00007f41883bf4fd in g_idle_dispatch (source=0x23a88e0, callback=0x4b6956 <queued_state_set>, user_data=0x23ab870) at ../glib/gmain.c:6163
  15 0x00007f41883c34fc in g_main_dispatch (context=0x22c4d10) at ../glib/gmain.c:3460
  16 g_main_context_dispatch (context=0x22c4d10) at ../glib/gmain.c:4200
  17 0x00007f41884216b8 in g_main_context_iterate.isra.0 (context=0x22c4d10, block=1, dispatch=1, self=<optimized out>) at ../glib/gmain.c:4276
  18 0x00007f41883c2aff in g_main_loop_run (loop=0x22c3b50) at ../glib/gmain.c:4479
  19 0x0000000000423a37 in main (argc=<optimized out>, argv=<optimized out>) at ../src/core/main.c:519

This reverts commit ed565f9146.
2023-10-05 21:26:31 +02:00
Beniamino Galvani
11c9ce12f4 merge: branch 'bg/ipv4-dad-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1734
2023-10-05 09:26:15 +02:00
Beniamino Galvani
a45024714f core: don't fail if at least one static address passes DAD
It seems more useful to have a best effort approach and configure
everything we can; in that way we achieve at least some connectivity,
and then sysadmin can check the logs in case something is
missing. Currently instead, the whole activation fails (so, no address
is configured) if just one of the addresses fails DAD.

Ideally, we should have a way to make this configurable; but for now,
implement the more useful behavior as default.
2023-10-05 09:05:21 +02:00
Beniamino Galvani
536805231a libnm: better document IPv4 DAD property
Clarify that the value is the *maximum* interval; the actual value is
randomized and can be as low as half the specified one.
2023-10-05 09:05:16 +02:00
Beniamino Galvani
6ebf2c6ba1 l3cfg: log the reason when marking IP configuration dirty 2023-10-05 09:05:13 +02:00
Beniamino Galvani
e83e8b73f4 l3cfg: improve logging
- avoid "update" as it is also a commit type
 - make clear that the commit is not happening now
2023-10-05 09:05:07 +02:00
Beniamino Galvani
1f73034719 device: check DAD result for manual method even without carrier
IPv4 and IPv6 DAD work slightly differently: for IPv4 the presence or
absence of carrier doesn't have any effect on the duration of the
probe; for IPv6, DAD never completes without carrier because kernel
never removes the tentative flag.

In both cases, we shouldn't ignore the DAD result because that would
mean that we complete the ipmanual method without addresses actually
configured.
2023-10-05 09:04:59 +02:00
Beniamino Galvani
a49913504d dhcp: don't schedule commit of type "update" when clearing acd
We don't know the reason why the DHCP client is being stopped. It is
wrong to schedule a commit of type "update" because the device could
be now unmanaged. Schedule instead a commit of type "auto", which
automatically determines the type of commit based on registered
handles.
2023-10-05 09:04:46 +02:00
Beniamino Galvani
ed565f9146 l3cfg: fix pruning of ACD data
If a commit is invoked without any change to the l3cd or to the ACD
data, in _l3cfg_update_combined_config() we skip calling
_l3_acd_data_add_all(), which should clear the dirty flag from ACDs.
Therefore, in case of such no-op commits the ACDs still marked as
dirty - but valid - are removed via:

 _l3_commit()
   _l3_acd_data_process_changes()
     _l3_acd_data_prune()
       _l3_acd_data_prune_one()

Invoking a l3cfg commit without any actual changes is allowed, see the
explanation in commit e773559d9d ('device: schedule an idle commit
when setting device's sys-iface-state').

The bug is visible by running test 'bond_addreses_restart_persistence'
with IPv4 ACD/DAD is enabled by default: after restart IPv6 completes
immediately, the devices becomes ACTIVATED, the sys-iface-state
transitions from ASSUME to MANAGED, a commit is done, and it
incorrectly prunes the ACD data. The result is that the IPv4 address
is never added again.

Fix this by doing the pruning only when we update the dirty flags.
2023-10-05 09:04:32 +02:00
Beniamino Galvani
7548ff57d3 l3cfg: skip ACD for interfaces with IFF_NOARP
Interfaces with IFF_NOARP don't support Address Conflict Detection,
which is based on ARP. Trying to start ACD on them would result in
ENOBUFS always being returned by send(), and n-acd handles such error
by retrying indefinitely.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2023-10-05 09:04:09 +02:00
Beniamino Galvani
687051368f l3cfg: schedule a commit when ACD is not supported
On interfaces not supporting ACD (for example, layer3 interfaces), the
probe fails to be created with message:

 l3cfg[...,ifindex=2]: acd[172.25.17.1, init]: probe-good (interface does not support acd, initial post-commit)
 l3cfg[...,ifindex=2]: acd[172.25.17.1, ready]: set state to ready (probe is ready, waiting for address to be configured)

During the post-commit event, if the address is not yet configured, we
need to schedule a new commit to actually add it.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2023-10-05 09:03:40 +02:00