Commit graph

28769 commits

Author SHA1 Message Date
Thomas Haller
ef76937e67
core: always reset ethtool autoneg/speed to fix reactivation
The check whether the current setting are already as expected are wrong.

The reason is that nm_platform_ethtool_set_link_settings() also sets
the announced ethernet modes, but nm_platform_ethtool_get_link_settings()
does not give them.

That means, we cannot check whether the current link configuration is
the same, because the getter doesn't give that information.
Consequently, we must not skip the setting on the assumption that
there is nothing to change.

This bug has bad effects. If the device is currently activated with ethtool
option set, then re-activating the profile will result in wrongly
skipping the update.

(cherry picked from commit 78b3711522)
2021-09-07 08:44:12 +02:00
Thomas Haller
e2fe64a3d8
platform: also set advertised modes when disabling ethernet autoneg
Disabling autoneg is not supported for Gigabit ethernet. But it seems that
ixgbe also doesn't honor

  ethtool -s enp5s0f0 speed 100 duplex full autoneg off

As a workaround, when we disable autoneg then always set the advertised
modes too. I think (hope) that should not have a bad effect otherwise,
but seems most sensible for ixgbe.

(cherry picked from commit bd92df3e56)
2021-09-07 08:44:12 +02:00
Thomas Haller
6b7957f311
core: during reset of ethtool autoneg enable all modes
(cherry picked from commit d5f062cecd)
2021-09-07 08:44:11 +02:00
Thomas Haller
a6ef74a662
core: cleanup logging of set-link for speed/autoneg
There is no point in logging the current speed/duplex. OK, with
the "*", we could at least see whether the printed values are
to be set, or are currently configured on the interface.

But mixing these two outputs is confusing and meaningless.
Either log what we are about to do, or what the current configuration
is. Not a mix of both.

(cherry picked from commit ea2b965ac2)
2021-09-07 08:44:11 +02:00
Thomas Haller
10ae24098c
platform: add debug logging for setting link autoneg/speed
(cherry picked from commit 5c789c030a)
2021-09-07 08:44:11 +02:00
Thomas Haller
16e491f06a
platform: clear all BASE types when setting advertised modes for ethernet autoneg
Get the list of supported flags from ethtool utility ([1]).

When we enable auto-negotiation, the user may select only one mode to
be advertised. But then we need to clear all other modes, the previous
define BASET_ALL_MODES did not cover them all.

[1] https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/ethtool.c?id=7cca9692b9b0c4e2c7eb7868a7791f97202014b0#n397

(cherry picked from commit 34d48d2596)
2021-09-07 08:44:10 +02:00
Thomas Haller
5b0396efc0
platform: don't set lp_advertising in set_link_settings_new()
I don't understand why this was done. I don't think it's necessary nor
correct.

(cherry picked from commit 595099f27a)
2021-09-07 08:44:10 +02:00
Thomas Haller
475d759ae3
platform: simplify accessing ethtool_link_settings.link_mode_masks in set_link_settings_new()
(cherry picked from commit 94e23ebba5)
2021-09-07 08:44:10 +02:00
Thomas Haller
25bfa2f8a5
platform/build: fix linking "test-nm-platform" test
libnm-platform.la depends on libnm-udev-aux and libnm-base.
Only by accident this was working, because we happened to use
no symbol in the test that required any of these dependencies.

A small change to the test can (and will soon) change that. Fix the
build to link the right library.

(cherry picked from commit f992b2bc25)
2021-09-07 08:44:10 +02:00
Thomas Haller
f7d8d4f548
linux-headers: update nl802154.h kernel header
Taken from "include/net/nl802154.h", Linux 5.14,
7d2a07b769330c34b4deabeed939325c77a7ec2f, Aug 30, 2021.

(cherry picked from commit c3d0249859)
2021-09-07 08:44:08 +02:00
Thomas Haller
0a0fc204e1
linux-headers: add ethtool.h kernel header
Taken from Linux 5.14, 7d2a07b769330c34b4deabeed939325c77a7ec2f,
Aug 30, 2021.

(cherry picked from commit aadcd0935e)
2021-09-07 08:43:38 +02:00
Thomas Haller
ae97ab7d29
code-format: exclude "src/linux-headers" from "nm-code-format.sh" script
(cherry picked from commit 023c8ad88b)
2021-09-07 08:43:37 +02:00
Thomas Haller
2824f99673
initrd: fix crash parsing plain '=' without key
./src/nm-initrd-generator/nm-initrd-generator  -s -- =

