Commit graph

31247 commits

Author SHA1 Message Date
Beniamino Galvani
9feffe7ad4 platform: detect dadfailed IPv6 addresses during pruning
If an address is removed during pruning and it had the TENTATIVE flag
before, the most likely cause of the removal is that it failed DAD. It
could also be that the user removed it at the same time we needed to
resync the platform cache, but that seems more unlikely.
2022-10-26 08:54:29 +02:00
Beniamino Galvani
3f84ee27a0 platform: add mechanism to report removed IPv6 addresses that failed DAD 2022-10-26 08:54:29 +02:00
Thomas Haller
06bf0707ee
platform/tests: merge branch 'th/platform-1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1440
2022-10-26 08:25:59 +02:00
Thomas Haller
ff9f413fcc
platform/tests: use nmtst_inet6_from_string() instead of *nmtst_inet6_from_string_p() 2022-10-26 08:24:29 +02:00
Thomas Haller
edfb4e578e
platform/tests: add nmtst_inet6_from_string() helper
This returns a struct (not a pointer like nmtst_inet6_from_string_p()).
It is thus consistent with nmtst_inet4_from_string().
2022-10-26 08:24:28 +02:00
Thomas Haller
2786a30a7c
platform/tests: rename nmtst_inet6_from_string() to nmtst_inet6_from_string_p()
This helper returns a pointer (to a thread local variable).
2022-10-26 08:24:28 +02:00
Thomas Haller
06cf1f5e2d
platform/tests: extend monitor tool to dump the state of NMPlatform
This is useful for manual testing ("manual", in the sense that you can
write a script that tests the behavior of the platform cache, without
humanly reading the logfile).

Usage:

To write the content of the platform cache once:

  ./src/core/platform/tests/monitor -P -S './statefile'

To keep monitor running, and update the state file:

  ./src/core/platform/tests/monitor -S './statefile'
2022-10-26 08:24:28 +02:00
Thomas Haller
3654fc8145
platform/tests: make "external_command" int type
The variable is passed to nmtstp_run_command_check_external(), which accepts
-1 to mean choose randomly. Change the function signature to reflect that.
2022-10-26 08:24:28 +02:00
Thomas Haller
358d4c691d
glib-aux: add nm_auto_unref_gdatetime cleanup macro 2022-10-26 08:24:22 +02:00
Thomas Haller
a558b8c88c
systemd: merge branch systemd into main 2022-10-25 18:50:32 +02:00
Thomas Haller
37ccc08abf
examples: fix code formatting in "gmaincontext.py" 2022-10-25 16:47:48 +02:00
Fernando Fernandez Mancera
8111f7f33e docs: document routing-rules dbus properties
Add IP setting routing-rules properties DBus documentation. The type is
specified using the DBus formatting.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1439

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-10-25 16:42:02 +02:00
Andrew Zaborowski
2ee0536f2a
iwd: Register the Netconfig agent
Handle IP Configuration requests from IWD so that, when IWD's main.conf
setting [General].NetworkConfigurationEnabled is true, we don't try to
run DHCP or static addressing in parallel with IWD's internal DHCP or
static addressing.

Since part of the IWD secret agent and the new NetConfig agent
registration code is common, the agent object's path is changed.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1337
2022-10-25 16:35:48 +02:00
Thomas Haller
ced829d8fd
all: merge branch 'th/nm-close'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1430
2022-10-25 15:42:13 +02:00
Thomas Haller
d98553e9e7
main: use helper function to write pid file in nm_main_utils_write_pidfile()
On the surface, writing a file seams simple enough. But there are many
pitfalls:

- we should retry on EINTR.

- we should check for incomplete writes and loop.

- we possibly should check errors from close.

- we possibly should write to a temporary file and do atomic rename.

Use nm_utils_file_set_contents() to get this right.
2022-10-25 13:12:49 +02:00
Thomas Haller
70417fda9e
glib-aux: handle errors from close() in nm_utils_file_set_contents()
glib's g_file_set_contents() also does that.
2022-10-25 13:12:48 +02:00
Thomas Haller
3254f33b33
std-aux: assert against any EBADF error in nm_close()
Previously, nm_close() accepted EBADF, as long as fd was negative.

Getting EBADF for a non-negative file descriptor is a serious bug,
because in multi threaded applications there is a race to close
an unrelated file descriptor. Also, it indicates that somebody
messed up the tracking of the resource, which indicates a bug.

Getting EBADF on a negative FD is less of a problem.
But it still indicates that the caller does something they likely
don't intend to.

Assert against any EBADF.

Note that nm_clear_fd() and nm_auto_close take already care to not
close negative "file descriptors". So, if you use those, you are
not affected.

