Commit graph

24724 commits

Author SHA1 Message Date
Antonio Cardace
ffbc8fe2a8 nm-logging: fix stack-use-after-scope error detected by asan
asan error:

==6291==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffe6af12880 at pc 0x7fc8dd3321cd bp 0x7ffe6af11be0 sp 0x7ffe6af11388
READ of size 15 at 0x7ffe6af12880 thread T0
    #0 0x7fc8dd3321cc  (/lib64/libasan.so.5+0x4e1cc)
    #1 0x7fc8dcebcf29 in sd_journal_sendv ../src/journal/journal-send.c:226
    #2 0x74d834 in _nm_log_impl ../src/nm-logging.c:778
    #3 0x42485c in main ../src/main.c:379
    #4 0x7fc8dca1b1a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    #5 0x427e3d in _start (/work/NetworkManager/build/src/NetworkManager+0x427e3d)

Address 0x7ffe6af12880 is located in stack of thread T0 at offset 736 in frame
    #0 0x74c26f in _nm_log_impl ../src/nm-logging.c:663

  This frame has 9 object(s):
    [48, 56) 's_log_domains' (line 744)
    [80, 88) 'l_log_domains' (line 745)
    [112, 128) 'tv' (line 666)
    [144, 168) 'args' (line 664)
    [208, 240) 'g_copy' (line 670)
    [272, 312) 'cur_log_state_copy' (line 669)
    [352, 392) 'iov_free_data' (line 730)
    [432, 672) 'iov_data' (line 728)
    [736, 1024) 's_log_domains_buf' (line 743) <== Memory access at offset 736 is inside this variable

(cherry picked from commit 904050dd2d)
2020-02-22 12:22:51 +01:00
Thomas Haller
6f189da7b6 platform: avoid compiler warning in _NMP_OBJECT_TYPE_IS_OBJ_WITH_IFINDEX()
Surisingly, the compiler may detect the remaining obj_type in
the default switch. Then, inlining nmp_class_from_type() it may detect
that this is only possible to hit with an out or range access to
_nmp_classes array.

Rework the code to avoid that compiler warning. It's either way not
supposed to happen.

Also, drop the default switch case and explicitly list the enum values.
Otherwise it is error prone to forget a switch case.

(cherry picked from commit 9848589fbf)
2020-02-22 12:10:57 +01:00
Thomas Haller
139586c95c all: merge branch 'th/fix-gitlab-ci-failures'
(cherry picked from commit cb2c00d823)
2020-02-22 10:55:25 +01:00
Thomas Haller
c8f372b3a6 libnm-core/tests: avoid -Wstring-compare in unit test for NM_IN_SET()
Clang 10 doesn't like NM_IN_SET() with strings and is right about that:

    ../libnm-core/tests/test-general.c:7763:9: error: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Werror,-Wstring-compare]
            (void) NM_IN_SET ("a",  "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16");
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

However, NM_IN_STRSET() should work.

(cherry picked from commit c437d6c60a)
2020-02-22 10:50:07 +01:00
Thomas Haller
6e23a1b95d build: disable -Wimplicit-fallthrough warning with clang
Seems clang 10 got support for -Wimplicit-fallthrough, but does
not honor the code comments to suppress the warning. What a
disaster.

Try to detect it.

See-also: https://github.com/ClangBuiltLinux/linux/issues/   #636
See-also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e2079e93f562c7f7a030eb7642017ee5eabaaa10
(cherry picked from commit 86dfc4b099)
2020-02-22 10:50:07 +01:00
Thomas Haller
01fda25250 all: unify spelling of "fall-through" comment for switch statements
We used "/* fall through */" and "/* fall-through */" inconsistently.
Rename to use only one variant.

