Commit graph

27414 commits

Author SHA1 Message Date
Beniamino Galvani
785aef7103 device: log dns resolver state as string 2020-12-17 14:32:31 +01:00
Beniamino Galvani
ec7d8ddb29 ovs: fix leaks
Fixes: 1eeca3c606 ('core/ovs: track external-ids for cached ovsdb objects')
2020-12-15 10:59:31 +01:00
Beniamino Galvani
a60ea8af7d merge branch 'ffmancera/eth_prio'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/707
2020-12-14 18:08:48 +01:00
Fernando Fernandez Mancera
b19b800c95 libnm: adjust nm_device_get_type_description for Veth
Veth interfaces should be shown as Ethernet from
nm_device_get_type_description in order to provide backward
compatibility.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-12-14 17:35:07 +01:00
Fernando Fernandez Mancera
3dc202579e libnm: NMDeviceEthernet uses PRIO_20 instead of PRIO_30
As NMDeviceVeth has a NMDeviceEthernet as parent, it should use PRIO_20
in order to report NMDeviceVeth when configured and do not report
NMDeviceEthernet.

An unit test case has been added.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2020-12-14 17:35:07 +01:00
Beniamino Galvani
c7a470dd66 release: bump version to 1.29.6 (development) 2020-12-14 15:29:03 +01:00
Beniamino Galvani
53fa956004 Revert "ovs: clean up interfaces from ovsdb at startup"
The commit breaks ovs system interfaces on daemon restart. Revert the
change until a better solution is found.

This reverts commit e5113a7fd9.
2020-12-14 13:35:34 +01:00
Thomas Haller
590211a669
merge branch 'th/gitlab-ci-alpine' (part 2)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/704
2020-12-13 21:26:00 +01:00
Rasmus Thomsen
6a009610a6
systemd: don't use qsort_r() on musl
[thaller@redhat.com: modified original patch]
2020-12-13 21:25:46 +01:00
Rasmus Thomsen
b28c9e4535
systemd: add missing definitions for __compar_d_fn_t with musl 2020-12-13 21:25:46 +01:00
Thomas Haller
4cf41a43fd
systemd: don't include <printf.h>
It doesn't exist on alpine/musl.
2020-12-13 21:25:39 +01:00
Thomas Haller
d828f5b021
systemd: include <fcntl.h> instead of <sys/fctnl.h>
On alpine/musl we get a compiler warning:

    CC       shared/systemd/src/basic/libnm_systemd_shared_la-env-file.lo
  In file included from ../shared/systemd/src/basic/fileio.h:9,
                   from ../shared/systemd/src/basic/env-file.c:10:
  /usr/include/sys/fcntl.h:1:2: error: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Werror=cpp]
      1 | #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
        |  ^~~~~~~
2020-12-13 17:10:54 +01:00
Rasmus Thomsen
d38b5d92ee
shared/nm-glib-aux: don't use RTLD_DEEPBIND on musl
[thaller@redhat.com: original patch modified]
2020-12-13 17:10:53 +01:00
Thomas Haller
712516f2ac
shared: fix _POSIX_C_SOURCE not being defined for nm-errno.c
This is the case with musl.

Based-on-patch-by: Rasmus Thomsen <oss@cogitri.dev>
2020-12-13 17:10:53 +01:00
Thomas Haller
ba4142b328
libnm: replace <netinet/ether.h> by <net/ethernet.h>/<net/if_arp.h> in "nm-utils.c"
Including <netinet/ether.h> with musl leads to a conflict with <linux/if_ether.h>,
due to redefining ethhdr struct. As we include <linux/if_ether.h> in "nm-utils.h",
that is a problem.

Avoid that, by including other headers.
2020-12-13 17:07:42 +01:00
Thomas Haller
7f4a7bf433
all: remove unnecessary <netinet/ether.h> includes
<netinet/ether.h> with musl defines ethhdr struct, which conflicts
with <linux/if_ether.h>. The latter is included by "nm-utils.h",
so this is a problem.

