Commit graph

12611 commits

Author SHA1 Message Date
Beniamino Galvani
ed3f959dca
policy: get the DHCPv6 hostname from the FQDN option
There isn't any 'host-name' option for DHCPv6. Read instead the
'fqdn-fqdn' option that carries the FQDN assigned by the server to the
client.

(cherry picked from commit 1f74ea52f5)
(cherry picked from commit 4e1da002a9)
(cherry picked from commit 7c46ff24e5)
2020-09-29 13:21:21 +02:00
Beniamino Galvani
66fc5bd354
dhcp: export the DHCPv6 FQDN option
The dhclient backend already exports all the option passed by
dhclient, including the FDQN. Export it also for the systemd backend.

(cherry picked from commit 1621a6ddb1)
(cherry picked from commit c6a7618f2b)
(cherry picked from commit 293b00c947)
2020-09-29 13:09:13 +02:00
Beniamino Galvani
d7ff226ceb
systemd: dhcp6: parse the FQDN option
Parse option 39 (Client Fully Qualified Domain Name, RFC 4704) from the DHCP
reply, which specifies the FQDN assigned by the server to the client.

c43eea9f2e
(cherry picked from commit 813fb7d64e)
(cherry picked from commit 504a3486ed)
2020-09-29 13:09:12 +02:00
Beniamino Galvani
c1dcc259ec
systemd: dhcp6: remove assertions in dhcp6_option_parse_domainname()
Assertions are for programming errors; here the input comes directly
from the DHCP response packet.

af710b535b
(cherry picked from commit e2248143af)
(cherry picked from commit 555c7e4ee6)
2020-09-29 13:09:12 +02:00
Thomas Haller
343293ffcb
core: fix D-Bus type for "org.freedesktop.NetworkManager.Capabilities" property
Fixes: 297d4985ab ('core/dbus: rework D-Bus implementation to use lower layer GDBusConnection API')
(cherry picked from commit 51b7d351fa)
(cherry picked from commit 2d8c6343e0)
(cherry picked from commit 72bc477ef6)
2020-09-18 15:34:41 +02:00
Beniamino Galvani
584f467e13 device: fix wrongly considering ipv6.may-fail for ipv4
Fixes: 5e71f01605 ('device: merge stage3 and stage4 ip-config function for IPv4 and IPv6')
(cherry picked from commit a017936223)
(cherry picked from commit 0adfcadc9d)
(cherry picked from commit 1438d5a9f0)
2020-09-09 11:20:09 +02:00
Thomas Haller
e6f235d971
ndisc/tests: relax assertion in "test-ndisc-fake.c"
Still assertion failures:

  ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->timestamp >= _ts): (9 >= 10)

(cherry picked from commit a5133e708e)
(cherry picked from commit 75e8f4c36f)
(cherry picked from commit 80dbc0f17b)
2020-09-08 14:51:52 +02:00
Thomas Haller
6f2731b6cb
ndisc/tests: fix assertion in "test-ndisc-fake.c"
First I wanted to fix

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

but that leads to a different failure:

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->lifetime == (9)): (10 == 9)

Instead, the start and end times must match exact (in their duration),
we only allow them to be shifted by up to one second.

Fixes: 8209095ee1 ('ndisc/tests: relax the assertion in "test-ndisc-fake.c"')
(cherry picked from commit b2f03544a7)
(cherry picked from commit 838777a891)
(cherry picked from commit 1470212f4c)
2020-09-08 14:51:51 +02:00
Thomas Haller
712194ac8c
ndisc/tests: relax the assertion in "test-ndisc-fake.c"
test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

(cherry picked from commit 8209095ee1)
(cherry picked from commit 75177f6967)
(cherry picked from commit c32f993486)
2020-09-08 14:51:51 +02:00
Thomas Haller
017bfbf4d7
ndisc/tests: make assertion checks a macro and not a function in test-ndisc-fake
By having it a function, the assertion failure does not show the line
number of the origin. Make them a macro, so that we see where exactly it
failed.