Fixes: ecc074b2f8 ('initrd: add command line parser')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/776
(cherry picked from commit 01fd4b7d2c)
2021-08-30 09:18:35 +02:00
Thomas Haller
bd28e91947
initrd/tests: add _parse_no_con() macro
(cherry picked from commit 553721eed7)
2021-08-30 09:17:56 +02:00
Thomas Haller
279f9fff67
core: fix crash for duplicate seen-bssid
This happens if there are duplicate BSSIDs for a profile in
"/var/lib/NetworkManager/seen-bssid" file.

  #0  c_list_unlink_stale (what=0x555555bc8768) at ./src/c-list/src/c-list.h:160
  #1  _seen_bssid_entry_free (data=0x555555bc8750) at src/core/settings/nm-settings-connection.c:98
  #2  0x00007ffff77e834a in g_hash_table_insert_node
      (hash_table=hash_table@entry=0x555555afa9e0 = {...}, node_index=node_index@entry=6, key_hash=key_hash@entry=967604099, new_key=new_key@entry=0x555555bc8750, new_value=new_value@entry=0x555555bc8750, keep_new_key=keep_new_key@entry=0, reusing_key=0) at ../glib/ghash.c:1352
  #3  0x00007ffff77e88f0 in g_hash_table_insert_internal (keep_new_key=0, value=0x555555bc8750, key=0x555555bc8750, hash_table=0x555555afa9e0 = {...}) at ../glib/ghash.c:1600
  #4  g_hash_table_insert (hash_table=0x555555afa9e0 = {...}, key=key@entry=0x555555bc8750, value=value@entry=0x555555bc8750) at ../glib/ghash.c:1629
  #5  0x000055555586c5e1 in _nm_settings_connection_register_kf_dbs (self=self@entry=0x555555bbf5a0, kf_db_timestamps=<optimized out>, kf_db_seen_bssids=<optimized out>)
      at src/core/settings/nm-settings-connection.c:2382
  #6  0x00005555555b7e19 in _connection_changed_update
      (self=self@entry=0x555555b1d0c0, sett_conn_entry=sett_conn_entry@entry=0x555555b60390, connection=0x555555b953f0, sett_flags=sett_flags@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, sett_mask=sett_mask@entry=_NM_SETTINGS_CONNECTION_INT_FLAGS_PERSISTENT_MASK, update_reason=update_reason@entry=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET)) at src/core/settings/nm-settings.c:1080
  #7  0x00005555555b8b5a in _connection_changed_process_one
      (self=self@entry=0x555555b1d0c0, sett_conn_entry=0x555555b60390, allow_add_to_no_auto_default=allow_add_to_no_auto_default@entry=0, sett_flags=sett_flags@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, sett_mask=_NM_SETTINGS_CONNECTION_INT_FLAGS_PERSISTENT_MASK,
      sett_mask@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, override_sett_flags=override_sett_flags@entry=1, update_reason=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET)) at src/core/settings/nm-settings.c:1304
  #8  0x00005555555b8c5e in _connection_changed_process_all_dirty
      (self=self@entry=0x555555b1d0c0, allow_add_to_no_auto_default=allow_add_to_no_auto_default@entry=0, sett_flags=sett_flags@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, sett_mask=sett_mask@entry=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, override_sett_flags=override_sett_flags@entry=1, update_reason=update_reason@entry=(NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_RESET_AGENT_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET)) at src/core/settings/nm-settings.c:1325
  #9  0x00005555555b8d40 in _plugin_connections_reload (self=self@entry=0x555555b1d0c0) at src/core/settings/nm-settings.c:1448
  #10 0x00005555555bddb5 in nm_settings_start (self=0x555555b1d0c0, error=error@entry=0x7fffffffe278) at src/core/settings/nm-settings.c:3892
  #11 0x000055555560013d in nm_manager_start (self=self@entry=0x555555b19060, error=error@entry=0x7fffffffe278) at src/core/nm-manager.c:6961
  #12 0x0000555555594b27 in main (argc=<optimized out>, argv=<optimized out>) at src/core/main.c:496