Drop includes of "netinet/ether.h" that are not necessary.
2020-12-13 16:56:51 +01:00
Thomas Haller
0a730fe0ea
core: log whether assertions are enabled for the build 2020-12-11 18:41:47 +01:00
Thomas Haller
344247cdc1
gitlab-ci: merge branch 'th/gitlab-ci-alpine' (part 1)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/704
2020-12-11 18:28:26 +01:00
Thomas Haller
a1002bd93a
gitlab-ci: enable test build on alpine linux
Alpine is especially interesting because it uses musl as libc.

The build does not yet succeed. There are several issues that
need to be fixed.

However, it will be simpler to fix things, if we have tests
in place -- even if at the moment they are known to be broken.

See-also: https://git.alpinelinux.org/aports/tree/community/networkmanager?h=master
2020-12-11 18:14:10 +01:00
Thomas Haller
a6e234349c
gitlab-ci: update used "ci-templates" version 2020-12-11 18:14:10 +01:00
Thomas Haller
4ce62b6df3
gitlab-ci: fix failure to enable PowerTools on CentOS8 build
Seems that the repository was renamed (or can sometimes have
a different name). Try both the "PowerTools" and "powertools" name.
2020-12-11 18:06:52 +01:00
Thomas Haller
77a6fde1e2
man,cloud-setup: merge branch 'th/man-nm-cloud-setup'
https://bugzilla.redhat.com/show_bug.cgi?id=1867997
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/600

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/701
2020-12-11 17:37:56 +01:00
Thomas Haller
a4f1fa0893
man: add man 8 nm-cloud-setup
https://bugzilla.redhat.com/show_bug.cgi?id=1867997
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/ ## 600
2020-12-11 17:36:38 +01:00
Thomas Haller
be8a3f9902
cloud-setup: simplify cancellation in _get_config_fetch_cancelled_cb()
If we call g_cancellable_connect() on a GCancellable that is already
cancelled, then the callback is invoked synchronously. We need to
handle that.

However, we can slightly simplify the code. There is no change in
behavior, but we can always let the cancelled callback return the
result.
2020-12-11 17:36:37 +01:00
Thomas Haller
422ab25626
cloud-setup: in EC2's _get_config_task_maybe_return() cancel internal requests on any error
"iface_data->cancellable" is an internal cancellable for the parallel
HTTP requests. Once we encounter a failure, those requests are all
obsolete and must be cancelled.
2020-12-11 17:36:37 +01:00
Thomas Haller
399c04e810
cloud-setup: fix handling cancellation of internal GET operation for EC2 provider
There are two GCancellable at work: one is provided by the user
during nmcs_provider_get_config(), and one is used internally for the
individual HTTP GET requests.

In _get_config_fetch_done_cb(), if the error reason is "cancelled",
then it means that our internal iface_data->cancellable was cancelled.
Probably because an error happend (like a timeout or the user cancelled
the external GCancellable).

In that case, we must not report that the task completed with a
cancellation, because we need to preserve the error that was the
original cause.
2020-12-11 17:36:37 +01:00
Thomas Haller
d07cd5dbf2
all: avoid GNU "which" from shell scripts
"which" is a separate package and may not be installed.
Also, shell has a built-in command for the same purpose.
Use that.
2020-12-11 16:42:23 +01:00
Thomas Haller
b9d4026f85
tools: improve detection of "ci-fairy" command in "tools/check-gitlab-ci.sh"
The previous implementation would print

    ./tools/check-gitlab-ci.sh: line 22: ci-fairy: command not found

also, it's not nice to execute the program, just to find out whether
we have it.
2020-12-11 16:08:47 +01:00
Thomas Haller
3c39ab8836
tests: skip "check-local-gitlab-ci" test on gitlab-ci 2020-12-11 16:08:47 +01:00
Thomas Haller
76f3cf41ac
tests: allow to skip check-local-gitlab-ci via "$NMTST_SKIP_CHECK_GITLAB_CI"
This will be used on our gitlab-ci tests. We do have a separate,
dedicated test on gitlab-ci for checking that "gitlab-ci.yml" is
correct.

We may intentionally want to violate that condition, but then our
`make check` should not fail.

