Commit graph

31147 commits

Author SHA1 Message Date
Fernando Fernandez Mancera
fdedaa6c92 merge: branch 'ff/backport_1_40_bond_port' 2023-05-15 16:03:03 +02:00
Fernando Fernandez Mancera
d36620e654 bonding: add support to prio property in bond ports
Add per port priority support for bond active port re-selection during
failover. A higher number means a higher priority in selection. The
primary port still has the highest priority. This option is only
compatible with active-backup, balance-tlb and balance-alb modes.

(cherry picked from commit 2f0571f193)
(cherry picked from commit 748f6388aa)
2023-05-15 16:02:01 +02:00
Fernando Fernandez Mancera
4fd186bbf6 libnm: add NM_VERSION_1_40_20 2023-05-15 15:44:46 +02:00
Fernando Fernandez Mancera
c787d22fc8 platform: add support to prio property in bond ports
(cherry picked from commit e200b16291)
(cherry picked from commit 84f17a2fbb)
2023-05-15 15:44:39 +02:00
Fernando Fernandez Mancera
ee592c02dd platform: add netlink support for bond port options
sysfs is deprecated and kernel will not add new bond 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.

(cherry picked from commit bb435674b5)
(cherry picked from commit 1bce7f0dec)
2023-05-15 15:44:18 +02:00
Lubomir Rintel
836d7511e8 bond,bridge,team: use uuid for con.master when generating connection
If we're generating a connection for an externally configured slave,
refer the master by the UUID instead of the device name.

This doesn't matter most of the time. However, on a checkpoint restore
we need to make sure that a connection that is unambiguously the original
master is up.

Otherwise it could happen that a different connection was activated on the
same master device and the slaves being restored don't agree on which master
connection to bring up.

I can't think of any thing that would rely on this but I've been wrong
about more serious things before.

Fixes-test: @libnm_snapshot_reattach_unmanaged_ports_to_bridge

https://bugzilla.redhat.com/show_bug.cgi?id=2125615
(cherry picked from commit dc254f90e2)
2023-05-15 15:44:09 +02:00
Beniamino Galvani
0a158141d3 platform: rename link_change() to link_change_extra()
There are many functions to replace properties of a link
(link_set_address, link_set_mtu, link_set_name, link_change,
etc.). Eventually, they will be replaced by a function that does
everything and removes all the code duplication.

That function will be named link_change(); rename the current
link_change() to link_change_extra().

(cherry picked from commit babe2bacd3)
(cherry picked from commit 9ae85f6541)
2023-05-15 15:44:00 +02:00
Fernando Fernandez Mancera
40c523cd78 libnm: fix ifcfg variable documentation at queue-id property
The correct variable for queue-id in ifcfg is BOND_PORT_QUEUE_ID.

(cherry picked from commit 762cd06ffa)
(cherry picked from commit 87316737f3)
2023-05-15 15:43:54 +02:00
Thomas Haller
26ce6f5062
NEWS: belatedly mention default for ipv6.addr-gen-mode
Fixes: e6a33c04eb ('all: make "ipv6.addr-gen-mode" configurable by global default')
(cherry picked from commit 48a3682a75)
(cherry picked from commit 987f98197b)
2023-05-03 10:19:54 +02:00
Beniamino Galvani
4a81802e85 device: emit dhcp-change dispatcher event also after a lease renewal
Fixes: e1648d0665 ('core: commit l3cd asynchronously on DHCP bound event')
Co-authored-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=2179537
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1609
(cherry picked from commit cab80c5129)
(cherry picked from commit b3584ae994)
2023-04-19 10:03:59 +02:00
Beniamino Galvani
5f9547dcc1 device: stop activation when queueing the unmanaged state
When the unmanaged state is queued, we must ensure that the current
activation doesn't overwrite the queue stated with a new one. This can
happen for example if a dispatcher script or a firewall call
terminate, or if the next activation stage is dispatched.

Fixes-test: @preserve_master_and_ip_settings
https://bugzilla.redhat.com/show_bug.cgi?id=2178269
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1599
(cherry picked from commit 89a8f51235)
(cherry picked from commit b2ed01efc9)
2023-04-11 09:56:46 +02:00
Beniamino Galvani
8ae744ee5d
dhcp: reset IPv6 DAD flag on lease update
If the client was waiting for IPv6 DAD to complete and the lease was
updated or lost, `wait_ipv6_dad` needs to be cleared; otherwise, at
the next platform change the client will try to evaluate the DAD state
with a different or no lease. In particular if there is no lease the
client will try to decline it because there are no valid addresses,
leading to an assertion failure:

 ../src/core/dhcp/nm-dhcp-client.c:997:_dhcp_client_decline: assertion failed: (l3cd)