(cherry picked from commit 3b896cc642)
(cherry picked from commit b1a7eda71d)
(cherry picked from commit 8316943338)
2020-09-08 14:51:51 +02:00
Antonio Cardace
5913e4cee9
initrd: fix memory leak
Signed-off-by: Antonio Cardace <acardace@redhat.com>
Fixes: 9f9609555d ('initrd: add configuration generator')
(cherry picked from commit d5c05d07c7)
(cherry picked from commit bba54613eb)
(cherry picked from commit 67bb9896b3)
2020-09-04 13:58:01 +02:00
Thomas Haller
67135e64c9
core: avoid deprecated matchfilecon SELinux API instead of selabel
The matchfilecon API is deprecated for a very long time. Since selinux 3.1
the functions are also marked as deprecated in the header, which causes
compiler warnings and build failures.

Update the code to use selabel API instead.

(cherry picked from commit 173533c3b2)
(cherry picked from commit f5aafb9da4)
(cherry picked from commit bde9f1023f)
2020-08-28 22:51:56 +02:00
Thomas Haller
fb93ca2851
modem: suppress deprecated warning from libmm for MM_MODEM_CAPABILITY_LTE_ADVANCED
On Ubuntu 20.10, we build against ModemManager 1.14.0 and get a compiler warning:

  ../src/devices/wwan/nm-modem-broadband.c: In function 'try_create_connect_properties':
  ../src/devices/wwan/nm-modem-broadband.c:492:2: error: 'MMModemCapabilityDeprecated' is deprecated [-Werror=deprecated-declarations]
    492 |  if (MODEM_CAPS_3GPP (ctx->caps)) {
        |  ^~

Suppress it.

An alternative would be to drop the flag entirely. It seems the flag
was never used (and never will be used). But if that's true, there is
little harm done checking it. If it's not true, we better keep checking
for older versions.

0cd76bf1c4
(cherry picked from commit 03dc759026)
(cherry picked from commit 12e4a4a5df)
(cherry picked from commit b672944603)
2020-08-28 22:13:11 +02:00
Thomas Haller
3d27459460
device: fix casting pointer to enum for sriov_reset_on_deactivate_cb()
Avoids a compiler warning:

    ../src/devices/nm-device.c:16079:26: error: cast to smaller integer type 'NMDeviceStateReason' from 'gpointer' (aka 'void *') [-Werror,-Wvoid-pointer-to-enum-cast]
            deactivate_ready (self, (NMDeviceStateReason) reason);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 121c58f0c4 ('core: set number of SR-IOV VFs asynchronously')
(cherry picked from commit 918ebd600a)
(cherry picked from commit 32641b9fca)
(cherry picked from commit c24888be51)
2020-08-28 13:14:11 +02:00
Thomas Haller
2e0cb189d3
device: fix leak in sriov_deactivate_cb()
On master this code was refactored and thereby the leak was
fixed. Instead of backporting that, do an original patch for
nm-1-24 to fix only the leak.

Fixes: 121c58f0c4 ('core: set number of SR-IOV VFs asynchronously')
(cherry picked from commit a28d4a305a)
2020-08-28 13:14:04 +02:00
Thomas Haller
739417ab85
lldp: fix lldp_neighbor_equal() to compare variants
Fixes: 8200078ec5 ('lldp: support IEEE 802.3 TLVs')
(cherry picked from commit 9b7c5ca12d)
(cherry picked from commit 4b84eeba57)
2020-08-28 12:30:21 +02:00
Thomas Haller
321f9b51c3
lldp: fix lldp_neighbor_equal() to compare lists of variants
Fixes: 6c52d946fc ('lldp: add support for management address TLV')
(cherry picked from commit 7c0d73d94a)
(cherry picked from commit 0426681ab4)
2020-08-28 12:30:11 +02:00
Thomas Haller
90b1df4754
lldp: backslash escape untrusted chassis-id,port-id strings
This is a serious issue, because this is not guaranteed to be UTF-8
data.

Fixes: 07a9364d9c ('device: export list of LLDP neighbors through D-Bus')
(cherry picked from commit 8cd9b87c91)
(cherry picked from commit 94f8e9fbdc)
2020-08-28 12:28:05 +02:00
Beniamino Galvani
f59af10216
ifcfg-rh: fix memory leak reading tc filters
Fixes: 902bbfdb18 ('ifcfg-rh: add tc support')
(cherry picked from commit 88e8f2829e)
(cherry picked from commit b1e00a5805)
(cherry picked from commit 7a3f78d7eb)
2020-08-28 12:07:42 +02:00
Beniamino Galvani
cde95a3c75
ifcfg-rh: check return value of fdopen()
Reported by coverity:

>>> CID 210222: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing a pointer that might be "NULL" "f" when calling
    "fseek".

Fixes: ac5206aa9c ('2007-11-21')
(cherry picked from commit 581aa981c2)
(cherry picked from commit bb40de0ca0)
2020-08-28 12:06:56 +02:00
Thomas Haller
a1a3cce6ef
rdisc: avoid static variable in receive_ra()
It's unnecessary and makes the function unnecessarily not thread safe.
Of course, also ndp_msg_opt_route_prefix() uses static variables, so
it's still not thread safe.

Fixes: c3a4656a68 ('rdisc: libndp implementation')
(cherry picked from commit fbb65de32e)
2020-08-28 11:38:12 +02:00
Thomas Haller
b28eee1c4b
rdisc: fix parsing ndp_msg_opt_dnssl_lifetime() from IPv6 RA
Fixes: c3a4656a68 ('rdisc: libndp implementation')
(cherry picked from commit d1181533b8)
2020-08-28 11:38:01 +02:00
Beniamino Galvani
5f22c06c53 device: don't reset the MAC without ifindex
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.

(cherry picked from commit 77b6ce7d04)
(cherry picked from commit 791a888cad)
(cherry picked from commit e1f76e7044)
2020-07-21 10:19:11 +02:00
Beniamino Galvani
69c5c5e767 ovs: also set cloned MAC address via netlink
We already set the MAC of OVS interfaces in the ovsdb. Unfortunately,
vswitchd doesn't create the interface with the given MAC from the
beginning, but first creates it with a random MAC and then changes it.

This causes a race condition: as soon as NM sees the new link, it
starts IP configuration on it and (possibly later) vswitchd will
change the MAC.

To avoid this, also set the desired MAC via netlink before starting IP
configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/483
(cherry picked from commit 47ec3d14d4)
(cherry picked from commit 60d10b146d)
(cherry picked from commit 0139995590)
2020-07-21 10:19:11 +02:00
Beniamino Galvani
f54c5400c8 ovs: set MAC address on the bridge for local interfaces
When a user creates a ovs-interface with the same name of the parent
ovs-bridge, openvswitch considers the interface as the "local
interface" [1] and assigns the MAC address of the bridge to the
interface [2].

This is confusing for users, as the cloned MAC property is ignored in
some cases, depending on the ovs-interface name.

Instead, detect when the interface is local and set the MAC from the
ovs-interface connection in the bridge table.

[1] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/vswitch.xml#L2546
[2] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/bridge.c#L4744

(cherry picked from commit 5d4c8521a3)
(cherry picked from commit 7548c29a89)
(cherry picked from commit 127294babc)
2020-07-21 10:19:11 +02:00
Beniamino Galvani
bb4781cc58 policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to
reconnect until the master connection activates again; when this
happens, the master clears the blocked reason for all its slaves in
activate_slave_connections() and tries to reconnect them. For this to
work, the slave should be marked as blocked when it fails with
dependency-failed.

(cherry picked from commit 725fed01cf)
(cherry picked from commit e1755048e3)
(cherry picked from commit ecb134ac34)
2020-07-21 10:17:20 +02:00
Beniamino Galvani
6d0e8a2acf manager: fix race condition when resuming from sleep
If the device state change (to disconnected or unmanaged) triggered by
a sleep event happens after the wake, the devices becomes wrongly
unmanaged and it's necessary to manually manage it again, or restart
NM.

During the wake event we should disconnect the device_sleep_cb()
callback for all devices because we don't want to react to state
changes anymore; in particular we don't need to detect when the device
becomes disconnected to unmanage it.

(cherry picked from commit fe2d93980b)
(cherry picked from commit 971897195a)
(cherry picked from commit 7913275b02)
2020-07-21 10:17:20 +02:00
Beniamino Galvani
da54b35af3 device: restart DHCP only for devices that are active or activating
do_sleep_wake() tries to restart DHCP for all devices, even ones that
are disconnecting. When a device is disconnecting, it still has a DHCP
client instance but we shouldn't restart it because it makes no sense;
and especially, the device could be already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1852612
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/561
(cherry picked from commit 2c50438987)
(cherry picked from commit 5321490180)
(cherry picked from commit ef755588ad)
2020-07-21 10:16:55 +02:00
Beniamino Galvani
5bfaee825c ppp: fix taking control of link generated by kernel
NetworkManager can't control the name of the PPP interface name
created by pppd; so it has to wait for the interface to appear and
then rename it. This happens in nm_device_take_over_link() called by
nm-device-ppp.c:ppp_ifindex_set() when pppd tells NM the ifindex of
the interface that was created.

However, sometimes the initial interface name is already correct, for
example when the connection.interface-name is ppp0 and this is the
first PPP interface created.

When this happens, nm_device_update_from_platform_link() is called on
the NMDevicePPP and it sets the device ifindex. Later, when pppd
notifies NM, nm_device_take_over_link() fails because the ifindex is
already set:

 nm_device_take_over_link: assertion 'priv->ifindex <= 0' failed

Make nm_device_take_over_link() more robust to cope with this
situation.

https://bugzilla.redhat.com/show_bug.cgi?id=1849386
(cherry picked from commit 75bc21c4cf)
(cherry picked from commit 72d66fffac)
(cherry picked from commit 684a1a06cc)
2020-07-08 15:14:22 +02:00
Beniamino Galvani
84ad85eb31 device: clean up exported IP6 config when flushing addresses
After flushing addresses and routes, it's also necessary to update the
exported IP6 configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1848888
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/551

Fixes: e302f5ff77 ('device: flush IP configuration of slaves during activation')
(cherry picked from commit 071104124b)
(cherry picked from commit 2b5ba370a6)
(cherry picked from commit 96f230bcee)
2020-06-30 13:46:04 +02:00
Beniamino Galvani
c92a857538 settings: fix assertion when updating default wired connection
The connection is expected to have the NM_GENERATED flag, since it has
a default wired device.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/471
(cherry picked from commit 4aefad5673)
(cherry picked from commit 3951396de7)
(cherry picked from commit ac89b8f6b7)
2020-06-22 09:59:14 +02:00
Beniamino Galvani
359f2ef1f2 Revert "manager: change autoconnect-slaves logic for already active slaves"
The commit breaks many nmstate CI tests. It also breaks the
autoconnect-slaves functionality: if the master gets reactivated and
the slave was active, the slave is not reconnected.

A different solution is needed for the original issue.

This reverts commit 024e983c8e.

(cherry picked from commit 6e02622f57)
(cherry picked from commit 877599c390)
2020-06-15 10:15:35 +02:00
Beniamino Galvani
399aad15bf ovs: ignore failures of patch interfaces
When there are two patch ports connected, each of them must reference
the other; however they can't be created in a single transaction
because they are part of different bridges (so, different
connections). Therefore, the first patch that gets activated will
always fail with "No usable peer $x exists in 'system' datapath" until
the second patch exists.

In theory we could also match the error message, however this doesn't
seem very robust as the message may slightly change in the future.

(cherry picked from commit ffeac35f04)
(cherry picked from commit 75cbf21738)
2020-06-11 13:28:09 +02:00
Thomas Haller
f238f0a714
supplicant: fix verification of key_mgmt config for FT-FILS-SHA{256,384}
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/468

Fixes: d17a0a0905 ('supplicant: allow fast transition for WPA-PSK and WPA-EAP')
(cherry picked from commit e7a74721be)
(cherry picked from commit e5fb776441)
2020-06-11 11:10:29 +02:00
Beniamino Galvani
4df63b205e manager: change autoconnect-slaves logic for already active slaves
Autoconnect-slaves currently forces an activation of all slaves, even
if there is already an active connection for them. This is bad because
at boot slaves first try to autoconnect, then the autoconnect-slaves
of the master kicks in and disconnects/reactivates them.

The only reason why the forceful reactivation was added was to fix
[1]; in that scenario, a slave connection is already active as
non-slave; then it is updated to be a slave; later, the master with
autoconnect-slaves is manually activated. NetworkManager should detect
that the slave connection must now be activated by autoconnect-slaves.

Add a specific check for such situation, instead of always
reactivating all slaves.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1845018

Fixes: 4985ca5ada ('manager: allow autoconnect-slaves to reconnect the same connection')
(cherry picked from commit 024e983c8e)
(cherry picked from commit d07d515dd7)
2020-06-11 10:29:57 +02:00
Thomas Haller
77e1132845
ifcfg-rh: support persisting 802-1x.pin and pin-flags property
(cherry picked from commit 655fd1ebd8)
(cherry picked from commit 799cee5068)
2020-05-29 13:12:13 +02:00
Thomas Haller
7a20dd4dbb
ifcfg-rh: fix handling "802-1x.{phase2-,}ca-path" in ifcfg-rh settings plugin
https://bugzilla.redhat.com/show_bug.cgi?id=1840210
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/448
(cherry picked from commit b6b6639c7c)
(cherry picked from commit 67f1da27fe)
2020-05-27 10:57:29 +02:00
Beniamino Galvani
678c6b6a6a core: signal parent-active only when the parent AC is activated
The parent-active signal is used by the manager to determine when the
parent active-connection is ready and a connection that depend on it
can proceed.

The AC state could transition from ACTIVATING directly to
DEACTIVATING; in such case we should not emit the signal but instead
just stop watching the parent AC.

Fixes: 6e382ea91d ('active-connection: add parent active connection tracking')
https://bugzilla.redhat.com/show_bug.cgi?id=1778073
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/510
(cherry picked from commit 02ea74c920)
(cherry picked from commit 30be025e59)
2020-05-19 21:43:42 +02:00
Beniamino Galvani
1dcdd1e8dd device: use the nm-shared firewalld zone in shared mode
When the interface is in IPv4 or IPv6 shared mode and the user didn't
specify an explicit zone, use the nm-shared one.

Note that masquerade is still done through iptables direct calls
because at the moment it is not possible for a firewalld zone to do
masquerade based on the input interface.

The firewalld zone is needed on systems where firewalld is using the
nftables backend and the 'iptables' binary uses the iptables API
(instead of the nftables one). On such systems, even if the traffic is
allowed in iptables by our direct rules, it can still be dropped in
nftables by firewalld.

(cherry picked from commit 3e2b723532)
(cherry picked from commit 13438e041a)
2020-05-19 08:42:42 +02:00
Beniamino Galvani
d69d92c658 ip-tunnel: set cloned-mac-address only for layer2 tunnel devices
For ip-tunnel modes that encapsulate layer2 packets (gretap and
ip6gretap) we allow the presence of an ethernet setting in the
connection and honor the cloned-mac-address specified in it.

For all other modes, the ethernet setting is removed during
normalization, but a value different from 'preserve' could be set via
global default.

The kernel doesn't allow setting a MAC for layer3 devices, don't do
it.

(cherry picked from commit 0494a84878)
(cherry picked from commit 78ed14166c)
2020-05-15 10:04:04 +02:00
Thomas Haller
c0997fa4f3
acd: fix char buffer argument to _acd_event_to_string_buf()
(cherry picked from commit 6e9967939b)
(cherry picked from commit 1e1ae9ba07)
2020-05-08 07:58:36 +02:00
Thomas Haller
198e233b91
acd: avoid alloca() inside an unbounded loop
(cherry picked from commit b447c80ad8)
(cherry picked from commit ecb9e0e3df)
2020-05-07 14:06:09 +02:00
Beniamino Galvani
cd056b664b platform: fix test failure when /proc is mounted read-only
Expect a failure when writing to /proc if the file system is mounted
read-only.

(cherry picked from commit 211eb3ff8a)
2020-05-04 14:00:27 +02:00
Beniamino Galvani
93df9d6c49 device: flush IP configuration of slaves during activation
If a device only has an IPv6 link-local address, we don't generate an
assumed connection. Therefore, when a new slave connection (without IP
configuration) is activated on the device, we don't deactivate any
existing connection and the link-local address remains configured.

The IP configuration of an activated slave should be predictable and
not depend on the previous state; let's flush addresses and routes on
activation.

https://bugzilla.redhat.com/show_bug.cgi?id=1816517
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/480
(cherry picked from commit e302f5ff77)
(cherry picked from commit 0344a97105)
2020-04-28 10:02:58 +02:00
Thomas Haller
55c361453b vpn: clear host part of IPv6 routes received from VPN plugin
Kernel would reject adding a route with a destination host part not
all zero. NetworkManager generally coerces such routes and there
are assertions in place to ensure that.

We forgot to ensure that for certain IPv6 routes from VPN plugins.
This can cause an assertion failure and wrong behavior.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/482
(cherry picked from commit b437bb4a6e)
(cherry picked from commit c7586e6388)
2020-04-28 09:43:04 +02:00
Beniamino Galvani
6abf71f056 bluetooth: disconnect signal on dispose
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/417

Fixes: 4154d9618c ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data')
(cherry picked from commit 5c547fdab3)
(cherry picked from commit 93b130c05a)
2020-04-22 09:24:29 +02:00
Beniamino Galvani
2b7908a1c6 dhcp-helper: retry in case of failure connecting to D-Bus unix socket
Connecting to the unix socket can fail with EAGAIN if there are too
many pending connections and the server can't accept them in time
before reaching backlog capacity. Ideally the server should increase
the backlog length, but GLib doesn't provide a way to change it for a
GDBus server. Retry for up to 5 seconds in case of failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1821594
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/471
(cherry picked from commit eefe5dacaa)
(cherry picked from commit 4cf63dfa15)
2020-04-21 08:58:29 +02:00
Beniamino Galvani
54254bf6fe ovsdb: retry calls in case of communication error with server
When the server is restarted the write to unix socket fails with
EPIPE. In such case, don't fail all the calls in queue; instead, after
a sync of the ovsdb state (through a monitor call), start processing
the queue again, including the call that previously failed.

Add a retry counter to avoid that calls are stuck in the queue forever
in a hypothetical scenario in which the write always fails.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/459
(cherry picked from commit db37e530e8)
2020-04-09 17:29:17 +02:00
Thomas Haller
eec2740d71 all: use wrappers for g_ascii_strtoll(), g_ascii_strtoull(), g_ascii_strtod()
Sometimes these function may set errno to unexpected values like EAGAIN.
This causes confusion. Avoid that by using our own wrappers that retry
in that case. For example, in rhbz#1797915 we have failures like:

    errno = 0;
    v = g_ascii_strtoll ("10", 0, &end);
    if (errno != 0)
        g_assert_not_reached ();

as g_ascii_strtoll() would return 10, but also set errno to EAGAIN.

Work around that by using wrapper functions that retry. This certainly
should be fixed in glib (or glibc), but the issues are severe enough to
warrant a workaround.

Note that our workarounds are very defensive. We only retry 2 times, if
we get an unexpected errno value. This is in the hope to recover from
a spurious EAGAIN. It won't recover from other errors.

https://bugzilla.redhat.com/show_bug.cgi?id=1797915
(cherry picked from commit 7e49f4a199)
2020-04-02 07:45:39 +02:00
Thomas Haller
62469c1401 device/bluetooth: avoid g_ascii_strtoull() to parse capabilities
Avoid g_ascii_strtoull() calling directly. It has subtle issues, which is why
we have a wrapper for it.

(cherry picked from commit 659ac9cc12)
2020-04-02 07:44:25 +02:00