Commit graph

32437 commits

Author SHA1 Message Date
Thomas Haller 640c82710f
platform/tests: fix unit test creating ip6gre tunnel with old iproute2
Older versions of iproute2 don't support the "enclimit" argument. Work
around that from the unit tests.

Fixes: 1505ca3626 ('platform/tests: ip6gre & ip6gretap test cases (ip6 tunnel flags)')
2023-04-07 17:25:26 +02:00
Thomas Haller fe4e5c24e4
find-backports: improve git_ref_exists() to cache also the hashes themselves
git_ref_exists() memoizes the result. But while it looks up the SHA sum
for "ref", it also can cache the result for the SHA sum itself.
2023-04-07 17:23:13 +02:00
AsciiWolf ee99a868f5
po: update Czech (cs) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1596
2023-04-07 14:07:11 +02:00
Thomas Haller 65ef6bc9bc
find-backports: warn if any commits are not from the first reference
Every branch (for example "nm-1-40") has exactly one next branch, from
which patches should be backported (in that example that branch is
"nm-1-42").

While "find-backports" searches all newer branches for patches, it does
not make it clear form where the patch should come from.

That means, if you run the script `contrib/scripts/find-backports origin/nm-1-40`
it will check nm-1-42 and main branch, and might suggest to backport
patches that are only on main, but not "nm-1-42". That would be wrong,
because patches need to first go into nm-1-42, and then backported (from
there) further to nm-1-40.

Print a warning to highlight that.
2023-04-06 21:37:10 +02:00
Thomas Haller 9f89910852
find-backports: various cleanups in script
- avoid list([...]).
- use some f-strings.
2023-04-06 18:34:15 +02:00
Thomas Haller efd23da26b
find-backports: enable debug logging in script 2023-04-06 18:34:15 +02:00
Beniamino Galvani 24461954d0 dhcp: reset IPv6 DAD flag on lease update
If the client was waiting for IPv6 DAD to complete and the lease was
updated or lost, `wait_ipv6_dad` needs to be cleared; otherwise, at
the next platform change the client will try to evaluate the DAD state
with a different or no lease. In particular if there is no lease the
client will try to decline it because there are no valid addresses,
leading to an assertion failure:

 ../src/core/dhcp/nm-dhcp-client.c:997:_dhcp_client_decline: assertion failed: (l3cd)

Backtrace:

  __GI_raise ()
  __GI_abort ()
  g_assertion_message ()
  g_assertion_message_expr ()
  _dhcp_client_decline (self=0x1af13b0, l3cd=0x0, error_message=0x8e25e1 "DAD failed", error=0x7ffec2c45cb0) at ../src/core/dhcp/nm-dhcp-client.c:997
  l3_cfg_notify_cb (l3cfg=0x1bc47f0, notify_data=0x7ffec2c46c60, self=0x1af13b0) at ../src/core/dhcp/nm-dhcp-client.c:1190
  g_closure_invoke ()
  g_signal_emit_valist ()
  g_signal_emit ()
  _nm_l3cfg_emit_signal_notify () at ../src/core/nm-l3cfg.c:629
  _nm_l3cfg_notify_platform_change_on_idle () at ../src/core/nm-l3cfg.c:1390
  _platform_signal_on_idle_cb () at ../src/core/nm-netns.c:411
  g_idle_dispatch ()

Fixes: 393bc628ff ('dhcp: wait DAD completion for DHCPv6 addresses')

https://bugzilla.redhat.com/show_bug.cgi?id=2179890
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1594
2023-04-06 15:56:59 +02:00
Lubomir Rintel 23beb28771 release: bump version to 1.43.5 (development) 2023-04-05 13:45:17 +02:00
Thomas Haller fba38266bc
ovs: merge branch 'th/ovsdb'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1593
2023-04-05 08:46:42 +02:00
Thomas Haller 3a76d717da
ovsdb: debug log all messages of socket buffer 2023-04-04 08:58:06 +02:00
Thomas Haller 0ee60b943d
ovsdb: downgrade error logging to warnings
<error> is mostly about "really should not happen" scenarios. It's
closer to an assertion failure, and something that NetworkManager should
not happen.