Backtrace:

  __GI_raise ()
  __GI_abort ()
  g_assertion_message ()
  g_assertion_message_expr ()
  _dhcp_client_decline (self=0x1af13b0, l3cd=0x0, error_message=0x8e25e1 "DAD failed", error=0x7ffec2c45cb0) at ../src/core/dhcp/nm-dhcp-client.c:997
  l3_cfg_notify_cb (l3cfg=0x1bc47f0, notify_data=0x7ffec2c46c60, self=0x1af13b0) at ../src/core/dhcp/nm-dhcp-client.c:1190
  g_closure_invoke ()
  g_signal_emit_valist ()
  g_signal_emit ()
  _nm_l3cfg_emit_signal_notify () at ../src/core/nm-l3cfg.c:629
  _nm_l3cfg_notify_platform_change_on_idle () at ../src/core/nm-l3cfg.c:1390
  _platform_signal_on_idle_cb () at ../src/core/nm-netns.c:411
  g_idle_dispatch ()

Fixes: 393bc628ff ('dhcp: wait DAD completion for DHCPv6 addresses')

https://bugzilla.redhat.com/show_bug.cgi?id=2179890
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1594
(cherry picked from commit 24461954d0)
(cherry picked from commit 5019004bad)
2023-04-06 19:14:00 +02:00
Ratchanan Srirattanamet
ad2d7a7362
wwan/ofono: correct MMS proxy property lookup
The property name under `Settings` dict is just `Proxy`, unlike the one
outside which is `MessageProxy`. See [1].

[1] https://kernel.googlesource.com/pub/scm/network/ofono/ofono/+/refs/heads/master/doc/connman-api.txt#253

Fixes: a6e81af87f ('wwan: add support for using oFono as a modem manager')
(cherry picked from commit 264fed4778)
(cherry picked from commit 7f7fd4244c)
2023-04-06 19:08:37 +02:00
Lubomir Rintel
03c07cc765 release: bump version to 1.40.19 (development) 2023-04-06 12:31:18 +02:00
Lubomir Rintel
2db3748ec8 release: bump version to 1.40.18 2023-04-06 12:31:18 +02:00
Thomas Haller
8011f60c95 core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: df1d214b2e ('clients: polkit-agent: implement polkit agent without using libpolkit')
(cherry picked from commit 20bd6b6803)
2023-04-06 12:26:33 +02:00
Thomas Haller
7d75ae5d34 core: fix setting FD flags in _rfkill_update_system()
F_SETFL will reset the flags. That is wrong, as we only want to add
O_NONBLOCK flag and leaving the other flags alone. Usually, we would
need to call F_GETFL first.

Note that on Linux, F_SETFL can only set certain flags, so the
O_RDWR|O_CLOEXEC flags were unaffected by this. That means, most likely
there are no other flags that our use of F_SETFL would wrongly clear.
Still, it's ugly, because it's not obvious whether there might be other
flags.

Avoid that altogether, by setting the flag already during open().

Fixes: 67e092abcb ('core: better handling of rfkill for WiMAX and WiFi (bgo #629589) (rh #599002)')
(cherry picked from commit 62a85fa845)
2023-04-06 12:26:24 +02:00
Thomas Haller
3364b8b804 core: fix setting non-blocking stderr in nm_utils_spawn_helper()
Fixes: d65702803c ('core: print stderr from nm-daemon-helper')
(cherry picked from commit d1f7e439c6)
2023-04-06 12:25:39 +02:00
Thomas Haller
909c7994fb core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: 6ac21ba916 ('core: add infrastructure for spawning a helper process')
(cherry picked from commit fd123315e5)
2023-04-06 12:25:34 +02:00
Thomas Haller
3611d8b1c7 release: improve hint about documentation in "release.sh"
A "minor" release can still be the latest release. It depends
on which minor release you do. The script isn't smart enough
to understand the difference, so make the hint a bit clearer.

