Commit graph

28760 commits

Author SHA1 Message Date
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
Thomas Haller
dd3f3cb9e5
release: bump version to 1.32.6 2021-07-28 18:00:18 +02:00
Thomas Haller
7521ede1ad
initrd: fix handling "ip=single-dhcp:..." in reader_parse_ip()
Fixes: bf7530ccc1 ('initrd: honor "ip=single-dhcp" option as alias for "dhcp"')
(cherry picked from commit 22d6be54f3)
2021-07-28 17:56:58 +02:00
Thomas Haller
404272b152
NEWS: update 2021-07-28 17:26:28 +02:00
Beniamino Galvani
2188c00ed4 merge: branch 'bg/rh1934122'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/862

(cherry picked from commit 2d879c1ac5)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
72f6edb01d core: introduce device 'allowed-connections' property
Configuration can have [device*] and [connection*] settings and both
can include a 'match-device=' key, which is a list of device-specs.

Introduce a new 'allowed-connections' key for [device*] sections,
which specifies a list of connection-specs to indicate which
connections can be activated on the device.

With this, it becomes possible to have a device configuration like:

  [device-enp1s0]
  match-device=interface-name:enp1s0
  allowed-connections=except:origin:nm-initrd-generator

so that NM in the real root ignores connections created by the
nm-initrd-generator, and starts activating a persistent
connection. This requires also setting 'keep-configuration=no' to not
generate an assumed connection.

(cherry picked from commit bace14fe1f)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
7ca6e9d687 core: add nm_utils_connection_match_spec_list()
Add function nm_utils_connection_match_spec_list() to check whether a
connection matches a spec list. Also document the supported syntax in
the man page.

(cherry picked from commit 604c611cd0)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
1a0f7e1bd3 initrd: add a 'origin' user tag to connections
Introduce a user tag key to indicate where the connection comes
from. It would also be possible to have this as a standard property
(as 'connection.origin'), but since this information can be considered
'meta-data' I think the user setting is more appropriate.

(cherry picked from commit 86f22ce8ba)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
165daca280 core: add 'keep-configuration' device configuration option
Add a new 'keep-configuration' device option, set to 'yes' by
default. When set to 'no', on startup NetworkManager ignores that the
interface is pre-configured and doesn't try to keep its
configuration. Instead, it activates one of the persistent
connections.

(cherry picked from commit df2fe15714)
2021-07-27 17:51:10 +02:00
Beniamino Galvani
a2f9e11942 manager: exit early in get_existing_connection()
Later the function will become more complex. Add a check to exit early
if the device can't assume connections.

(cherry picked from commit b1644fa826)
2021-07-27 17:51:09 +02:00