If you want a close function that doesn't care about whether fd is set,
then maybe use `nm_clear_fd(&fd)` instead.
2022-10-25 13:12:48 +02:00
Thomas Haller
ad7d5887cd
all: cleanup close() handling and clarify nm_close()/nm_close_with_error()
Cleanup the handling of close().

First of all, closing an invalid (non-negative) file descriptor (EBADF) is
always a serious bug. We want to catch that. Hence, we should use nm_close()
(or nm_close_with_error()) which asserts against such bugs. Don't ever use
close() directly, to get that additional assertion.

Also, our nm_close() handles EINTR internally and correctly. Recent
POSIX defines that on EINTR the close should be retried. On Linux,
that is never correct. After close() returns, the file descriptor is
always closed (or invalid). nm_close() gets this right, and pretends
that EINTR is a success (without retrying).

The majority of our file descriptors are sockets, etc. That means,
often an error from close isn't something that we want to handle. Adjust
nm_close() to return no error and preserve the caller's errno. That is
the appropriate reaction to error (ignoring it) in most of our cases.

And error from close may mean that there was an IO error (except EINTR
and EBADF). In a few cases, we may want to handle that. For those
cases we have nm_close_with_error().

TL;DR: use almost always nm_close(). Unless you want to handle the error
code, then use nm_close_with_error(). Never use close() directly.

There is much reading on the internet about handling errors of close and
in particular EINTR. See the following links:

https://lwn.net/Articles/576478/
https://askcodes.net/coding/what-to-do-if-a-posix-close-call-fails-
https://www.austingroupbugs.net/view.php?id=529
https://sourceware.org/bugzilla/show_bug.cgi?id=14627
https://news.ycombinator.com/item?id=3363819
https://peps.python.org/pep-0475/
2022-10-25 13:12:48 +02:00
Thomas Haller
1ce29e120b
std-aux: drop assertion and function name from assert() in release mode
For g_assert() and g_return*() we already do the same, in
"src/libnm-glib-aux/nm-gassert-patch.h"

Also patch __assert_fail() so that it omits the condition text and the
function name in production builds.

Note that this is a bit ugly, for two reasons:

- again, we make assumptions that __assert_fail() exists. In practice,
  this is the case for glibc and musl.

- <assert.h> can be included multiple times, while also forward
  declaring __assert_fail(). That means, we cannot add a macro

  #define __assert_fail(...)

  because that would break the forward declaration. Instead,
  just `#define __assert_fail _nm_assert_fail_internal`

Of course, this only affects direct calls to assert(), which we have
few. nm_assert() is not affected, because that anyway doesn't do
anything, unless NM_MORE_ASSERTS is enabled.
2022-10-25 13:12:48 +02:00
Thomas Haller
8e3299498d
std-aux,glib-aux: rework nm_assert() implementations
1) ensure the compiler always sees the condition (even if
  it's unreachable). That is important, to avoid warnings
  about unused variables and to ensure the condition compiles.
  Previously, if NM_MORE_ASSERTS was enabled and NDEBUG (or
  G_DISABLE_ASSERT) was defined, the condition was not seen by
  the compiler.

2) to achieve point 1, we evaluate the expression now always in
  nm_assert() macro directly. This also has the benefit that we
  control exactly what is done there, and the implementation is
  guaranteed to not use any code that is not async-signal-safe
  (unless the assertion fails, of course).

3) add NM_MORE_ASSERTS_EFFECTIVE.
  When using no glib (libnm-std-aux), the assert is implemented
  by C89 assert(), while libnm-glib-aux redirects that to g_assert().
  Note that these assertions are only in effect, if both NM_MORE_ASSERTS
  and NDEBUG/G_DISABLE_ASSERT say so. NM_MORE_ASSERTS_EFFECTIVE
  is thus the effectively used level for nm_assert().

4) use the proper __assert_fail() and g_assertion_message_expr()
  calls. __assert_fail() is not standard, but it is there for glibc
  and musl. So relying on this is probably fine. Otherwise, we will
  get a compilation error and notice it.
2022-10-25 13:12:48 +02:00
Thomas Haller
197963fba3
std-aux: add _nm_noreturn macro 2022-10-25 13:12:48 +02:00
Thomas Haller
0d5b04ad9c
glib-aux/tests: reinclude <assert.h> with NDEBUG undefined
While we usually don't do that, we also want to build with NDEBUG.
But in that case, we don't want that the assertions from our unit
tests are disabled.

Solve that by undefining NDEBUG and re-including <assert.h>.
2022-10-25 13:12:47 +02:00
Thomas Haller
51e41566a7
all: drop lgtm annotations
lgtm is going away. These annotations are no longer useful.