(cherry picked from commit 3c548dd081)
2023-04-06 12:22:13 +02:00
Thomas Haller
5e12cc2b28 release: fix honoring $ORIGIN environment variable
(cherry picked from commit b88700bd4b)
2023-04-06 12:22:13 +02:00
Thomas Haller
7185d1e5b9 contrib/release: fix version in import-docs hint message
(cherry picked from commit a798b4f3f6)
2023-04-06 12:22:13 +02:00
Thomas Haller
9705e2acce contrib/release.sh: add hint about publishing documentation on website
(cherry picked from commit 00affc7b6f)
2023-04-06 12:22:13 +02:00
Lubomir Rintel
bbdb439f12 NEWS: update 2023-04-06 12:20:25 +02:00
Thomas Haller
0510e6f57d
libnm/tests: avoid uninitialized variable warning in _invalid_option_write_handler()
src/libnm-core-impl/tests/test-keyfile.c: In function '_invalid_option_write_handler':
  src/libnm-core-impl/tests/test-keyfile.c:917:9: error: 'message' may be used uninitialized [-Werror=maybe-uninitialized]
    917 |         g_assert(message && strstr(message, "ethtool.bogus"));
        |         ^
  src/libnm-core-impl/tests/test-keyfile.c:905:29: note: 'message' was declared here
    905 |     const char             *message;
        |                             ^
  lto1: all warnings being treated as errors

(cherry picked from commit 8d6349156b)
(cherry picked from commit a71e51e712)
2023-04-03 21:31:48 +02:00
Thomas Haller
ee7f66e42c
wifi: fix aggressively roaming (background Wi-Fi scanning) based on seen-bssids
"wifi.seen-bssids" looks like a regular property, but it is not. Unlike
almost all other properties, it does not contain user configuration,
rather it gets filled by the daemon.

