Commit graph

32503 commits

Author SHA1 Message Date
Beniamino Galvani
1935d351ac l3cfg: commit routes that previously failed
If a route is not in platform, doesn't have force-commit and the
commit type is not "reapply", we still need to apply it if it failed
previously. Otherwise, e.g. a route with a src address that is
temporarily not available is never applied again after the first
failure.
2023-07-26 10:19:09 +02:00
Beniamino Galvani
92fb17f99e ipv6ll: set force-once flag when adding the IPv6 link-local address
After the previous commit, this is needed for
53ba9f4701 ('ipv6ll: don't regenerate
the address when it's removed externally') to work properly.
2023-07-25 19:30:16 +02:00
Beniamino Galvani
0df304b790 Revert "platform: always reconfigure IP routes even if removed externally"
The change in behavior introduced by the patch departs from the policy
that NM had for long time of trying not to interfere with user
modifications. This seems a fundamental aspect of how NM works and
indeed we got already one report:

https://bugzilla.redhat.com/show_bug.cgi?id=2218866

of a user that was affected by the change. The specific case is about
routes from DHCP, but also static routes are affected. When a user
removes the route added by NM, NM now can add it back at any time.

Changing behavior is bad, it causes pain for users and for people who
need to support them. However, if the new behavior provides clear
advantages to users, that might be ok. This doesn't seem the case in
my opinion. Commit 7ca95cee describes a couple of scenarios:

> - kernel can automatically remove routes. For example, deleting an
>   IPv4 address that is the prefsrc of a route, will cause kernel to
>   delete that route. Sure, we may be unable to re-configure the
>   route at this moment, but we shouldn't remember indefinitely that
>   the route is supposed to be absent. Rather, we should re-add it
>   when possible

> - kernel is a pain with validating consistencies of routes. For
>   example, when a route has a nexthop gateway, then the gateway must
>   be onlink (directly reachable), or kernel refuses to add it with
>   "Nexthop has invalid gateway". Of course, when removing the onlink
>   route kernel is fine leaving the gateway route behind, which it
>   would otherwise refuse to add.
>   Anyway. Such interdependencies for when kernel rejects adding a
>   route with "Nexthop has invalid gateway" are non-trivial. We try
>   to work around that by always adding the necessary onlink
>   routes. See nm_l3_config_data_add_dependent_onlink_routes(). But
>   if the user externally removed the dependent onlink route, and
>   NetworkManager remembers to not re-adding it, then the efforts
>   from nm_l3_config_data_add_dependent_onlink_routes() are
>   ignored. This causes ripple effects and NetworkManager will also
>   be unable to add the nexthop route.

Kernel usually removes addresses as consequence of user actions. If
not (e.g. DHCP lease expiring) we have solutions in place for that to
re-add the route.

If the route removal is the consequence of a user action, then the
user must do something to undo it. For example, if the user removes an
address on the same interface, a route using the address as prefsrc
will be deleted. If the user wants it back, it must be re-added
manually together with the address; I don't see any problem with this.

The prefsrc address could be on another interface; in such case by
simply deactivating the connection providing the address, a dependent
route could be removed on another interface and never readded. This
doesn't look as a setup that anybody would use; in case we need to
support it, it is better to find alternative solutions.

So, my opinion is that the change in behavior potentially breaks many
users and doesn't bring clear advantages. Therefore, restore the old
behavior.

This reverts commit 7ca95cee15.

Revert conflicts:

