varlink: introduce varlink_call_and_log() which calls and then logs an error

As it turns out we do this in a similar way at various times (and
sometimes incorrectly), hence add a common implementation to share the
code and fix the incorrect behaviour.
This commit is contained in:
Lennart Poettering
2024-01-17 16:20:54 +01:00
parent 0444391d1e
commit 71d0ecc5b9
6 changed files with 72 additions and 29 deletions
+2 -2
View File
@@ -104,9 +104,9 @@ static int check_netns_match(void) {
if (r < 0)
return log_error_errno(r, "Failed to connect to network service /run/systemd/netif/io.systemd.Network: %m");
r = varlink_call(vl, "io.systemd.Network.GetNamespaceId", /* parameters= */ NULL, &reply, /* ret_error_id= */ NULL);
r = varlink_call_and_log(vl, "io.systemd.Network.GetNamespaceId", /* parameters= */ NULL, &reply);
if (r < 0)
return log_error_errno(r, "Failed to issue GetNamespaceId() varlink call: %m");
return r;
static const JsonDispatch dispatch_table[] = {
{ "NamespaceId", JSON_VARIANT_UNSIGNED, json_dispatch_uint64, 0, JSON_MANDATORY },