Of course, things can go wrong, but <warn> is a sufficient. When ovsdb
gives unexpected communication, it's just a warning. At least, that's
also what all the similar cases in "nm-ovsdb.c" already do
2023-04-04 08:43:21 +02:00
Thomas Haller 25c97817d2
ovsdb: limit maxiumum data size for receive buffer from ovsdb 2023-04-04 08:43:21 +02:00
Thomas Haller f7d321c6d6
ovsdb: add watchdog for unparsable JSON data in socket 2023-04-04 08:43:21 +02:00
Thomas Haller 7e12d437fe
ovsdb: use the FD directly instead of GSocketConnection/GOutputStream
GSocketConnection/GOutputStream/GInputStream seems rather unnecessary.
Maybe they make sense when you want to write portable code (for
Windows). Otherwise, watching a file descriptor and reading/writing it
directly is simpler (and also more efficient).

For example, we passed no GCancellable to g_input_stream_read_async().
What does that mean w.r.t. destroying the NMOvsdb instance? I suspect
it's wrong, but it's hard to say, because there are so many layers of
code.

Note that we anyway keep state in NMOvsdb, namely the data we want to
send (output_buf) and the data we partially received (input_buf). All we
need, are poll notifications when the file descriptor is ready. To
those, we hook up the read/write callbacks. Also before was the code
async, and there were callbacks when when read/write was done. That does
not simplify the code in any way.

- we no longer use separate NMOvsdbPrivate.buf and NMOvsdbPrivate.input
  buffers. There is just a NMOvsdbPrivate.input_buf that can we can fill
  directly.
2023-04-04 08:43:21 +02:00
Thomas Haller f862d4bbce
ovsdb: use nm_auto_free cleanup attribute in "nm-ovsdb.c" 2023-04-04 08:43:21 +02:00
Thomas Haller 64825b4f58
ovsdb: don't track buffer offset in NMOvsdb data and refactor parsing JSON messages
The "priv->bufp" offset is only used while parsing a message at a time.
It's unnecessary to track it in NMOvsdbPrivate and keep it between
parsing messages. Tracking the state in NMOvsdbPrivate makes it more
complicated to understand, because one needs to reason at which times
the state is used (when it really is not used).

Also, move the parsing to a separate function.
2023-04-04 08:43:21 +02:00
Thomas Haller 1378ed7d96
core: drop unnecessary initialization in nm_utils_spawn_helper()
We did not initialize "child_stderr". If that were necessary, we would need
to add it too. However, it is clearly not necessary to initialize those fields.
2023-04-04 08:43:21 +02:00
Thomas Haller ce414933a7
core: use nm_io_fcntl_setfl_update_nonblock() helper 2023-04-04 08:43:21 +02:00
Thomas Haller f4943e07f1
glib-aux: add nm_io_fcntl_setfl_update_nonblock() helper 2023-04-04 08:43:20 +02:00
Thomas Haller 31fd8f60cf
all: use G_SPAWN_CLOEXEC_PIPES with g_spawn_async_with_pipes()
G_SPAWN_CLOEXEC_PIPES is supported since glib 2.40, which we already
depend on.
2023-04-04 08:43:20 +02:00
Thomas Haller 17ae6a4413
platform: drop unused nl_socket_set_nonblocking() function
It's not used. It's better to use SOCK_NONBLOCK flag for socket(), as we do.

Also, the implementation that blindly calls F_SETFL without merging the
existing flags from F_GETFL is just wrong. Drop it altogether.
2023-04-04 08:43:20 +02:00
Thomas Haller 20bd6b6803
core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: df1d214b2e ('clients: polkit-agent: implement polkit agent without using libpolkit')
2023-04-04 08:43:20 +02:00
Thomas Haller 62a85fa845
core: fix setting FD flags in _rfkill_update_system()
F_SETFL will reset the flags. That is wrong, as we only want to add
O_NONBLOCK flag and leaving the other flags alone. Usually, we would
need to call F_GETFL first.