- the following code was removed from _obj_states_sync_filter() in
  nm-l3cfg.c because the mechanism to set temporarily-unavailable
  routes was changed in 1feaf427d2
  ('platform: rework handling of failed routes during
  nm_platform_ip_route_sync()'), and so
  `os_temporary_not_available_timestamp_msec` no longer exists:

    if (obj_state->os_temporary_not_available_timestamp_msec > 0) {
        /* we currently try to configure this address (but failed earlier).
         * Definitely retry. */
        return TRUE;
    }
2023-07-25 19:30:15 +02:00
Beniamino Galvani
bdd87cd5f4 Revert "platform,l3cfg: remove force-commit flag for addresses/routes"
The next commit will revert 7ca95cee15 ('platform: always
reconfigure IP routes even if removed externally'), so that we don't
re-add routes removed externally. After that, we still need the
force-commit flag to indicate which routes must be forcibly added even
if removed externally.

This reverts commit 7fa63c23b4.
2023-07-25 19:30:15 +02:00
Beniamino Galvani
4f571dd88d l3cfg: remove tna_dirty member
The member is no longer used.

Fixes: 1feaf427d2 ('platform: rework handling of failed routes during nm_platform_ip_route_sync()')
2023-07-25 19:30:15 +02:00
Beniamino Galvani
8d37e94616 l3cfg: fix typo in variable name
Replace "mesc" with "msec".

Fixes: 1feaf427d2 ('platform: rework handling of failed routes during nm_platform_ip_route_sync()')
2023-07-25 19:30:15 +02:00
Beniamino Galvani
6e8a867591 l3cfg: fix log message
nm_utils_addr_family_to_char() requires a valid address family.

Fixes: 1feaf427d2 ('platform: rework handling of failed routes during nm_platform_ip_route_sync()')
2023-07-25 19:30:15 +02:00
Fernando Fernandez Mancera
9f01cff04f settings: merge branch 'bg/ifcfg-migrate-option'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1700
2023-07-25 15:40:02 +02:00
Beniamino Galvani
b2ada6d4fa settings: implement ifcfg-rh migration option
Implement the migration of ifcfg-rh profiles when the
"main.migrate-ifcfg-rh" option is enabled.
2023-07-25 15:39:06 +02:00
Beniamino Galvani
5e75f0c197 settings: move warning about ifcfg-rh
Move the warning about the presence of ifcfg-rh profiles from the
plugin to NMSettings. In this way, it will be easier to implement the
migration option in the next commit.
2023-07-25 15:39:06 +02:00
Beniamino Galvani
52cca91dd2 build,core: add a "main.migrate-ifcfg-rh" configuration option
The option enables automatic migration of ifcfg-rh connection profiles
to keyfile. The default value can be configured at build time.
2023-07-25 15:39:06 +02:00
Fernando Fernandez Mancera
aaaf727b97 nmtui: merge branch 'jv/nmtui-inclusive'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1698
2023-07-25 14:23:53 +02:00
Jan Vaclav
bf4d0eba6e nmtui: replace occurrences of master/slave with controller/port in internal code
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1335
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1698
2023-07-25 14:22:25 +02:00
Fernando Fernandez Mancera
4f84ed9c10 nmcli: merge branch 'jv/nmcli-inclusive'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1697
2023-07-25 14:19:35 +02:00
Jan Vaclav
16f3e64307 nmcli: replace occurrences of master/slave with controller/port in internal code
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1334
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1697
2023-07-25 14:18:22 +02:00
Wen Liang
e8a2306afb assume: change IPv6 method from "ignore" and "disabled" into "auto"
IPv6 method "disabled" and "ignore" are not supported for loopback
device, when generating the assume connection, the generated connection
will fail verification. Therefore, change the IPv6 method into "auto",
as a result, for loopback external connection, NM will not toggle the
`disable_ipv6` sysctl setting when `systemd-sysctl` sets it into 1.

https://bugzilla.redhat.com/show_bug.cgi?id=2207878

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1694
2023-07-24 22:09:43 -04:00
Jan Vaclav
c779c22fcb initrd: unset dhcp options for static profiles
Makes it so that DHCP properties (`dhcp-timeout`, `dhcp-hostname`) are unset when they are deemed unnecessary.
Unit tests have also been updated to account for this change.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1276
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1695
2023-07-24 11:17:27 +02:00
NorwayFun
13d4d4c35c Update file ka.po
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1687
2023-07-19 14:34:50 +02:00
Fernando Fernandez Mancera
fb362e0583 manager: allow controller activation if device is deactivating
When activating a port connection it will require the controller
connection is active or a valid controller device candidate is available
for activation.

One of the conditions we consider for a controller device to be a valid
candidate for the connection is that it is not active, therefore we
should also consider as valid a device that is currently deactivating.
Otherwise, we could fail during the port activation just because the
deactivation of the controller device candidate didn't finish yet.

https://bugzilla.redhat.com/show_bug.cgi?id=2125615

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1693
2023-07-19 12:09:09 +02:00
Fernando Fernandez Mancera
d441f846b2 glib-aux: merge branch 'th/fix-ifname-valid-kernel'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1692
2023-07-19 11:55:08 +02:00
Thomas Haller
ab69d430a7 glib-aux: fix rejecting '\v' and NBSP in nm_utils_ifname_valid_kernel()
Kernel's dev_valid_name() calls isspace(), which also rejects '\v'
and '\240'.

As this tightens the check, the change can break code that partly worked
before. It surely didn't work to the point, where an interface with such
name could be created in kernel.

  # ip link add name $'foo\240bar' type dummy
  RTNETLINK answers: Invalid argument
2023-07-19 11:50:04 +02:00
Thomas Haller
cffca6f995 glib-aux: add NM_ASCII_SPACES_KERNEL helper 2023-07-19 11:50:04 +02:00
Fernando Fernandez Mancera
5e67644f96 nmcli: merge branch 'ihuguet_ask_offline'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1688
2023-07-17 13:13:17 +02:00
Íñigo Huguet
d414265ab1 nmcli: fix endless loop with --offline --ask
If --offline and --ask were used at the same time, and endless loop
showing the readline's prompt but without waiting for user's input
happened.

This was because when using --offline, all arguments are parsed and
resolved before running the g_main_loop. In nmc_readline_helper it was
checked that the main loop is running, so if g_main_loop_quit is called
we can stop waiting for user's input.

Fix this bug by continue polling for user input if the main loop is
running or if we are in offline mode.  Cancelling the user input is
still possible both in normal and offline mode with Ctrl+C or Ctrl+D.

Added a test case to verify that this still works after future changes.
2023-07-17 12:58:07 +02:00
Íñigo Huguet
5490604084 nmcli: move offline flag from NmCli to NmcConfig struct
This flag is a setting that changes the behaviour of nmcli, it's not
only the current state of the program, so it makes more sense to put it
in NmcConfig than in NmCli.

Furthermore, it's needed to fix a bug in next commit, too.
2023-07-17 12:56:03 +02:00
Thomas Haller
514e944da3
contrib: add "cloud-init", "firewalld", "nftables" to makerepo.sh script 2023-07-14 09:40:26 +02:00
Beniamino Galvani
a81de2fc8b release: bump version to 1.43.11 (development) 2023-07-12 16:56:31 +02:00
Beniamino Galvani
2d261ec768 merge: branch 'fix_ovs'
device: do not set MAC address on iface with index <=0

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1691
2023-07-12 14:43:25 +00:00
Gris Ge
215bc15255 device: do not set MAC address on iface with index <=0
The `nm_device_hw_addr_reset()` should only set MAC address on NIC
with valid(>0) interface index.

The failure was found by `ovs_mtu` test of NMCI, failed to reproduce
the original problem (`ovs_mtu` test of NMCI) with 100 times retry.
And no trace log found for original test failure, hence cannot tell why
`nm_device_hw_addr_reset()` been invoked with iface index 0.

Signed-off-by: Gris Ge <fge@redhat.com>
2023-07-12 22:16:04 +08:00
Thomas Haller
efa63aef3a device: delete software device when software devices lose carrier
We delete devices when the connection goes down and NetworkManager
created the device earlier.

Software devices like bond/bridge/team default to ignoring carrier.
However, when configuring them to not ignore carrier
([device].ignore-carrier), they were not deleted when deactivating the
devices.

This adjusts commit d0c2a24b71 ('device: do not remove software devices
on initial disconnected (rh #1035814)'). Note that back then there was
no check whether the device has an activation queued, so it behaved
differently then.

When the software device enters the UNAVAILABLE state from UNMANAGED,
during cleanup we shouldn't delete the link.

Co-Authored-By: Beniamino Galvani <bgalvani@redhat.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1686
2023-07-12 15:30:05 +02:00
Jan Vaclav
9a5c7c7228 build: make modprobe path configurable
Extracts the hardcoded modprobe path used in `src/libnm-platform/nm-platform-utils.c` to the configurable MODPROBE_PATH macro
Merge request: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1689
Closes: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1257
2023-07-11 17:06:19 +02:00
Fernando Fernandez Mancera
5b8fdd25ab utils: extend connection matching function for UUID in controller
When matching two connections one might be using UUID and the other one
could be using interface-name for the controller property. When
recovering from a fresh start NM does not have any context and when
generating a connection we are using UUID as the controller.

It is always hard to guess what is the right candidate to pick but at
least something NM can do is checking if the UUID matches a connection
with the same controller interface-name. If there are no other
conflicts, then we can assume that is a good canditate to activate.

This is a follow up to `dc254f90e2b306700a0b81f7194e9b0438c62f4c`.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1684
2023-07-11 17:01:41 +02:00
Gris Ge
5565aebf30 merge: branch 'br_fix_po'
po: fix wrong translation in simplified Chinese

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1590
2023-07-03 09:32:22 +00:00
chengyechun
11219b483a po: fix wrong translation in simplified Chinese 2023-07-03 09:16:44 +00:00
Thomas Haller
ccb16013e0
gitlab-ci: fix detection and handling of Ubuntu 18.04
Fixes: d563b4e009 ('gitlab-ci: fix setup of debian:9 container')
2023-06-30 18:51:13 +02:00
Thomas Haller
6985c011c7
nm-in-container: add NetworkManager.service override 2023-06-30 15:44:05 +02:00
Thomas Haller
ad4e068bfd
cloud-setup/man: add DEBUGGING section to man nm-cloud-setup 2023-06-29 17:41:13 +02:00
Beniamino Galvani
646e041523 dns: fix tracking of best ip config
When a IP configuration has type "best", it is the configuration with
the best (lowest) metric default route for the specific address
family. Therefore, there can be only one best configuration for
address family.

When a new configuration is added as best, make sure it is the only
one for the address family.

This reverts commit 0abc14b3a0.

Fixes: 0abc14b3a0 ('core: remove unused best_ip_config_[46] field in NMDnsManager')

https://lists.freedesktop.org/archives/networkmanager/2023-June/000123.html
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1331
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1683
2023-06-29 15:12:51 +02:00
Thomas Haller
c961ec1f99
keyfile: merge branch 'th/keyfile-rename'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1661
2023-06-29 14:10:12 +02:00
Thomas Haller
e9426e6d07
keyfile: add a NetworkManager.conf option "keyfile.rename"
The default behavior is not to rename profiles. I guess, that makes
sense, as renaming a file when changing the "connection.id" could break
users who rely on the name.

My use case is the following. When I connect a Wi-Fi hotspot I use
`nmcli device wifi connect $SSID`, which -- as expected -- persists the
profile to "/etc/NetworkManager/system-connections/$SSID.nmconnection".
Later, I always update the profile's name to "w_$SSID" so I can see on
the name that this is wireless profile. I also want the filename to
reflect that change of name.

Add a configuration option for that. All the infrastructure
("force_rename" parameter) already exists.
2023-06-29 14:05:27 +02:00
Thomas Haller
c1f2616618
keyfile: add option to nms_keyfile_writer_connection() to follow the preferred name
There was already a force_rename argument to nms_keyfile_writer_connection(), which
-- if TRUE -- means to always rename the file, if it exists.

What we also want, is to follow the change of a connection.id. So we don't want
to force a rename, if we already use the preferred name, but we also want to rename
otherwise.

Extend the boolean "force_rename" argument to a NMTernary, where NM_TERNARY_DEFAULT
now means to follow the preferred name.
2023-06-29 14:05:27 +02:00
Thomas Haller
cfe2cede12
core/settings: fix "force_rename" for writing connection to disk
"force_rename" parameter was not used previously, but it also was broken.
Fix it. We need to create a new NMSettingsStorage instance when the filename
changes, as the storage's filename is immutable.
2023-06-29 14:05:27 +02:00
Thomas Haller
3d2622c358
settings: fix passing force_rename flag to _update_connection_to_plugin()
No bad effects so far, it was unused.

But as it wasn't used, also no longer set the update_reason flag
NM_SETTINGS_CONNECTION_UPDATE_REASON_FORCE_RENAME. We didn't have the
force-rename behavior so far. This makes the flag totally unused, and
maybe should be dropped. It's kept for now, if only to show what could
be done.
2023-06-29 14:05:27 +02:00
Thomas Haller
e5a6e16ce0
keyfile/tests: rename internal test-only function to have nmtst prefix
We have some interal code that is only used to expose functionality for
the tests. Those functions should be easily distinguishable from code
that is used by the "real" code. Give a "nmtst" prefix. Rename
nms_keyfile_writer_test_connection() to nmtst_keyfile_writer_test_connection().
2023-06-29 14:05:27 +02:00
Gris Ge
c6b5dc2552 merge: branch 'sriov_opt'
sriov: do not fail activation on SR-IOV VF failures

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1682
2023-06-29 10:07:14 +00:00
Gris Ge
02b892149a sriov: do not fail activation on SR-IOV VF failures
When user are changing SR-IOV VF settings for options like `max-tx-rate`
which some hardware not supported yet, the failure of this VF will fail
the whole activation, then the SR-IOV will be disabled means all the VFs
will be deleted.

Deleting VFs might break network connectivity and this collateral
damage of VF option failure is not acceptable for OpenShift use cases
even they have checkpoint protection.

This patch only log warn message on failure of VF options and will not
fail the activation.

NetworkManager also ignore MTU failure during activation, I believe this
fit into the same assumption.

User case reference: https://bugzilla.redhat.com/show_bug.cgi?id=2210164

Signed-off-by: Gris Ge <fge@redhat.com>
2023-06-29 17:59:53 +08:00
Beniamino Galvani
7e2f2174ab merge: branch 'bg/link-setting-ifcfg'
Deprecate the ifcfg-rh setting plugin

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1570
2023-06-29 10:24:45 +02:00
Beniamino Galvani
e96bb430e2 ifcfg-rh: fail to save connections with the 'link' setting
Fail to save a connection with a 'link' setting instead of just
ignoring it. Now:

  $ nmcli connection add type ethernet ifname foobar
  Connection 'ethernet-foobar' (c3f6f067-e1d5-4bb1-8d67-e09109253a79) successfully added.

  $ nmcli connection modify ethernet-foobar link.tx-queue-length 1234
  Error: Failed to modify connection 'ethernet-foobar': failed to update connection: The ifcfg-rh plugin doesn't support setting 'link'. If you are modifying an existing connection profile saved in ifcfg-rh format, please migrate the connection to keyfile using 'nmcli connection migrate c3f6f067-e1d5-4bb1-8d67-e09109253a79' or via the Update2() D-Bus API and try again.

  $ nmcli connection migrate c3f6f067-e1d5-4bb1-8d67-e09109253a79
  Connection 'ethernet-foobar' (c3f6f067-e1d5-4bb1-8d67-e09109253a79) successfully migrated.

  $ nmcli connection modify ethernet-foobar link.tx-queue-length 1234
  $

Fixes: 39bfcf7aab ('all: add "link" setting')
2023-06-29 10:18:09 +02:00
Beniamino Galvani
043c18bf0f ifcfg-rh: add helper to set unsupported error
The ifcfg-rh plugin is now deprecated and in bugfixes-only mode. When
users try to set a property that is not supported by the plugin, we
need to report an error.

Add an helper function to set such error. Also, introduce a new error
code so that the situation can be detected and dealt with
programmatically.
2023-06-29 10:18:07 +02:00
Beniamino Galvani
8645d34dd1 man: update list of settings not supported by ifcfg-rh 2023-06-29 10:15:48 +02:00