(cherry picked from commit ffa098edae)
2020-02-22 10:50:07 +01:00
Thomas Haller
f1a4961def gitlab-ci: add "t_fedora:32" and by default build on Fedora 31
(cherry picked from commit ec8068ec0c)
2020-02-22 10:50:02 +01:00
Thomas Haller
a9372112b9 tests: ignore valgrind warnings for unhandled syscalls in libnm,service-provider tests
Otherwise, we get test failures with valgrind on fedora:rawhide
(valgrind-3.15.0-18.fc33.x86_64.rpm, gcc-10.0.1-0.8.fc33.x86_64,
glib2-devel-2.63.5-3.fc33.x86_64):

    >>>> PRINT VALGRIND LOGS (valgrind test) (start)
    + find -name '*.valgrind-log' -print0
    + xargs -0 grep -H '^'
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- WARNING: unhandled amd64-linux syscall: 315
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- You may be able to write your own handler.
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- Nevertheless we consider this a bug.  Please report
    ./src/devices/wwan/tests/test-service-providers.valgrind-log:--95634-- it at http://valgrind.org/support/bug_reports.html.
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- WARNING: unhandled amd64-linux syscall: 315
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- You may be able to write your own handler.
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- Nevertheless we consider this a bug.  Please report
    ./libnm/tests/test-remote-settings-client.valgrind-log:--95245-- it at http://valgrind.org/support/bug_reports.html.
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- WARNING: unhandled amd64-linux syscall: 315
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- You may be able to write your own handler.
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- Nevertheless we consider this a bug.  Please report
    ./libnm/tests/test-secret-agent.valgrind-log:--95280-- it at http://valgrind.org/support/bug_reports.html.
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- WARNING: unhandled amd64-linux syscall: 315
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- You may be able to write your own handler.
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- Nevertheless we consider this a bug.  Please report
    ./libnm/tests/test-nm-client.valgrind-log:--95208-- it at http://valgrind.org/support/bug_reports.html.
    + echo '>>>> PRINT VALGRIND LOGS (valgrind test) (done)'
    >>>> PRINT VALGRIND LOGS (valgrind test) (done)

(cherry picked from commit 3e616c306d)
2020-02-22 10:50:02 +01:00
Antonio Cardace
ef786159c4 meson: add additional debug CFLAGS to use the same ones autotools uses
(cherry picked from commit 6dc8167588)
2020-02-22 10:45:36 +01:00
Thomas Haller
96f50cf9d8 build/autotools: fix passing AM_CFLAGS when building libnm-core
With `./configure --enable-more-asserts`, we add extra -W flags to
AM_CFLAGS. This variable is only used, if the per-library override
libnm_core_libnm_core_la_CFLAGS is unspecified ([1]).

Usually we avoid this problem be never specifying library_CFLAGS, but
placing all our per-library flags to library_CPPFLAGS. While that is a
bit of a hack and misuse of CPPFLAGS, it works well (enough).

This was broken recently. The effect was, that libnm-core was not
build with AM_CFLAGS flags. Fix it.

[1] https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

Fixes: d2d6a68697 ('build: use -fcommon when building libnm-core')
(cherry picked from commit 16df1c179d)
2020-02-21 10:12:24 +01:00
Thomas Haller
263e12c9d6 bond: merge branch 'th/bond-allow-arp-validate' (partial backport)
https://bugzilla.redhat.com/show_bug.cgi?id=1789437

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/418

(cherry picked from commit 1fbfbf743d)
2020-02-19 17:31:01 +01:00
Thomas Haller
02ba767496 device: allow setting "arp_validate" with supported bond modes
arp_validate is allowed for several bonding modes, at least since commit [1].

The validation was too strict. Just use set_bond_attr() directly, that
already correctly encodes whether to set the value or not.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=13ac34a8866e31b31db6237c73aa558aff84d765

(cherry picked from commit d9d51dd42d)
2020-02-19 17:30:15 +01:00
Beniamino Galvani
987c1d282a Revert "core: create virtual device on settings changes in idle handler"
When AddConnection() or Update() terminate, the (unrealized) virtual
device should be already be available, otherwise an activation attempt
of that connection can fail.

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

This reverts commit c163207b07.

(cherry picked from commit efc04b1285)
2020-02-19 10:06:21 +01:00
Thomas Haller
0c8046574e ifcfg: fix writer when changing OVS slave to clear previous settings
We need to reset the OVS_PORT and OVS_PORT_UUID variables.
Otherwise, clearing the slave type doesn't work.

