Commit graph

25101 commits

Author SHA1 Message Date
Thomas Haller
f12b830a94 gitlab-ci: fix deploying documentation after switching to Fedora 31
Fixes: ec8068ec0c ('gitlab-ci: add "t_fedora:32" and by default build on Fedora 31')
2020-02-22 13:57:56 +01:00
Thomas Haller
9848589fbf 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.
2020-02-22 12:09:56 +01:00
Thomas Haller
fd0d292caf platform: belatedly add NMP_OBJECT_TYPE_LNK_VRF to _NMP_OBJECT_TYPE_IS_OBJ_WITH_IFINDEX()
Fixes: 7c73c6a038 ('platform: add VRF support')
2020-02-22 12:09:56 +01:00
Thomas Haller
46bc6d93d6 release: bump version to 1.23.2-dev 2020-02-21 20:35:02 +01:00
Thomas Haller
cb2c00d823 all: merge branch 'th/fix-gitlab-ci-failures' 2020-02-21 20:34:34 +01:00
Thomas Haller
c437d6c60a 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.
2020-02-21 18:27:40 +01:00
Thomas Haller
86dfc4b099 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
2020-02-21 18:27:40 +01:00
Thomas Haller
ffa098edae all: unify spelling of "fall-through" comment for switch statements
We used "/* fall through */" and "/* fall-through */" inconsistently.
Rename to use only one variant.
2020-02-21 18:24:25 +01:00
Thomas Haller
95891e78e7 build/meson: fix missing dependency when building nm-libnm-aux
[351/932] Compiling C object libnm/fdede0a@@nm-libnm-aux@sta/.._shared_nm-libnm-aux_nm-libnm-aux.c.o.
    FAILED: libnm/fdede0a@@nm-libnm-aux@sta/.._shared_nm-libnm-aux_nm-libnm-aux.c.o
    gcc -Ilibnm/fdede0a@@nm-libnm-aux@sta -Ilibnm -I../libnm -Ilibnm-core -I../libnm-core -I. -I../ -Ishared -I../shared -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=gnu11 -O2 -g -Wall -Wextra -Wdeclaration-after-statement -Wfloat-equal -Wformat-nonliteral -Wformat-security -Wimplicit-fallthrough -Wimplicit-function-declaration -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wpointer-arith -Wshadow -Wshift-negative-value -Wstrict-prototypes -Wundef -Wvla -Wno-duplicate-decl-specifier -Wno-format-truncation -Wno-format-y2k -Wno-missing-field-initializers -Wno-pragmas -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-parameter -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -fno-strict-aliasing -fPIC -pthread -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 -DG_LOG_DOMAIN=libnmc -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_CLIENT -MD -MQ libnm/fdede0a@@nm-libnm-aux@sta/.._shared_nm-libnm-aux_nm-libnm-aux.c.o -MF libnm/fdede0a@@nm-libnm-aux@sta/.._shared_nm-libnm-aux_nm-libnm-aux.c.o.d -o libnm/fdede0a@@nm-libnm-aux@sta/.._shared_nm-libnm-aux_nm-libnm-aux.c.o -c ../shared/nm-libnm-aux/nm-libnm-aux.c
    In file included from ../libnm-core/nm-connection.h:14,
                     from ../libnm/nm-types.h:12,
                     from ../libnm/nm-object.h:14,
                     from ../libnm/nm-access-point.h:14,
                     from ../libnm/NetworkManager.h:11,
                     from ../shared/nm-default.h:288,
                     from ../shared/nm-libnm-aux/nm-libnm-aux.c:3:
    ../libnm-core/nm-core-types.h:13:10: fatal error: nm-core-enum-types.h: No such file or directory
       13 | #include "nm-core-enum-types.h"
          |          ^~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