Note that on Linux, F_SETFL can only set certain flags, so the
O_RDWR|O_CLOEXEC flags were unaffected by this. That means, most likely
there are no other flags that our use of F_SETFL would wrongly clear.
Still, it's ugly, because it's not obvious whether there might be other
flags.

Avoid that altogether, by setting the flag already during open().

Fixes: 67e092abcb ('core: better handling of rfkill for WiMAX and WiFi (bgo #629589) (rh #599002)')
2023-04-04 08:43:20 +02:00
Thomas Haller d1f7e439c6
core: fix setting non-blocking stderr in nm_utils_spawn_helper()
Fixes: d65702803c ('core: print stderr from nm-daemon-helper')
2023-04-04 08:43:20 +02:00
Thomas Haller fd123315e5
core: fix setting non-blocking FD in nm_utils_spawn_helper()
Fixes: 6ac21ba916 ('core: add infrastructure for spawning a helper process')
2023-04-04 08:43:20 +02:00
Beniamino Galvani a2db213a45 merge: branch 'bg/rh2054933'
https://bugzilla.redhat.com/show_bug.cgi?id=2054933
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1569
2023-04-04 08:22:39 +02:00
Beniamino Galvani fc13215826 ovs: implement asynchronous detach_port()
Make detach_port() return only after ovsdb reports that the operation
finished.
2023-04-04 08:21:22 +02:00
Beniamino Galvani 07dc237e5c device: wait port detach before leaving the DEACTIVATING state
The device shouldn't change state from DEACTIVATING to DISCONNECTED
until its detached from its controller; otherwise, the port detach
that is in progress can conflict with the following activation.
2023-04-04 08:21:22 +02:00
Beniamino Galvani 82d0fa2a87 device: make detach_port() method asynchronous
This changes the signature of detach_port() to be asynchronous,
similarly to attach_port(). The implementation can return TRUE/FALSE
on immediate completion.

Current implementations return immediately and so there is no change
in behavior for now.
2023-04-04 08:21:22 +02:00
Thomas Haller de8104c71c
device: fix assertion condition in _dev_ipdhcpx_start()
src/core/devices/nm-device.c: In function '_dev_ipdhcpx_start':
  src/core/devices/nm-device.c:10672:13: error: logical 'or' of collectively exhaustive tests is always true [-Werror=logical-op]
               nm_assert(pd_hint_length > 0 || pd_hint_length <= 128);
               ^
  src/core/devices/nm-device.c:10672:13: error: logical 'or' of collectively exhaustive tests is always true [-Werror=logical-op]
  src/core/devices/nm-device.c:10672:13: error: logical 'or' of collectively exhaustive tests is always true [-Werror=logical-op]

Fixes: e2b9019ac0 ('dhcp: support prefix delegation hint')
2023-04-04 08:19:20 +02:00
Beniamino Galvani 3127810158 merge: branch 'bg/dhcp6-pd-hint'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1581
2023-04-03 16:05:27 +02:00
Beniamino Galvani fa997be216 dhcp: export the prefix delegation
Export the IA_PD option so that it is available via D-Bus and in the
lease file in /run.
2023-04-03 16:04:55 +02:00
Beniamino Galvani e2b9019ac0 dhcp: support prefix delegation hint
Support the prefix delegation hint in the DHCP client.

dhclient only supports a prefix length, emit a warning if the user set
a non-zero prefix.
2023-04-03 16:04:55 +02:00
Beniamino Galvani f9c1d06e64 libnm,nmcli: add ipv6.dhcp-pd-hint property
Add a new property to specify a hint for DHCPv6 prefix delegation.
2023-04-03 16:04:55 +02:00
Thomas Haller af078a7d54
core: merge branch 'th/dameon-helper-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1588
2023-04-03 10:29:54 +02:00
Thomas Haller f58a69656a
core: error out in nm_utils_kill_child_{sync,async}() if first waitpid() gives ECHILD
It is wrong trying to send the signal still. Just error out.