Add a way to skip that test.
2020-12-11 16:08:46 +01:00
Thomas Haller
e5699dbcb7
libnm: suppress "-Warray-bounds" warning in nm_team_link_watcher_new_ethtool()
gcc-11.0.0-0.7.fc34 warns here:

    CC       libnm-core/libnm_core_la-nm-setting-team.lo
  libnm-core/nm-setting-team.c: In function ‘nm_team_link_watcher_new_ethtool’:
  libnm-core/nm-setting-team.c:127:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
    127 |     watcher->ref_count          = 1;
        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
  libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
    125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  libnm-core/nm-setting-team.c:128:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
    128 |     watcher->type               = LINK_WATCHER_ETHTOOL;
        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
  libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
    125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  libnm-core/nm-setting-team.c:129:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
    129 |     watcher->ethtool.delay_up   = delay_up;
        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
  libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
    125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  libnm-core/nm-setting-team.c:130:33: error: array subscript ‘NMTeamLinkWatcher[0]’ is partly outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
    130 |     watcher->ethtool.delay_down = delay_down;
        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
  libnm-core/nm-setting-team.c:125:15: note: referencing an object of size 16 allocated by ‘g_malloc’
    125 |     watcher = g_malloc(nm_offsetofend(NMTeamLinkWatcher, ethtool));
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Maybe we should not use this trick and just malloc() a struct of the
intended size, however:

 - the code below does a similar thing, doing it differently for ethtool
   watcher is confusing.

 - the NMTeamLinkWatcher is a union which cannot alter its type. In no
   case is it correct to access the fields of the wrong union type. By
   allocating a smaller chunk, valgrind might catch such bugs.
   Also, NMTeamLinkWatcher's definition is private to the C source file,
   in no case must anybody assume that the rest of the buffer actually
   exists.

Hence, workaround the warning by suppressing it.
2020-12-11 16:08:46 +01:00
Thomas Haller
bba81ca13c
libnm: merge branch 'th/ovs-external-ids-for-system-interface'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/702
2020-12-11 09:38:45 +01:00
Thomas Haller
9cc242596d
libnm: allow OVS external-ids also for system interface
Note that reapply currently does not work for OVS system interface.
That is, because the code does not make it easy to implement that.
2020-12-11 09:38:16 +01:00
Thomas Haller
a9bc3eecc6
libnm: move detection/normalization of "connection.slave-type" to a separate function
We allow normalizing the slave-type, but sometimes, we may want to
validate a profile according to the set slave-type.

For example, a "ovs-external-ids" setting should only be allowed for
"connection.slave-type=ovs-interface". But during verify, the slave-type
may be missing and not yet normalized. We need to be able to obtain
the actually used slave-type.
2020-12-11 09:38:12 +01:00
Thomas Haller
e5b8fad96e
build: merge branch 'maxice8:reallocarray-in-stdlib' into master
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/703
2020-12-10 12:36:45 +01:00
Leo
c992f460c7
build: check for reallocarray in stdlib.h 2020-12-10 12:36:38 +01:00
Leo
5e01c87cad
build/meson: check for reallocarray in stdlib.h too
musl added support for reallocarray, but the function prototype is
declared in stdlib.h instead of malloc.h.

Update the check for reallocarray to check both in malloc.h and
stdlib.h.

https://man7.org/linux/man-pages/man3/reallocarray.3.html
2020-12-10 12:36:37 +01:00
Thomas Haller
8cadfed2fe
wifi: fix evaluating the scanning state for wpa-supplicant
wpa_supplicant has a property "scanning" and a "state=scanning".
Previously, NetworkManager considered both parts to indicate whether
supplicant is currently scanning (if either the property or the state
indicated scanning, it took that as indication for scanning).

If NetworkManager thinks that supplicant is scanning, it suppresses
explicit "Scan" requests. That alone is not severe, because the "Scan"
request is only to trigger a scan in supplicant (which supplicant
possibly is already doing in state "scanning").

However, what is severe is that NetworkManager will also block autoconnect
while supplicant is scanning. That is because NetworkManager wants to get
a complete scan result before deciding which network to connect to.

It seems that wpa_supplicant can get into "state=scanning" and stay
there indefinitely. This prevents NetworkManager from autoactivating
a profile.