Fixes: 8278719840 ('settings: limit number of seen-bssids and preserve order')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/787
(cherry picked from commit eafa88d438)
2021-08-30 08:25:46 +02:00
Thomas Haller
dd8bc31fdb
nmcli/docs: fix address order in ipv46.addresses documentation for man nm-settings-nmcli
For IPv4, the order is not like for IPv6. Of course not.

Fixes: 7aa4ad0fa2 ('nmcli/docs: better describe ipv[46].addresses in `man nm-settings-nmcli`')
(cherry picked from commit 2f3c2647d2)
2021-08-19 14:30:28 +02:00
Thomas Haller
605373b38a
platform: fix capturing addresses from platform for assuming after restart
Commit c631aa48f0 ('platform: capture NMIP[46]Config from platform
with correct (reversed) order of IP addresses') changed this for IPv6
and IPv4, but it's not correct for IPv4.

For IPv6, later `ip addr add` calls adds a new primary address, which
is also listed in `ip addr show` first. Hence, as NMIP6Config tracks
addresses in increasing priority, while NMPlatform tracks them as
exposed by kernel, the order when appending addresses form platform
to NMIP6Config must be reversed.

That is not the case for IPv4. For IPv4, later `ip addr add` calls
add a secondary IP address. Also, in `ip addr show` output they are
appended. Consequently, IPv4 addresses are tracked by NMPlatform with
decreasing priority (in the reverse order than for IPv6).

Fix constructing the NMIP4Config by fixing the address order. This is
important, because during restart devices get assumed and our code would
configure the order of addresses as it finds them.

Fixes: c631aa48f0 ('platform: capture NMIP[46]Config from platform with correct (reversed) order of IP addresses')
(cherry picked from commit c380893dc6)
2021-08-19 14:30:27 +02:00
Beniamino Galvani
bb0ebac9f2 release: bump version to 1.32.11 (development) 2021-08-18 09:42:37 +02:00
Beniamino Galvani
39302c7441 release: bump version to 1.32.10 2021-08-18 09:42:37 +02:00
Beniamino Galvani
91bbc0f002 NEWS: update 2021-08-18 08:22:55 +02:00
Thomas Haller
3f9958451f ifcfg/tests: fix evaluating environment variable to regenerate test files
Fixes: 1ae6719cf1 ('ifcfg-rh/tests: evalute environment for $NMTST_IFCFG_RH_UPDATE_EXPECTED only once')
(cherry picked from commit 02832b03ee)
2021-08-17 22:58:00 +02:00
Thomas Haller
722c7805e4 ifcfg: fix crash due to not setting error on failure to parse DNS
Fixes: c2ad294290 ('ifcfg-rh: fix error handing in some functions that expect error != NULL')
(cherry picked from commit 1abf512831)
2021-08-17 22:57:37 +02:00
Ana Cabral
08800329e7 nm-initrd-generator: Merge branch 'al/initrdgenerator-ethtool-docs'
- remove duplex option

- include man entry for rd.ethtool options

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

!960

(cherry picked from commit bdaf82ed19)
2021-08-17 15:21:58 -03:00
Ana Cabral
d84cb1c67b nm-initrd-generator: include man entry for rd.ethtool options
(cherry picked from commit 44a5bdabe9)
2021-08-17 15:21:58 -03:00
Ana Cabral
926b96a53c nm-initrd-generator: remove duplex option
(cherry picked from commit 750d35a6e3)
2021-08-17 15:21:58 -03:00
Thomas Haller
781142c67c
core: merge branch 'th/fix-addr-order-on-assume'
https://bugzilla.redhat.com/show_bug.cgi?id=1988751

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/963

(cherry picked from commit f76af50df3)
2021-08-17 19:58:51 +02:00
Thomas Haller
8e05b05135
nmcli/docs: better describe ipv[46].addresses in man nm-settings-nmcli
(cherry picked from commit 7aa4ad0fa2)
2021-08-17 19:58:51 +02:00
Thomas Haller
823b94290b
platform: capture NMIP[46]Config from platform with correct (reversed) order of IP addresses
Fix the order of IP addresses when assuming devices (service restart).

The order of IP addresses matters to kernel for selection of source IP
address.

If all other properties are equal ([1]), for IPv6, the address added *last*
will be preferred. That is the address you see *first*` in `ip -6 addr show`.
NMPlatform also preserves that order, so the address *first* is the most
important one.

On the other hand, in a connection profile, `ipv6.addresses` lists
addresses in increasing priority (the last address is the primary one).
That is for compatibility with initscripts, which iterates over the
list of addresses and calls `ip addr add` (meaning, the last address
will be added last and is thus preferred by kernel).

As the priority order in the profile is reversed, also the priority
order in NMIP[46]Config is reversed. Fix creating an NMIP[46]Config
instance from platform addresses to honor the priority.

This has real consequences. When restarting NetworkManager, the interface
stays up with the addresses configured in the right order. After
restart, the device gets assumed, which means that the NMIP[46]Config
instance from the connection is not yet set, only the config from the
platform gets synchronized. Previously the order was wrong, so during
restart the order of IP addresses was reverted.

[1] https://access.redhat.com/solutions/189153

https://bugzilla.redhat.com/show_bug.cgi?id=1988751
(cherry picked from commit c631aa48f0)
2021-08-17 19:58:50 +02:00
Thomas Haller
feaa4943a0
platform: add nmp_cache_iter_for_each_reverse() helper
(cherry picked from commit 9c99c948fd)
2021-08-17 19:58:50 +02:00
Thomas Haller
e60c52829c
glib-aux: clear iterator in nm_dedup_multi_iter_{next,prev}() at the end
It seems slightly nicer not to leave a dangling pointer at the
end of the iteration. Then you could do something like

    nm_dedup_multi_iter_init(&iter, head_entry);
    while (nm_dedup_multi_iter_next(&iter)) {

        if (some_condition())
            break;
    }
    if (!iter.current)
        printf("iterated to the end\n");

As nm_dedup_multi_iter_next() and nm_dedup_multi_iter_init() are inline
functions, the compiler should even be able to see that the initial
setting becomes unnecessary (the field will be initialized by the
first nm_dedup_multi_iter_next()). Likewise, the final clearing
of the field might also be optimized away at the end of the iteration
(if, as in the common case, the iterator is not accessed afterwards).

(cherry picked from commit 53070705b0)
2021-08-17 19:58:50 +02:00
Thomas Haller
1803370cb2
glib-aux: add nm_dedup_multi_iter_init_reverse() to iterate in reverse order
(cherry picked from commit 57a519cc03)
2021-08-17 19:58:50 +02:00
Thomas Haller
b1a7c71da7
udev: also react to "move" (and "change") udev actions in our rules
NetworkManager handles "add" and "move" actions the same way, by
tracking the "struct udev_device" instance.

Still, this means that also for move events, we need the right
attributes set.

See-also: https://github.com/openshift/sriov-network-operator/issues/414
(cherry picked from commit b57c1af814)
2021-08-16 19:23:07 +02:00
Ana Cabral
0271c71ec8 nm-initrd-generator: add kernel command line options ethtool autoneg, speed and duplex to configure NICs
Merge Request !941

(cherry picked from commit f06c89f5)
2021-08-12 15:57:43 -03:00
Thomas Haller
937171ba18
ifup: extend ifup/ifdown to be smarter about NetworkManager profiles
Now that NetworkManager on Fedora 33 and RHEL 9 no longer writes
ifcfg-rh files by default ([1]), ifup/ifdown became less useful.

Possibly users shouldn't use it and it would be fine that new-style profiles
(keyfile) no longer work with these commands. But this is deemed as too
disruptive for users.

Note that our previous ifup/ifdown compat scripts only honored the argument
to be part of the ifcfg filename. That was not what initscripts were doing,
which called `need_config()` function that searched also the contents of
the files. With this extension, ifup/ifdown gets smarter too, to better
guess what the user might have wanted.

Extend the script by making it smarter, and to work with connection profile
names.

With this extension we further solidify ifup/ifdown as part of NetworkManager
command line API. That is problematic, because these tools pollute the
$PATH, by not having a clear NM-specific name. Also, these scripts
should only exist on Fedora/RHEL, which makes their usage non-portable
to other distros.
Also, other distros already ship different tools with name ifup/ifdown.
Extending the use of these scripts is thus undesirable, as it furthers
distro-specific commands.

Still, these arguments seem to not hold and users need to be "helped".
As Fedora users cannot be expected to unlearn "ifup" today, there is no
reason to assume they could in a few years. This likely means we will
never get rid of these scripts.

Also, if we truly would make ifup/ifdown part of NetworkManager, then a better
implementation would be that nmcli honors being called with these names.
That is not done, because nmcli's implementation currently is not as
nice to make that extension trivial (as it should be). It also would
mean to embrace ifup/ifdown officially. A shell script works well enough
as a hack.

[1] https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/936
(cherry picked from commit 30e7400528)
2021-08-10 22:00:22 +02:00
Thomas Haller
55aa9eda0d
release: bump version to 1.32.9 (development) 2021-08-10 19:16:43 +02:00
Thomas Haller
921cfd8ef1
release: bump version to 1.32.8 2021-08-10 19:16:43 +02:00
Thomas Haller
c37f72acd3
glib-aux: fix thread-safe initialization in _nm_g_source_sentinel_get_init()
Fixes: ce7c28c514 ('glib-aux: add nm_g_source_sentinel_get() util')
(cherry picked from commit 2140bbf7f5)
2021-08-10 19:15:07 +02:00
Thomas Haller
ef3b773bc3
NEWS: update 2021-08-10 16:20:17 +02:00
Wen Liang
59633dbe11
aliyun: reuse ipv4 gateway address returned by metadata server
The default ipv4 gateway address of the VPC in Aliyun cloud is not the
first IP address in the CIDR subnet block, we should instead use the
ipv4 gateway address retrieved from the metadata server in
`_nmc_mangle_connection()`.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/958

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
(cherry picked from commit 778e1f8493)
2021-08-09 17:16:07 +02:00
Ana Cabral
0e7d260852
.gitignore: include files used by eclipse-cdt IDE
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/957
(cherry picked from commit e6583941b1)
2021-08-06 20:19:47 +02:00
Beniamino Galvani
7730547721 device: store the original MTU before force-setting it
In case the MTU is force-set (e.g. for bridges), priv->mtu_initial and
priv->ip6_mtu_initial must be initialized before changing the MTU,
otherwise the wrong value will be restored on deactivation.

Fixes: e23798a5e5 ('bridge: force (hack)-set of the MTU when explicitly set in the profile')

https://bugzilla.redhat.com/show_bug.cgi?id=1973536
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/955
(cherry picked from commit 3f42e2005a)
2021-08-06 15:37:23 +02:00
Thomas Haller
780f89720d
firewalld: fix build error due to nm_utils_strdup_reset() 2021-08-06 14:43:35 +02:00
Thomas Haller
f915a43eb2
firewalld: merge branch 'th/firewalld-reloaded'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/949

(cherry picked from commit a9279d1e89)
2021-08-06 14:38:36 +02:00
Thomas Haller
d409a3c230
firewalld: listen to Reloaded signal and reconfigure firewall zones
During reload, firewalld drops the current runtime configuration.
NetworkManager should listen to that, and reconfigure the zones
that it cares about.

(cherry picked from commit 0f100abd85)
2021-08-06 14:38:35 +02:00
Thomas Haller
424535093c
firewalld: fix initialized_now argument for NMFirewalldManager's "state-changed" signal
(cherry picked from commit b2ed02dda9)
2021-08-06 14:38:35 +02:00
Thomas Haller
17312aa25c
firewalld: make D-Bus calls against unique name for firewalld service
As we keep track of the current name owner, use its unique name
for the D-Bus requests.

We also track when the name owner changes, so at the point when we make
the D-Bus call, the current name owner was still running. We should talk
to it directly. If at the same time, firewalld restarts, we go through
our usual tracking of the name owner and will retry -- but always
talking to the unique name.

(cherry picked from commit 3d949f98e4)
2021-08-06 14:38:35 +02:00
Thomas Haller
500c66551a
firewalld: track current name_owner in NMFirewalldManager
Not only track whether we have a name-owner, but also which.

(cherry picked from commit 9debc3d028)
2021-08-06 14:38:35 +02:00
Thomas Haller
78cc70feb3
firewalld: prefix firewalld logging messages with "firewalld"
It seems more apt than "firewall: ...".

(cherry picked from commit b55f95abfa)
2021-08-06 14:38:35 +02:00
Thomas Haller
a7a0404cb5
man: update URL for networkmanager.dev home page
(cherry picked from commit 7a39f1f7e7)
2021-08-03 14:58:08 +02:00
Thomas Haller
788c13c94f
release: bump version to 1.32.7 (development) 2021-07-28 18:00:18 +02:00