Commit graph

24878 commits

Author SHA1 Message Date
Valentin David
dc0c31bc6b
build/docs: fix generated XML syntax in tools/generate-docs-nm-settings-docs-gir.py
Class description may contains double quotes which is not valid as XML
attribute value.

[thaller@redhat.com: adjust original patch to reformat code with python black]
[thaller@redhat.com: adjusted patch during backport from nm-1-26 to nm-1-24]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/620
(cherry picked from commit 54e25f23f5)
(cherry picked from commit 7d26773138)
(cherry picked from commit 2899343bfd)
2020-09-29 15:16:55 +02:00
Thomas Haller
aef7a0a65d
docs: fix escaping XML in "tools/generate-docs-nm-settings-docs-gir.py"
The gtk-doc text that the tool receives is not XML, it's a plain text.
When setting the plain text as XML attribute, we need to properly escape
it. The previous XML escape code was naive, and didn't cover for a
plain ampersand.

[thaller@redhat.com: adjusted patch during backport from nm-1-26 to nm-1-24]

(cherry picked from commit 1641cc1d03)
(cherry picked from commit 5b7d39f8e1)
(cherry picked from commit 5c50280bc6)
2020-09-29 15:16:55 +02:00
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
d32148fd66
libnm: hide nm_setting_ip_config_next_valid_dns_option() function from headers
nm_setting_ip_config_next_valid_dns_option() API was added in libnm 1.2, but
it was never exported in the ABI of libnm. It thus was unusable, and any user
trying to link against it would have been unable to do so.

Hide the API now entirely. It doesn't seem a very nice API. If we want to
allow the user to validate option names, we should expose such a function
to validate an option (not to fetch the next valid option from a
profile).

Fixes: 019943bb5d ('libnm-core: add dns-options property to NMSettingIPConfig')
(cherry picked from commit e8e5c12480)
(cherry picked from commit 04946f71ea)
(cherry picked from commit 098e713ced)
2020-09-29 09:29:51 +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
279998167a
contrib/rpm: opt out of LTO build for Fedora 33+
(cherry picked from commit 176996fccb)
2020-09-08 16:17:39 +02:00
Thomas Haller
e815592919
tests: ignore valgrind warning about unhandled syscalls
On Fedora rawhide (34), valgrind gives a lot of warnings like:

    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- WARNING: unhandled amd64-linux syscall: 439
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- You may be able to write your own handler.
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- Nevertheless we consider this a bug.  Please report
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- it at http://valgrind.org/support/bug_reports.html.

Ignore them.

(cherry picked from commit 2cb40f6e36)
(cherry picked from commit 561bd7bba6)
(cherry picked from commit 09b5a72b0f)
2020-09-08 15:40:24 +02:00
Thomas Haller
e333a28b97
glib: always re-implement g_steal_pointer()
g_steal_pointer() is marked as GLIB_AVAILABLE_STATIC_INLINE_IN_2_44,
that means we get a deprecated warning. Avoid that. We anyway
re-implement the macro so that we can use it before 2.44 and so
that it always does the typeof() cast.

(cherry picked from commit edfe9fa9a2)
(cherry picked from commit 6936a0613c)
2020-09-08 15:17:27 +02:00
Thomas Haller
2b28b9b276
ndisc/tests: merge branch 'th/ndisc-test-assertion-fixes'
(cherry picked from commit 1411f0135e)
2020-09-08 14:51:52 +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
8bbcc264d8
release: bump version to 1.22.17 (development) 2020-08-31 13:21:33 +02:00
Thomas Haller
38b144c5a3
release: bump version to 1.22.16 2020-08-31 13:21:33 +02:00
Thomas Haller
f197b8eccd
NEWS: update 2020-08-31 09:36: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
deb53ff5a2
gitlab-ci: fix workarounds for Ubuntu 16.04 in tests
The detection for Ubuntu 16.04 was broken. By now /etc/os-release
contains

    VERSION="16.04.7 LTS (Xenial Xerus)"

(cherry picked from commit 12e8557476)
(cherry picked from commit 9f7736ea8e)
(cherry picked from commit 89e01a1936)
2020-08-28 16:17:36 +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
Thomas Haller
ff8ba801f3
shared: add nm_utils_buf_utf8safe_escape_cp() helper
(cherry picked from commit 393bc8c8f6)
(cherry picked from commit 10b0260d19)
2020-08-28 12:28:05 +02:00
Thomas Haller
fef7d8467c
libnm: fix leak in nm_utils_is_json_object()
Fixes: 32f78ae6c3 ('libnm: expose nm_utils_is_json_object() utility function')
(cherry picked from commit 1cf11ccbca)
(cherry picked from commit 49ec86092b)
(cherry picked from commit 7db30ad811)
2020-08-28 12:27:13 +02:00
Frazer Clews
853f5ea79e
cloud-setup: fix nmcs_utils_poll argument ordering
the order of the arguments in the header and C file did not match

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/574
(cherry picked from commit 16abfca78a)
(cherry picked from commit 2fba8a3ece)
(cherry picked from commit fd6606c525)
2020-08-28 12:27:13 +02:00
Antonio Cardace
8181674bab
nmcs-http: remove the timeout once expired
libcurl's documentation for CURLMOPT_TIMERFUNCTION requires the
application to install a non-repeating timer.