https://github.blog/2022-08-15-the-next-step-for-lgtm-com-github-code-scanning/
2022-10-25 12:36:43 +02:00
Thomas Haller
c34c8fdb82
examples: avoid unreachable code in "gmaincontext.py"
lgtm.com warns about this. Avoid it.
2022-10-25 12:36:43 +02:00
Thomas Haller
ea5cd47bc4
tools: drop unused variables from "tools/generate-docs-nm-property-infos.py"
Found by lgtm.com.
2022-10-25 12:12:44 +02:00
Thomas Haller
85d5fb210b
examples: drop unused import from "gmaincontext.py" example
Complained by lgtm.com.
2022-10-25 12:11:19 +02:00
Thomas Haller
b615dd83da
dispatcher: make global data in "nm-dispatcher.c" static
It's not needed outside the source file, and lgtm.com complains
that global variables should have a long name.

  Poor global variable name 'gl'. Prefer longer, descriptive names for
  globals (eg. kMyGlobalConstant, not foo).
2022-10-25 12:09:49 +02:00
Thomas Haller
f0fff996e2
vpn: drop redundant check in device_changed()
lgtm.com correclty warns that ifindex is always positive at this point.
Drop unnecessary code.
2022-10-25 12:06:12 +02:00
Thomas Haller
9b80860ff4
examples: avoid lgtm warning about calling traceback.format_exception()
lgtm.com says:

  Call to function format_exception with too few arguments; should be no
  fewer than 3.
2022-10-25 12:01:54 +02:00
Thomas Haller
5afa09e966
systemd: update code from upstream (2022-10-25)
This is a direct dump from systemd git.

  $ git clean -fdx && \
    git cat-file -p HEAD | sed '1,/^======$/ d' | bash - && \
    git add .

======

SYSTEMD_DIR=../systemd
COMMIT=4117366a283657295264723e559d7ead79a7cfd3

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files -z :/src/libnm-systemd-core/src/ \
                :/src/libnm-systemd-shared/src/ \
                :/src/libnm-std-aux/unaligned.h | \
  xargs -0 rm -f

nm_copy_sd_shared() {
    mkdir -p "./src/libnm-systemd-shared/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-systemd-shared/$1"
}

nm_copy_sd_core() {
    mkdir -p "./src/libnm-systemd-core/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-systemd-core/$1"
}