The values are thus stored in "/var/lib/NetworkManager/seen-bssids"
file, and the daemon maintains the values separately from the profile.
Only before exporting the profile on D-Bus, the value gets merged (see
NM_SETTINGS_CONNECTION_GET_PRIVATE(self)->>getsettings_cached and
nm_connection_to_dbus_full().

Hence, looking at nm_setting_wireless_get_num_seen_bssids() is not
working. Fix that.

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

Fixes: 0f3203338c ('wifi: roam aggressively if we on a multi-AP network')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1577
(cherry picked from commit 07c6f933d1)
(cherry picked from commit 3ddc17700d)
2023-03-29 14:27:23 +02:00
Fernando Fernandez Mancera
920ab658b2 dns: add support to no-aaaa option
Users can set `no-aaaa` DNS option to suppress AAAA queries made by the
stub resolver, including AAAA lookups triggered by NSS-based interfaces
such as getaddrinfo. Only DNS lookups are affected.

(cherry picked from commit 9d4bbf78f0)
(cherry picked from commit f71cd2eb72)
2023-03-29 12:24:44 +02:00
Beniamino Galvani
1395171326 core: fix l3cd comparison
NM_CMP_SELF(a, b) returns immediately if the objects are the same.

Fixes: cb29244552 ('core: support compare flags in nm_l3_config_data_cmp_full()')
Fixes-test: @dracut_NM_iSCSI_ibft_table

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1583
(cherry picked from commit 0a02995175)
(cherry picked from commit 5d95c20787)
2023-03-28 09:32:13 +02:00
Lubomir Rintel
6abbdaaa64 cloud-setup: actually pass the HTTP method in nm_http_client_poll_req()
https://bugzilla.redhat.com/show_bug.cgi?id=2179718

Fixes: 8b7e12c2d6 ('cloud-setup/ec2: start with requesting a IMDSv2 token')
Fixes: cd74d75002 ('cloud-setup: make nm_http_client_req() accept a method argument')
(cherry picked from commit f07da04cd9)
(cherry picked from commit d787c0c59d)
2023-03-23 12:45:04 +01:00
Lubomir Rintel
e3ac982b32 cloud-setup/ec2: start with requesting a IMDSv2 token
The present version of the EC2 metadata API (IMDSv2) requires a header
with a token to be present in all requests. The token is essentially a
cookie that's not actually a cookie that's obtained with a PUT call that
doesn't put anything. Apparently it's too easy to trick someone into
calling a GET method.

EC2 now supports IMDSv2 everywhere with IMDSv1 being optional, so let's
just use IMDSv2 unconditionally. Also, the presence of a token API can
be used to detect the AWS EC2 cloud.

https://bugzilla.redhat.com/show_bug.cgi?id=2151986
(cherry picked from commit 8b7e12c2d6)
(cherry picked from commit 429f36cd81)
2023-03-09 15:13:32 +01:00
Lubomir Rintel
06fc0ef35d cloud-setup: document detect() and get_config() methods
Clarify that detect() needs to succeed before get_config().

I thought it's sort of common sense, but it's better to be explicit as
we're going to rely on that.

(cherry picked from commit 088bfd817a)
(cherry picked from commit d99864ccba)
2023-03-09 15:13:32 +01:00
Lubomir Rintel
aaf66e9174 cloud-setup: make nm_http_client_req() accept a method argument
We'll need to be able to issue PUT calls.

(cherry picked from commit cd74d75002)
(cherry picked from commit eff4372045)
2023-03-09 15:13:32 +01:00
Lubomir Rintel
20cd11ee49 cloud-setup: rename get/Get identifiers to req and Req
We're going to extend those to issue methods other than GET.
Also, "request" would've been too long, "req" looks nicer.

(cherry picked from commit 85ce088616)
(cherry picked from commit 6e8cfbae32)
2023-03-09 15:13:32 +01:00
Lubomir Rintel
36d417af60 cloud_setup: unexport nm_http_client_get()
It's not used anywhere.

(cherry picked from commit ce225b2c06)
(cherry picked from commit 23b9514080)
2023-03-09 15:13:32 +01:00
Thomas Haller
89a6ce575d cloud-setup: use nm_strv_dup_packed() in nm_http_client_poll_get()
No need to do a deep clone. The strv array is not ever modified and we
pack it together in one memory allocation.

(cherry picked from commit 599fe234ea)
(cherry picked from commit 3787eacac9)
2023-03-09 15:13:32 +01:00
Thomas Haller
19d08eeb3d
platform/tests: avoid accessing in_addr_t via NMIPAddr union
The compiler may dislike this:

      CC       src/core/platform/tests/libNetworkManagerTest_la-test-common.lo
    In function '_ip_address_add',
        inlined from 'nmtstp_ip4_address_add' at ../src/core/platform/tests/test-common.c:1892:5:
    ../src/core/platform/tests/test-common.c:1807:63: error: array subscript 'NMIPAddr {aka const struct _NMIPAddr}[0]' is partly outside array bounds of 'in_addr_t[1]' {aka 'unsigned int[1]'} [-Werror=array-bounds]
     1807 |                                                   peer_address->addr4,
          |                                                   ~~~~~~~~~~~~^~~~~~~
    ../src/core/platform/tests/test-common.c: In function 'nmtstp_ip4_address_add':
    ../src/core/platform/tests/test-common.c:1886:36: note: object 'peer_address' of size 4
     1886 |                        in_addr_t   peer_address,
          |                        ~~~~~~~~~~~~^~~~~~~~~~~~
    ...

Fixes: 06aafabf14 ('platform/test: add test adding IPv4 addresses that only differ by their peer-address')
(cherry picked from commit 40dd8bf93a)
(cherry picked from commit adca87aba9)
2023-03-09 07:28:29 +01:00
Fernando Fernandez Mancera
8eed16dbf4
platform: compare arp_ip_targets_num before arp_ip_target values
We must first check whether a->arp_ip_targets_num and
b->arp_ip_targets_num are identical. Otherwise, this accesses
potentially uninitialized values.

Fixes: f900f7bc2c ('platform: add netlink support for bond link')
(cherry picked from commit 8dd18d91b2)
(cherry picked from commit c543c7f9d7)
2023-03-09 07:28:22 +01:00
Thomas Haller
daec3cf7c7
platform: ensure ext-data is of expected type
We just lookup the link info by ifindex. There is no guarantee that that
ifindex is of the expected type, to have a suitable ext-data. Check for
that.

Fixes: a7d2cad67e ('platform/linux: add support for WPAN links')
(cherry picked from commit 6dafe78088)
(cherry picked from commit ae1c4f45ad)
2023-03-09 07:28:04 +01:00
Thomas Haller
4a22be26cb
doc: fix documenting "carrier-wait-timeout" in NetworkManager-wait-online manual
Fixes: df94cb2116 ('man: add NetworkManager-wait-online.service.8 manual')
(cherry picked from commit 22c7fd33cc)
(cherry picked from commit e943387af7)
2023-03-09 07:22:40 +01:00
Thomas Haller
b3164a73bf
libnm: merge branch 'champtar:route-unreachable'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1549

(cherry picked from commit 90cc458d31)

(cherry picked from commit 0cdd822989)
2023-03-09 07:21:43 +01:00
Etienne Champetier
e37d6f1d75
platform/trivial: fix route type name (unavailable -> unreachable)
Fixes: 766349879e ('platform/trivial: add code comments for NMPGlobalTracker')
(cherry picked from commit 0decc027ba)
(cherry picked from commit 667ba52272)
2023-03-09 07:21:43 +01:00
Etienne Champetier
979591a067
doc: fix route type name (unavailable -> unreachable)
Fixes: 1cc3d00cb7 ('libnm/doc: list route attributes in `man nm-settings-nmcli`')
(cherry picked from commit fb03dbacd8)
(cherry picked from commit e308bd79e8)
2023-03-09 07:21:43 +01:00
Beniamino Galvani
164591f754 settings: preserve existing connection flags on update
We are passing to the plugin only 'sett_flags', which is the bitmask
of flags to change and works together with 'sett_mask'; however,
plugins interpret that value as the new flags value. The result is
that if there is no change needed (0/0), the existing flags are lost.
Simple reproducer:

  ip link add dummy1 type dummy
  ip link set dummy1 up
  ip addr add dev dummy1 fd01::12/64
  sleep 1

  # now, a external connection is created by NM

  echo "BEFORE:"
  cat /run/NetworkManager/system-connections/dummy1.nmconnection | grep "nm-generated\|volatile\|external"

  # just add a new address to the interface to make it lose
  # the external flag

  ip addr add dev dummy1 172.25.42.1/24
  sleep 1

  echo "AFTER:"
  cat /run/NetworkManager/system-connections/dummy1.nmconnection | grep "nm-generated\|volatile\|external"

Output:

  BEFORE:
  nm-generated=true
  volatile=true
  external=true
  AFTER:

Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1548
(cherry picked from commit 86b922695f)
(cherry picked from commit 4353f84230)
2023-03-02 11:25:39 +01:00
Beniamino Galvani
7886f945ba release: bump version to 1.40.17 (development) 2023-02-23 09:59:17 +01:00
Beniamino Galvani
a9f8a9b550 release: bump version to 1.40.16 2023-02-23 09:59:17 +01:00
Beniamino Galvani
dc60f060c9 NEWS: update 2023-02-23 09:31:48 +01:00
Beniamino Galvani
4bccf2ab4c merge: branch 'bg/hostname-skip-ipv6-tentative'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1536

(cherry picked from commit 34417ac3e6)
(cherry picked from commit bc9482f0e5)
2023-02-22 15:04:23 +01:00
Beniamino Galvani
26d5ad4680 device: skip DNS resolution for tentative IPv6 addresses
A tentative IPv6 address can still fail DAD, so don't use it to
resolve the hostname via DNS. Furthermore, tentative addresses can't
be used to contact the nameserver and so the resolution will fail if
there is no other valid IPv6 address. Wait that the address becomes
non-tentative.

(cherry picked from commit 4138be6a5a)
(cherry picked from commit 0ebd753819)
2023-02-22 15:04:06 +01:00
Beniamino Galvani
0a00b2a95a nm-daemon-helper: log to stderr any error from getaddrinfo()
Print errors from getaddrinfo() to stderr so that they will be logged
by NM.

(cherry picked from commit ac5325e96b)
(cherry picked from commit 41cd94f46a)
2023-02-22 15:01:53 +01:00
Beniamino Galvani
51e3dd447d core: print stderr from nm-daemon-helper
Currently the only way to return an error code from the daemon helper
is via the process exit code, but that is not enough to fully describe
an error from getaddrinfo(); in fact, the function returns a EAI_*
error code and when the value is EAI_SYSTEM, the error code is
returned in errno.

At the moment, any messages printed to stderr by the helper goes to NM
stderr; instead, we want to capture it and pass it through the logging
mechanism of NM, so that it can be filtered according to level and
domain.

(cherry picked from commit d65702803c)
(cherry picked from commit f1f1aee711)
2023-02-22 15:01:52 +01:00