2020-02-21 18:24:25 +01:00
Thomas Haller
ec8068ec0c gitlab-ci: add "t_fedora:32" and by default build on Fedora 31 2020-02-21 18:24:25 +01:00
Thomas Haller
3e616c306d 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)
2020-02-21 18:24:25 +01:00
Thomas Haller
b4e48b5ce5 license: minor spelling fixes in RELICENSE.md 2020-02-21 17:52:28 +01:00
Thomas Haller
eeec6ecc7d license: add Robert to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-February/msg00019.html
2020-02-21 17:43:07 +01:00
Beniamino Galvani
cf6940665d shared: add more debug messages to nm_utils_parse_inaddr_bin_full()
Log the reason for the assertion failure to debug the crash in [1].

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1797915
2020-02-21 16:54:53 +01:00
Thomas Haller
cfa2981271 core: merge branch 'th/nm-dhcp-config-merge'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/423
2020-02-21 16:01:20 +01:00
Thomas Haller
121d446354 device: merge nm_device_get_dhcp[46]_config() to nm_device_get_dhcp_config() 2020-02-21 15:59:44 +01:00
Thomas Haller
26f208aec3 core: add common base class NMDhcpConfig for NMDhcp[46]Config and merge them
The advantage is that the API is now the same for IPv4 and IPv6: it's
all nm_dhcp_config_*() and we can (easier) treat the address family
generically.

We still need two distinct GObject types, mainly because of the
glue code for exposing the object on D-Bus as NMDBusObject. Of course,
that could be solved differently, but as it is, it's quite nice.
2020-02-21 15:59:44 +01:00
Thomas Haller
cd03d39a6d core: rename "nm-dhcp4-config.[ch]" to "nm-dhcp-config.[hc]" before merge
NMDhcp4Config and NMDhcp6Config will get a common base type NMDhcpConfig
and be merged. In preparation, rename the file.
2020-02-21 15:59:44 +01:00
Thomas Haller
c8d043dd94 core: avoid duplicate lookup in nm_utils_strdict_to_variant()
Collect the full list of key and values, while sorting the key.
This way, we don't need to lookup the values by key later.
2020-02-21 15:59:44 +01:00
Thomas Haller
f13c7e3bbd shared: extend NM_GOBJECT_PROPERTIES_DEFINE*() macros to append suffix to defined names
This way, we will be able to use the macro multiple times in the same
source file by using different suffixes.
2020-02-21 15:59:44 +01:00
Thomas Haller
d07a85a2f9 platform: merge branch 'th/platform-link-type-metadata'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/421
2020-02-21 15:34:49 +01:00
Thomas Haller
6dcb4bd308 platform: use nm_streq() instead of strcmp() 2020-02-21 15:31:22 +01:00
Thomas Haller
acb397c995 platform: use binary search to lookup NMLinkType for devtype 2020-02-21 15:31:22 +01:00
Thomas Haller
19ad044359 platform: use binary search to lookup NMLinkType for rtnl_type 2020-02-21 15:31:22 +01:00
Thomas Haller
4f5e3765b0 platform: index LinkDesc array by NMLinkType
No need to iterate over the whole array, when we can just index
it by the link type that we look for.
2020-02-21 15:31:22 +01:00
Thomas Haller
6db35d95a5 platform: don't assign meaning to NMLinkType numeric values
It would be better if we would be able to use NMLinkType enum
as an index (e.g. into an array of LinkDesc structures). For that,
it is necessary that the enum is just consecutive numbers.

Don't assign special meaning to the enum. Also, this was only
used at two places, that we can solve differently.
2020-02-21 15:31:22 +01:00
Thomas Haller
4f9f228fed libnm: disable "-Wtautological-constant-out-of-range-compare" warning with clang
Seen on Debian 9, clang-3.8 (1:3.8.1-24):

    ../libnm-core/nm-setting-bond.c:596:49: error: comparison of constant 32 with expression of type 'NMBondMode' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
            nm_assert (_NM_INT_NOT_NEGATIVE (mode) && mode < 32);
                                                      ~~~~ ^ ~~

This warning is not useful. While it may be implementation defined how enum
values outside the defined ones are handled, we commonly rely on placing
special numeric values in enums (e.g. ((NMEnumType) -1)).

An enum is (with our compilers) just a glorified integer, and there is nothing
preventing it from being outside the enum values. The warning is not helpful
and outright wrong. Disable it.

See-also: https://bugs.llvm.org//show_bug.cgi?id=16154

Fixes: 957bb2e111 ('libnm: use binary search for _nm_setting_bond_option_supported() implementation')
2020-02-21 10:43:55 +01:00
Thomas Haller
16df1c179d 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')
2020-02-21 10:07:54 +01:00
Thomas Haller
1bc5a7c778 contrib/scripts: add "checkpatch-git-post-commit-hook" script to contrib/
This can be used as git post-commit hook.
2020-02-21 07:40:10 +01:00
Antonio Cardace
2b0689b9ae nm-setting-bond: do not shadow stack variable with same name
GCC complains about this when compiling with -Wshadow