On master this is solved differently, by automatically clearing all
variables that are not explicitly set.

Reproducer:

    nmcli con del t-eth1
    nmcli con add type ethernet autoconnect no ifname eth1 master port0 con-name t-eth1 slave-type ovs-port
    echo "
    remove ovs-interface
    remove connection.master
    remove connection.slave-type
    print
    save
    quit
    " | nmcli c edit t-eth1
    nmcli con show t-eth1 | grep 'ovs\|slave-type'

Fixes: 1440fe6a88 ('ifcfg: don't forget master of ovs interfaces')

https://bugzilla.redhat.com/show_bug.cgi?id=1804167
2020-02-18 18:37:45 +01:00
Antonio Cardace
6e12b31d1f release: bump version to 1.22.9 (development) 2020-02-18 16:49:55 +01:00
Antonio Cardace
fa6c656473 release: bump version to 1.22.8 2020-02-18 16:48:01 +01:00
Antonio Cardace
24977b55c8 release: update NEWS 2020-02-18 16:46:35 +01:00
Thomas Haller
82237a3344 shared/trivial: add code comment to nm_utils_ifname_valid_kernel()
(cherry picked from commit eb74d5f65f)
2020-02-18 13:28:49 +01:00
Thomas Haller
9bbb021b4f shared: check for valid UTF-8 in nm_utils_ifname_valid()
The interface name might come from the command line or from a filename
(like during nm_vpn_wireguard_import()). It's not clear that this
is valid UTF-8. Asserting against that requires the caller to ensure
that the encoding is valid. That is cumbersome, especially since we anyway
check. Just report a regular error.

(cherry picked from commit 82fb8b00b4)
2020-02-18 13:28:48 +01:00
Antonio Cardace
88d0d80d09 nm-shared-utils: relax ovs ifname check to accept any (non-space) ASCII printable char
quoting 'man ovs-vswitchd.conf.db':
"The name must be alphanumeric and must not contain forward or backward
slashes."

OVS actually accepts a wider range of chars (all printable UTF-8 chars),
NetworkManager restricts this to ASCII char as it's a safer option for
now since OVS is not well documented on this matter.

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

Fixes: e7d72a14f6 ('libnm-core: use different ifname validation function for OVS bridges, ports and interfaces')
(cherry picked from commit ed5a647ad1)
2020-02-18 13:12:59 +01:00
Beniamino Galvani
53b878818c ovs: merge branch 'bg/ovs-deactivate-async-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1787989
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/412
(cherry picked from commit e24fd88494)
2020-02-17 19:08:48 +01:00
Beniamino Galvani
c4eb0c6852 ovs: discard link updates when deactivating
When the ovs interface gets deactivated, it is released from the
master port and we call nm_device_update_from_platform_link (dev,
NULL) to ignore any later event for the interface. This is important
especially because it sets a zero ifindex on the interface and so,
later when the link disappears, we don't unmanage the device but
directly remove it.

However, since ovs commands are queued, the link could appear during
the deactivation and we need to ignore such events. Add a new device
method can_update_from_platform_link() for such purpose.

(cherry picked from commit e9fc1dea43)
2020-02-17 19:08:21 +01:00
Beniamino Galvani
2e5e409bf2 ovs: rework asynchronous deactivation of ovs interfaces
Tracking the deletion of link by ifindex is difficult because the
ifindex of the device is updated through delayed (idle) calls in
NMDevice and so there is the possibility that at a certain time the
device ifindex is not in sync with platform state. It seems simpler to
watch instead the interface name. The ugly thing is that the interface
name can be changed externally, but if users do that on an activating
device they are looking for trouble.

Also change the deactivate code to deal with the scenario where we
already created the interface in the ovsdb but the link didn't show up
yet. To ensure a proper cleanup we must wait that the link appears and
then goes away; however the link may never appear if vswitchd sees
only the last state in ovsdb, and so we must use a ugly timeout to
avoid waiting forever.

https://bugzilla.redhat.com/show_bug.cgi?id=1787989
(cherry picked from commit 9c49f8a879)
2020-02-17 19:08:20 +01:00
Beniamino Galvani
644151b07a n-dhcp4: request previous address after expiration
If the lease expires and the client start again sending a discover,
request the previous address.

(cherry picked from commit 3286918bd9)
2020-02-17 19:07:36 +01:00
Thomas Haller
b1dcfcb7b7 shared: fix returning out_len from nm_utils_hash_values_to_array()
The only affected caller is nm_modem_manager_get_modems(), which
is used by NMDeviceBt for DUN connections. This is rather bad.

Fixes: 4154d9618c ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data')
Fixes: e688e70b37 ('shared: add nm_utils_hash_values_to_array() helper')
(cherry picked from commit 037507f790)
2020-02-17 17:55:52 +01:00
Antonio Cardace
4200d0a85b Merge branch 'ac/ovs_ifname_length' into 'master'
[ac/ovs ifname length]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/408

(cherry picked from commit 63eabe0dbf)
2020-02-17 17:34:49 +01:00
Antonio Cardace
a44fa6c689 libnm-core: use different ifname validation function for OVS bridges, ports and interfaces
OVS bridges and ports do not have the length limitation of 15 bytes, the
only requirements are that all chars must be alphanumeric and not be
forward or backward slashes.

For OVS interfaces only 'patch' types do not have the length limit, all
the other types do (according to whether they have a corresponding
kernel link or not).

Add related unit test.

https://bugzilla.redhat.com/show_bug.cgi?id=1788432
(cherry picked from commit e7d72a14f6)
2020-02-17 17:31:31 +01:00
Antonio Cardace
1a4b59a7c3 nm-setting-ovs-interface: remove unneeded check on 'self'
'self' is guaranteed of being not-NULL since we have the
assertion 'g_return_val_if_fail (NM_IS_SETTING_OVS_INTERFACE (self),FALSE);'
at the beginning of the function.

(cherry picked from commit 15e87b80f3)
2020-02-17 17:28:15 +01:00
Antonio Cardace
30d329567c libnm-core: add assertion for valid 'error' argument in nm_utils_is_valid_iface_name()
(cherry picked from commit 72f7ad75dc)
2020-02-17 17:28:15 +01:00
Antonio Cardace
c3b0f1d4f5 all: use nm_utils_ifname_valid_kernel() instead of nm_utils_is_valid_iface_name()
nm_utils_is_valid_iface_name() is a public API of libnm-core, let's use
our internal API.

$ sed -i 's/\<nm_utils_is_valid_iface_name\>/nm_utils_ifname_valid_kernel/g' $(git grep -l nm_utils_is_valid_iface_name)

(cherry picked from commit 6e9a36ab9f)
2020-02-17 17:28:14 +01:00
Antonio Cardace
2cf568bd8f nm-shared-utils: add nm_utils_ifname_valid*() to shared utils
Move the body of nm_utils_is_valid_iface_name() to
nm_utils_ifname_valid_kernel() so that it's shared between NM and
clients.

(cherry picked from commit 550f538564)
2020-02-17 17:26:47 +01:00
Antonio Cardace
5fb293cfc6 nmcli: remove interface length check in nmcli
nmcli should not perform checks on the interface name length,
this kind of operations should only be performed by the NetworkManager
daemon and not be duplicated inside cli applications.

(cherry picked from commit 15a8595575)
2020-02-17 17:25:52 +01:00
Antonio Cardace
816aacc4c2 nm-device-factory: remove ifname check as it prevents activating OVS connections
(cherry picked from commit 0cac094c93)
2020-02-17 17:25:52 +01:00
Antonio Cardace
e52fccb0d0 nm-dhcp-client: use nm_assert() to check ifname
so that it gets compiled out in production builds, this check is
carried out anyway when the connection is created.

(cherry picked from commit 9e27252c27)
2020-02-17 17:25:52 +01:00
Thomas Haller
91b2be2e1b all: merge branch 'th/ra-timeout'
https://bugzilla.redhat.com/show_bug.cgi?id=1801158

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/414

(cherry picked from commit 4c993f6bbb)
2020-02-17 15:12:30 +01:00
Thomas Haller
8d04ae1e84 version: add NM_VERSION_1_22_8/NM_AVAILABLE_IN_1_22_8 macros 2020-02-17 15:06:10 +01:00
Thomas Haller
f259b4b6c0 ndisc: implement "ipv6.ra-timeout" property
(cherry picked from commit 9dde86d02c)
2020-02-17 15:06:10 +01:00
Thomas Haller
1f4c8a0f54 ndisc: rename NM_NDISC_RA_TIMEOUT signal to NM_NDISC_RA_TIMEOUT_SIGNAL
We will add a property NM_NDISC_RA_TIMEOUT for which this name is better
suited. The problem is really that our convention for object properties
and signals defines have no prefix to indicate whether it's a property
or a signal.

Rename.

(cherry picked from commit 10f0253f2e)
2020-02-17 15:06:10 +01:00
Thomas Haller
7c86bc9c97 ndisc: improve logging message with nm_ndisc_start() and minor cleanup
(cherry picked from commit b2e30b3c9a)
2020-02-17 15:06:10 +01:00
Thomas Haller
c1b640da2d libnm,cli,ifcfg-rh: add ipv6.ra-timeout configuration option
(cherry picked from commit de4aeb34e3)
2020-02-17 15:06:10 +01:00
Thomas Haller
8985917c9e cli: add support for "ipv6.dhcp-timeout" property
It was internally supported, but not by nmcli.

(cherry picked from commit 0d8f55a1cb)
2020-02-17 15:06:10 +01:00
Thomas Haller
60ef3a3e59 ifcfg-rh: belatedly add support for "ipv6.dhcp-timeout" setting
(cherry picked from commit 843c546b84)
2020-02-17 15:06:10 +01:00
Thomas Haller
fe6c3f0867 ifcfg-rh: fix potential crash with variadic argument make_ip6_setting()
It is undefined behavior and can lead to crashes or memory corruption.
In practice, this only had an issue on Big Endian systems.

Fixes: fdbf4ae5e6 ('ifcfg-rh: add IPV4_DHCP_TIMEOUT key for ipv4.dhcp-timeout property')
(cherry picked from commit 9b82d29f5f)
2020-02-17 15:06:10 +01:00
Thomas Haller
7751f853c3 ifcfg-rh: inline unnecessary function write_ip6_setting_dhcp_hostname()
If a function is only called once, it may not help to simplify the code
but make it more complicated. It would only simplify the code, if it
had a clear, distinct purpose. That isn't the case here. Also, the
IPv4 writer doesn't have such a function either. Drop and inline it.

(cherry picked from commit d06092acbd)
2020-02-17 15:06:10 +01:00
Thomas Haller
2ed1a6803e device: don't schedule grace timeout if dhcp-timeout is infinity
It feels wrong to schedule a timeout with G_MAXUINT32, if we actually
disabled the timeout. Of course, in practice there should be little
difference.

(cherry picked from commit 4c101f36ec)
2020-02-17 15:06:10 +01:00
Thomas Haller
bd02523b6b device/trivial: rename get_dhcp_timeout() virtual function to have a unique name
This is C, we have almost no IDE support. And ctags/cscope is much more
helpful if we use unique names.

Don't use the get_dhcp_timeout() name, because that is already used in
"src/devices/nm-device.c" already. Rename.

(cherry picked from commit be4129bb2d)
2020-02-17 15:06:10 +01:00
Thomas Haller
fb1b8de4d7 libnm/doc: explain values for dhcp-timeout setting
(cherry picked from commit e34db042af)
2020-02-17 15:06:10 +01:00
Antonio Cardace
a2a2bf5206 man: fix missing tag
(cherry picked from commit 1ccdce0c1d)
2020-02-17 14:35:15 +01:00
Antonio Cardace
83d5368a19 man: add dnsmasq option documentation on added dns servers
(cherry picked from commit 7ef684b1b3)
2020-02-17 14:35:09 +01:00
Thomas Haller
501893c4bc man: document connectivity.enabled option in NetworkManager.conf manual
(cherry picked from commit 655e1aa97f)
2020-02-17 14:34:59 +01:00