https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html

So let's remove the GSource once expired.

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit e09bd2339a)
(cherry picked from commit b7d53f0d3a)
(cherry picked from commit 92bded74c4)
2020-08-28 12:22:39 +02:00
Antonio Cardace
e9f865b365
nmcs-http: fix multiple HTTP request bug
Since just a single pointer is used to store the socket's GSource
if more than 1 consecutive request was done through the same
HTTP provider the 2nd request would clear the GSource associated to
the second request causing the 1st HTTP request to never complete
and end up in a expired timeout.

Use a hashtable instead so we can correctly track all requests.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit 427fbc85f0)
(cherry picked from commit f5487645d8)
(cherry picked from commit fe3ddf3eff)
2020-08-28 12:20:38 +02:00
Beniamino Galvani
ae35fa83e3
cli: fix reference count handling in hotspot error path
The connection is automatically unreferenced when the function
returns.

Fixes: 9c5ea0917d ('devices: reuse the hotspot connection if we find appropriate one'):
(cherry picked from commit 3ecfd13ded)
(cherry picked from commit 26f1074d9d)
(cherry picked from commit 6281e32875)
2020-08-28 12:13:47 +02:00
Thomas Haller
63fb52a58a
cloud-setup: fix allocating buffer for GetConfigMetadataMac in _get_config_metadata_ready_check()
It's not a severe issue, because the GetConfigMetadataData struct is
larger than GetConfigMetadataMac.

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit 460afe6d50)
(cherry picked from commit 181fd5c611)
(cherry picked from commit 9fed652db4)
2020-08-28 12:10:11 +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
Beniamino Galvani
15156f5498
libnm: fix assertion in NML_IS_DBUS_OBJECT()
Reported by coverity:

>>> CID 210228: Null pointer dereferences (REVERSE_INULL)
>>> Null-checking "dbobj" suggests that it may be null, but it has
    already been dereferenced on all paths leading to the check.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
(cherry picked from commit 272f19108b)
(cherry picked from commit 144e7e40f0)
2020-08-28 12:04:41 +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
Thomas Haller
5ab7794266
tui: fix signature for nmt_newt_form_keypress_callback() callback
Fixes: 3bda3fb60c ('nmtui: initial import of nmtui')
(cherry picked from commit 38323216f5)
2020-08-28 11:37:03 +02:00
Thomas Haller
9ff160d155
tests: suppress valgrind warning about unsupported syscall for "test-config"
(cherry picked from commit d507563a80)
(cherry picked from commit 4036bc48e4)
2020-08-17 19:06:06 +02:00
Beniamino Galvani
7208f594f6 n-dhcp4: fix BPF filter endianness issue
The BPF filter takes the byte containing IP Flags and performs a
bitwise AND with "ntohs(IP_MF | IP_OFFMASK)".

On little-endian architectures the IP_MF flag (0x20) is ANDed with
0xFF3F and so the presence of the flag is correctly detected ignoring
other flags as IP_DF (0x40) or IP_RF (0x80).

On big-endian, "ntohs(IP_MF | IP_OFFMASK)" is 0x3FFF and so the filter
wrongly checks the presence of *any* flags. Therefore, a packet with
the DF flag set is dropped.

Instead, take the two bytes containing flags and offset:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

and verify that IP_MF and the offset are zero.

Fixes: e43b1791a3 ('Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4'')

https://bugzilla.redhat.com/show_bug.cgi?id=1861488
https://github.com/nettools/n-dhcp4/pull/19
(cherry picked from commit 03d38e83e558802a82cb0e4847cb1f1ef75ccd16)
(cherry picked from commit 0024cef238)
(cherry picked from commit 80835f8f89)
(cherry picked from commit 4588e2e817)
2020-08-04 16:30:11 +02:00
Beniamino Galvani
a9b3730bf2 ovs: merge branch 'bg/ovs-mac-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/557
(cherry picked from commit 15492e6c50)

(cherry picked from commit f819a7cabf)

(cherry picked from commit 8dc357dc11)
2020-07-21 10:19:11 +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
3c960a9f2b merge: branch 'bg/sleep-unmanaged-rh1855563'
https://bugzilla.redhat.com/show_bug.cgi?id=1855563
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/580

(cherry picked from commit 116c49fceb)

(cherry picked from commit 90cb61f8fd)

(cherry picked from commit 2dae6833ad)
2020-07-21 10:17:21 +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