Commit graph

31132 commits

Author SHA1 Message Date
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
Beniamino Galvani
dfaee8d967 device: improve logging for hostname-from-dns events
Improve logging:
 - log only when something changes
 - print the new resolver state, instead of the old one
 - rename state "in-progress" to "started"
 - log when the resolver state is reset due to DNS changes

(cherry picked from commit 7037aa66c6)
(cherry picked from commit 7e3dccb781)
2023-02-22 15:01:51 +01:00
Beniamino Galvani
f4c7d3aa82 core: change buffer allocation size for the daemon helper
Use slightly more efficient sizes.

(cherry picked from commit 961824d43b)
(cherry picked from commit 8e312f6168)
2023-02-22 15:01:50 +01:00
Thomas Haller
b681bcec1d
dhcp: merge branch 'th/dhcp-iaid'
https://bugzilla.redhat.com/show_bug.cgi?id=2169869

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

(cherry picked from commit afbbfebfdb)
(cherry picked from commit 422f086a68)
2023-02-21 09:50:42 +01:00
Thomas Haller
bb20948b7b
libnm/docs: improve documentation for ipv[46].dhcp-iaid setting
(cherry picked from commit f36fabc0fa)
(cherry picked from commit e1d6d72f8e)
2023-02-21 09:46:42 +01:00
Thomas Haller
4efd8565a6
dhcp: log used DHCP IAID as hexstr
This is also the format that we will use to expose it in the lease
information. It's the format that dhclient uses.

(cherry picked from commit 2fe4313b92)
(cherry picked from commit 657949eacd)
2023-02-21 09:46:42 +01:00
Thomas Haller
bec1b14f44
dhcp: add the DHCPv6 IAID to the lease information
We already get the IAID from the dhclient environment. This is actually
rather useful, because dhclient plugin does not support setting the
value (that is, what we request in "config.v6.iaid" is not actually
used). Already previously, was the IAID for dhclient present in the
lease information. Now also normalize/verify it.

Expose the used IAID also with the internal (systemd) plugin. There we
explicitly set the IAID and know it.

(cherry picked from commit 07f1789725)
(cherry picked from commit 2e0e38ab17)
2023-02-21 09:46:39 +01:00
Thomas Haller
c9ecac7098
dhcp: add "static_key" argument to nm_dhcp_option_add_option() etc.
Our lease is tracked in a plain string dictionary. For dhclient plugin
and similar, the keys are received via the environment, they are thus
unlimited. For the internal plugins they are known at compile time and
static strings. We thus sometimes need to clone the string, and
sometimes not.

Unfortunately, we cannot ask the GHashTable whether it has a free
function for the key, so we need to explicitly tell it. Add a parameter
for that.

(cherry picked from commit 5a05ba398b)
(cherry picked from commit 6e80a19059)
2023-02-21 09:46:13 +01:00
Thomas Haller
c45c5c37a4
libnm: accept ipv[46].dhcp-iaid as hexstr
dhclient exports the currently used IAID in the environment as
hex string. We expose this environment in our API, so this is also
the format that NetworkManager uses.

Accept setting the ipv[46].dhcp-iaid as hex string, so that the same
format is accepted on the profile.

While at it, also accept a hex number (0x) because it is also
convenient, and this change already introduces the precedent that the
IAID string is not unique/normalized.

(cherry picked from commit e5dc489197)
(cherry picked from commit 0b4446e252)
2023-02-21 09:45:25 +01:00
Thomas Haller
5f8b0c4713
base: add nm_dhcp_iaid_{from,to}_hexstr() helpers
(cherry picked from commit 4c18adbc74)
(cherry picked from commit 05c6a0d6fa)
2023-02-21 09:45:11 +01:00
Thomas Haller
5dcfb89a48
core: reuse _nm_utils_iaid_verify() for parsing
There should be one function for parsing the string. Use it everywhere.

Also, because we will accept specifying the IAID as hex string so the
same parsing code should be used everywhere.

(cherry picked from commit 69106d0aef)
(cherry picked from commit 99825e727b)
2023-02-21 09:44:30 +01:00
Beniamino Galvani
68da283941 device: update address in nm_device_update_from_platform_link()
When a software device is deactivated, normally we schedule a idle
task to unrealize the device (delete_on_deactivate). However, if a new
activation is enqueued on the same device (and that implies that the
new profile is compatible with the device), then the idle task is not
scheduled and the device will normally transition to the different
states (disconnected, prepare, config, etc.).

For ovs-interfaces, we remove the db entry on disconnect and that
makes the link go away; however, we don't clear the hw_addr* fields of
the device struct.

When the new link appears, we try to set the new cloned MAC but the
stale hw_addr field indicates that it's already set. Avoid this
problem by updating the address as soon as the link appears.

https://bugzilla.redhat.com/show_bug.cgi?id=2168477
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1532
(cherry picked from commit d403ac3d40)
(cherry picked from commit b87fa496ce)
2023-02-20 17:41:23 +01:00
Beniamino Galvani
0c3ce61b02 device: preserve assume state if updating port fails
If we fail to update the port connection, don't forget the assume
state but try again later. This helps when assuming a team connection
and its ports: the ports may fail to generate a connection because
teamd was not started yet; in that case we need to try again.

https://bugzilla.redhat.com/show_bug.cgi?id=2092215
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1523
(cherry picked from commit 27ad228df1)
(cherry picked from commit c273962a73)
2023-02-13 16:02:53 +01:00
Thomas Haller
06d72e9cd5
release: bump version to 1.40.15 (development) 2023-02-13 15:43:09 +01:00
Thomas Haller
31e483e8af
release: bump version to 1.40.14 2023-02-13 15:43:09 +01:00
Thomas Haller
d24d2e6ad6
gitlab-ci: set OMP_NUM_THREADS=1 to avoid libgomp crash for msgmerge
It's not clear why this happens. But since recently in our gitlab-ci,
all the Fedora machines will fail. It happens in the step

  check_run_clean 6 && test $IS_FEDORA = 1 -o $IS_CENTOS = 1 && ./contrib/fedora/rpm/build_clean.sh -g -w crypto_gnutls -w debug -w iwd -w test -W meson

which explains why it only affects Fedora configurations.

It does not always fail, but the probability of failure is high.
The failure is:

  ...
  rm -f et.gmo && /usr/bin/msgmerge --for-msgfmt -o et.1po et.po NetworkManager.pot && /usr/bin/msgfmt -c --statistics --verbose -o et.gmo et.1po && rm -f et.1po
  libgomp: Thread creation failed: Resource temporarily unavailable
  make[3]: *** [Makefile:383: et.gmo] Error 1

Maybe some new resource restricting in gitlab. Let's add this workaround.
I don't really understand the cause, but this seems to avoid it, which is
good enough for me.

(cherry picked from commit 01730f5943)
2023-02-13 11:32:14 +01:00