Note that ECHILD indicates that the process is either not a child
or was already reaped. In both cases, that is a bug of the caller
who must keep accurate track of the child's process ID.
2023-04-03 10:27:43 +02:00
Thomas Haller a65e80e8b6
core: pre-allocate exact buffer size for output in nm_utils_spawn_helper()
It's easy enough to know how many bytes are needed. Just allocate the
right size (+1, because NMStrBuf really likes to reserve that extra byte
for the trailing NUL, even if it's not needed in this case).
2023-04-03 10:27:43 +02:00
Thomas Haller 346196792c
core/trivial: add code comment about using GChildWatchSource 2023-04-03 10:27:43 +02:00
Thomas Haller 597e127bcb
core: use nm_g_child_watch_source_new() in nm_utils_spawn_helper() 2023-04-03 10:27:43 +02:00
Thomas Haller a52d620549
core: assert that nm_utils_spawn_helper() is used with default context 2023-04-03 10:27:43 +02:00
Thomas Haller 3411f42418
core: store main context in variable in nm_utils_spawn_helper()
There is no change in behavior, because the GTask's context
is of course g_main_context_get_thread_default(). Still, not point
in making that unclear.
2023-04-03 10:27:43 +02:00
Thomas Haller f9c409d34c
core: qualify logging lines related to helper with "nm-daemon-helper"
Seems to be the better name, because that is also the name of the
executable.
2023-04-03 10:27:43 +02:00
Thomas Haller f74109e4b0
core: rename nmlog defines in "nm-core-utils.c"
Those are related to _NMLOG2() macro. Rename.
2023-04-03 10:27:43 +02:00
Thomas Haller b5875ec79e
core: use nm_clear_fd() helper in nm_utils_spawn_helper() 2023-04-03 10:27:43 +02:00
Yuri Chornoivan a26c79e495
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1592
2023-04-03 09:40:41 +02:00
Thomas Haller 8d6349156b
libnm/tests: avoid uninitialized variable warning in _invalid_option_write_handler()
src/libnm-core-impl/tests/test-keyfile.c: In function '_invalid_option_write_handler':
  src/libnm-core-impl/tests/test-keyfile.c:917:9: error: 'message' may be used uninitialized [-Werror=maybe-uninitialized]
    917 |         g_assert(message && strstr(message, "ethtool.bogus"));
        |         ^
  src/libnm-core-impl/tests/test-keyfile.c:905:29: note: 'message' was declared here
    905 |     const char             *message;
        |                             ^
  lto1: all warnings being treated as errors
2023-03-31 18:15:50 +02:00
Thomas Haller 17601acd3d
clients/tests: merge branch 'th/test-client-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1591
2023-03-31 17:43:11 +02:00
Thomas Haller 342ee618c7
client/tests: don't do dup2() dance to pass file descriptor to "tools/test-cloud-meta-mock.py"
"preexec_fn" is not great, because it is not generally safe in multi
threaded code (and we don't know whether the test didn't start other
threads already, like a GDBus worker thread). Well, it probably is safe,
if you only call async signal safe code, but it's not clear what os.dup2()
does under the hood.

Just avoid that. We can pass on the FD directly.
2023-03-30 15:36:16 +02:00
Thomas Haller d533072962
client/tests: close process stdin in test-python.py to avoid warning about leak
test_ec2 (__main__.TestNmCloudSetup.test_ec2) ... /usr/lib64/python3.11/unittest/case.py:579: ResourceWarning: unclosed file <_io.BufferedWriter name=5>
    if method() is not None:
  ResourceWarning: Enable tracemalloc to get the object allocation traceback
  ok

Fixes: d89d42bf23 ('tests/client: test nm-cloud-setup')
2023-03-30 15:35:22 +02:00
Thomas Haller a9558231cf
client/tests: drop unnecessary socket.set_inheritable() call from "test-client.py"
This seems unnecessary, because we spawn the child process via subprocess.Popen and
set "pass_fds". That already ensures to pass on the FD.

Worse, socket.set_inheritable() is only added in Python 3.4, that means the
test is gonna break for Python 3.2 and 3.3. Just avoid that by not using the
unnecessary function. For the same reason, drop "inheritable=True" from
os.dup2(). "inheritable=True" is already the default, but only exists
since Python 3.4.

Fixes: d89d42bf23 ('tests/client: test nm-cloud-setup')
2023-03-30 15:06:54 +02:00