nm_copy_sd_stdaux() {
    mkdir -p "./src/libnm-std-aux/"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-std-aux/${1##*/}"
}

nm_copy_sd_core "src/libsystemd-network/arp-util.c"
nm_copy_sd_core "src/libsystemd-network/arp-util.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/network-common.c"
nm_copy_sd_core "src/libsystemd-network/network-common.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-option.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/async.h"
nm_copy_sd_shared "src/basic/cgroup-util.h"
nm_copy_sd_shared "src/basic/dns-def.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/format-util.c"
nm_copy_sd_shared "src/basic/format-util.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/glyph-util.c"
nm_copy_sd_shared "src/basic/glyph-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/inotify-util.c"
nm_copy_sd_shared "src/basic/inotify-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/locale-util.c"
nm_copy_sd_shared "src/basic/locale-util.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_random.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_syscall.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/ordered-set.c"
nm_copy_sd_shared "src/basic/ordered-set.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/ratelimit.c"
nm_copy_sd_shared "src/basic/ratelimit.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.c"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/strxcpyx.c"
nm_copy_sd_shared "src/basic/strxcpyx.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/user-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/basic/util.c"
nm_copy_sd_shared "src/basic/util.h"
nm_copy_sd_shared "src/fundamental/macro-fundamental.h"
nm_copy_sd_shared "src/fundamental/sha256.c"
nm_copy_sd_shared "src/fundamental/sha256.h"
nm_copy_sd_shared "src/fundamental/string-util-fundamental.c"
nm_copy_sd_shared "src/fundamental/string-util-fundamental.h"
nm_copy_sd_shared "src/shared/dns-domain.c"
nm_copy_sd_shared "src/shared/dns-domain.h"
nm_copy_sd_shared "src/shared/log-link.h"
nm_copy_sd_shared "src/shared/web-util.c"
nm_copy_sd_shared "src/shared/web-util.h"
nm_copy_sd_stdaux "src/basic/unaligned.h"
2022-10-25 11:04:47 +02:00
Thomas Haller
fee0f7cad8
lldp: merge branch 'th/lldp'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1426
2022-10-25 10:59:16 +02:00
Thomas Haller
debc66e823
lldp: use nm_lldp_neighbor_id_hash() in "nm-lldp-listener.c" 2022-10-25 10:59:02 +02:00
Thomas Haller
c416c066cf
lldp/systemd: remove systemd LLDP sources
They are no longer used. We use now libnm-llpd instead.
2022-10-25 10:59:01 +02:00
Thomas Haller
04e72b6b4d
lldp: use new libnm-lldp instead of systemd's sd_lldp_rx 2022-10-25 10:59:01 +02:00
Thomas Haller
630de288d2
lldp: add libnm-lldp as fork of systemd's sd_lldp_rx
We currently use the systemd LLDP client, which we consume by forking
systemd code. That is a maintenance burden, because it's not a
self-contained, stable library that we use. Hence there is a need for an
individual library or properly integrating the fork in our tree.

Optimally, we would create a new nettools project with an LLDP library.
That was not done because:

- nettools may want to be dual licensed with LGPL-2.1+ and Apache.
  Systemd code is LGPL-2.1+ so it is fine for NetworkManager but
  possibly not for nettools.

- nettools provides independent librares, as such they don't have an
  event loop, instead they expose an epoll file descriptor and the user
  needs to integrate it. Systemd and NetworkManager on the other hand
  have their established event loop (sd_event and GMainContext,
  respectively). It's simpler to implement the library on those terms,
  in particular porting the systemd library from sd_event to
  GMainContext.

- NetworkManager uses glib and has various helper utils. While it's
  possible to do without them, it's more work.

The main reason to not write a new NetworkManager-agnostic library from
scratch, is that it's much simpler to fork the systemd library and make
it part of NetworkManager, than making it a nettools library.

Do it.
2022-10-25 10:59:00 +02:00
Thomas Haller
8506865345
glib-aux: add nm_time_map_clock() helper 2022-10-25 10:59:00 +02:00
Thomas Haller
2e27f16d26
glib-aux: add nm_utils_clock_gettime_usec() helper 2022-10-25 10:58:59 +02:00
Thomas Haller
90b6491fa8
glib-aux: don't assert for integer range in nm_utils_monotonic_timestamp_from_boottime()
The boottime argument might come from the system, and we should not
assert that it's reasonably small. It might be infinity. In that
case, keep it at infinity.
2022-10-25 10:58:59 +02:00
Thomas Haller
64326a42a9
glib-aux: add nm_utils_get_monotonic_timestamp_usec_cached() helper 2022-10-25 10:58:58 +02:00
Thomas Haller
41fdbd8831
glib-aux: rework nm_utils_timespec_to_{n,u,m}sec() helpers
- add nm_utils_timespec_to_usec().
- add range checking, taken from systemd's timespec_load_nsec().
- add a unit test.
2022-10-25 10:58:58 +02:00
Thomas Haller
bc74116cde
glib-aux: add NM_ERRNO_IS_TRANSIENT() and NM_ERRNO_IS_DISCONNECT() helper 2022-10-25 10:58:58 +02:00
Thomas Haller
f7bc47a26f
glib-aux: add nm_fd_next_datagram_size() helper 2022-10-25 10:58:57 +02:00
Thomas Haller
4b35168193
glib-aux: add nm_ether_addr_to_string_dup() helper 2022-10-25 10:58:57 +02:00
Thomas Haller
f9cd90f12a
glib-aux: add nm_ether_addr_is_zero() helper 2022-10-25 10:58:57 +02:00
Thomas Haller
2fb8ce9188
glib-aux: move nm_ether_addr_zero to "libnm-glib-aux/nm-shared-utils.h"
It belongs there, beside NMEtherAddr. Maybe NMEtherAddr should be moved to a
separate header, but it here for now.

The only oddity is that nm_ether_addr_zero actually aliases nm_ip_addr_zero,
which is in "libnm-glib-aux/nm-inet-utils.h". We can workaround that.
2022-10-25 10:58:56 +02:00
Thomas Haller
996b679bd0
glib-aux: add NMPrioq priority queue (heap)
Taken from systemd's "Prioq".

Differences from Prioq:

- It is glib-ized, so certain operations cannot fail since g_malloc()
  never fails.

- Unlike Prioq, this structure is stack allocated. I think that makes
  sense, because we basically always want to embed the data structure
  in another object. There is never a need for passing this around as a
  pointer. And if you really want, you can box it yourself.

- The queue either accepts a GCompareFunc or a GComareDataFunc. This
  is for convenience. The prioq_ensure_allocated() and
  prioq_ensure_put() consequently are dropped, as they would be
  cumbersome with this pattern and don't seem useful.
2022-10-25 10:58:56 +02:00
Thomas Haller
5f3259b620
std-aux: add NM_ALIGN*() macros
Taken from systemd's ALIGN(), ALIGN_TO(), etc.
2022-10-25 10:58:56 +02:00
Thomas Haller
9f534341e0
core: fix code comment in _host_id_hash_v2()
The previous snippet was wrong, there was an additional newline after
`stat`. Fix that and reformat the comment.
2022-10-25 10:35:07 +02:00
Thomas Haller
11a34405ef
secrets: merge branch 'elbs-unicon:fix_auth_retries'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1381
2022-10-25 09:07:27 +02:00
Thomas Haller
16c0be1ada
style: various minor adjustments 2022-10-25 08:41:45 +02:00