Fixes: 8775c25c33 ('libnm: verify bond option in defined order')
2020-02-21 07:30:21 +01:00
Yuri Chornoivan
ce59e749fb po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/420
2020-02-20 15:26:31 +01:00
Thomas Haller
1fbfbf743d bond: merge branch 'th/bond-allow-arp-validate'
https://bugzilla.redhat.com/show_bug.cgi?id=1789437

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/418
2020-02-19 17:28:33 +01:00
Thomas Haller
8775c25c33 libnm: verify bond option in defined order
verify() should validate options in a deterministic order, so that
the same profile (with same libnm version) gives the same failure
reason every time.

Hence, visit the options in sorted order, like we do for nm_setting_bond_get_option().
2020-02-19 17:15:26 +01:00
Thomas Haller
ae1008b239 libnm: sort "mode" in nm_setting_bond_get_option() first
Internally, the options are tracked in a hash table and of undefined
sort order. However, nm_setting_bond_get_option() always returns a stable
(sorted) order.

Move "mode" as first, because that is usually the most interesting option.

The effect is:

  $ nmcli -o connection show "$BOND_PROFILE"
  ...
  -bond.options:  arp_interval=5,arp_ip_target=192.168.7.7,arp_validate=active,mode=balance-rr,use_carrier=0
  +bond.options:  mode=balance-rr,arp_interval=5,arp_ip_target=192.168.7.7,arp_validate=active,use_carrier=0

This doesn't affect keyfile, which sorts the hash keys themself (and
doesn't treat the "mode" special).

This however does affect ifcfg-rh writer how it writes the BONDING_OPTS
variable. I think this change is fine and preferable.
2020-02-19 17:15:26 +01:00
Thomas Haller
5ccab333d0 libnm: cleanup string comparison in "nm-setting-bond.c"
strcmp() is hard to understand visually. Especially when different patterns
are mixed, like:

    if (   !strcmp (name, NM_SETTING_BOND_OPTION_MIIMON)
        && strcmp (value, "0") != 0) {
2020-02-19 17:15:26 +01:00
Thomas Haller
18c8f43c34 libnm: use binary search for finding bond options to validate 2020-02-19 17:15:26 +01:00
Thomas Haller
957bb2e111 libnm: use binary search for _nm_setting_bond_option_supported() implementation 2020-02-19 16:24:55 +01:00
Thomas Haller
cba938f3ee shared: add nm_utils_named_values_from_str_dict_full() to allow different sort order (or none) 2020-02-19 16:24:55 +01:00
Thomas Haller
f4d12f7b59 shared: add NM_UTILS_STRING_TABLE_LOOKUP_STRUCT_DEFINE() macro for lookup of structs 2020-02-19 15:35:07 +01:00
Thomas Haller
14461e7217 shared: add NM_MORE_ASSERT_ONCE() macro 2020-02-19 15:35:07 +01:00
Thomas Haller
d9d51dd42d 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
2020-02-19 10:39:55 +01:00
Beniamino Galvani
efc04b1285 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.
2020-02-19 10:03:58 +01:00
Thomas Haller
eb74d5f65f shared/trivial: add code comment to nm_utils_ifname_valid_kernel() 2020-02-18 13:23:50 +01:00
Thomas Haller
82fb8b00b4 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.
2020-02-18 13:23:50 +01:00
Antonio Cardace
ed5a647ad1 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')
2020-02-18 13:11:21 +01:00
Beniamino Galvani
82697358e3 device: fix handling of DHCP grace period
'grace_pending' was never initialized.

Fixes: 0c52c18b56 ('device: unify handling of grace-period for DHCPv4 and DHCPv6 (2)')
2020-02-18 09:59:32 +01:00
Beniamino Galvani
e24fd88494 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
2020-02-17 19:03:42 +01:00
Beniamino Galvani
e9fc1dea43 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.
2020-02-17 19:03:29 +01:00
Beniamino Galvani
9c49f8a879 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
2020-02-17 19:03:29 +01:00
Beniamino Galvani
3286918bd9 n-dhcp4: request previous address after expiration
If the lease expires and the client start again sending a discover,
request the previous address.
2020-02-17 18:58:47 +01:00