Fix that, to only honor the "scanning" property.

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

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
2020-12-10 12:01:12 +01:00
Thomas Haller
b012877445
libnm: add warning for bindings about broken functions for transferred GPtrArray
In commit 201c153e25 ('libnm: fix GObject Introspection annotations
for functions returning a GPtrArray') these annotations were changed
to fix Vala bindings. However, bindings may treat the transfer
annotation for GPtrArray differently, so depending on the binding
we either get a leak or a double free.

It's unclear how to fix that. For now, just add a warning to the
documentation to avoid it.

The following reproducer leads to a crash:

    #!/bin/python

    import gi

    gi.require_version("NM", "1.0")
    from gi.repository import NM

    def _pr(msg):
        NM.utils_print(0, msg + "\n")

    def process(nmc):
        for device in nmc.get_devices():
            cons = device.filter_connections(nmc.get_connections())
            _pr(
                "device %s (%s) has %s compatible connections"
                % (device.get_iface(), NM.Object.get_path(device), len(cons))
            )

    process(NM.Client.new())

See-also: https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/305
2020-12-09 17:50:22 +01:00
Thomas Haller
d0a4661b65
keyfile: fix error message on failure to generate filename in _internal_write_connection() 2020-12-09 10:30:13 +01:00
Thomas Haller
3490a09a7d
shared: fix race in nm_ref_string_unref()
We cannot drop the reference count to zero while having
no lock. Otherwise, another thread might race doing

  s = nm_ref_string_new("...");
  nm_ref_string_unref(s);

and already successfully delete the instance.

Hitting this race should be rather difficult, especially because
we tend to use NMRefString only from one thread. But still, access
to global variables must be race free.

Fixes: 908fadec96 ('shared: add NMRefString')
2020-12-08 20:07:10 +01:00
Thomas Haller
ef6edd8dbd
libnm: fix re-entrancy of NMClient.dispose() for _init_release_all()
GObject's dispose() functions may be called multiple times
to break reference cycles.

As dispose() calls _init_release_all(), the object might
already be partially destroyed.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
2020-12-08 15:41:52 +01:00
Thomas Haller
dcd0066b10
libnm: add debug logging for creating/destroying NMObject 2020-12-07 22:15:46 +01:00
Beniamino Galvani
e5113a7fd9 ovs: clean up interfaces from ovsdb at startup
During shutdown, NM always tries to remove from ovsdb all bridges,
ports, interfaces that it previously added. Currently NM doesn't run
the main loop during shutdown and so it's not possible to perform
asynchronous operations. In particular, the NMOvsdb singleton is
disposed in a destructor where it's not possible to send out all the
queued deletions.

The result is that NM deletes only one OVS interface, keeping the
others. This needs to be fixed, but requires a rework of the shutdown
procedure that involves many parts of NM.

Even when a better shutdown procedure will be implemented, we should
support an unclean shutdown caused by e.g. a kernel panic or a NM
crash. In these cases, the interfaces added by NM would still linger
in the ovsdb.

Delete all those interface at NM startup. If there are connections
profiles for them, NM will create them again.

https://bugzilla.redhat.com/show_bug.cgi?id=1861296
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/700
2020-12-07 13:57:17 +01:00
Thomas Haller
f1f10e4eb6
NEWS: belatedly mention systemd-resolved change in NEWS 2020-12-07 13:35:46 +01:00
Thomas Haller
507c7c2b8a
release: bump version to 1.29.5 (development) 2020-12-06 16:17:48 +01:00
Thomas Haller
ae5ea7fa62
contrib/release: check NEWS file before release 2020-12-06 16:03:34 +01:00
Thomas Haller
6f32c5c107
release: bump version to 1.28.0 2020-12-06 15:07:17 +01:00
Thomas Haller
76bdde147f
l3cfg: avoid "-Werror=maybe-uninitialized" warning in _load_link()
It's not actually an issue, but the compiler might think that
we use nacd_old_addr without initialization.

(cherry picked from commit cd0e328f7e)
2020-12-06 14:41:39 +01:00
Thomas Haller
cd0e328f7e
l3cfg: avoid "-Werror=maybe-uninitialized" warning in _load_link()
It's not actually an issue, but the compiler might think that
we use nacd_old_addr without initialization.
2020-12-06 14:40:28 +01:00