From 8bdece7479cf147bc8f278f7874c03f5fc23a3a1 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Tue, 18 Jul 2023 22:47:43 +0200 Subject: [PATCH] network: fix fetching link properties This fixes regression introduced in 5a0c810462 with which all requests for link properties ended up with EINVAL as we kept hitting the signature_is_single() assert in sd_bus_get_property(). --- src/network/networkctl.c | 18 ++++++------------ test/test-network/systemd-networkd-tests.py | 3 +++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/network/networkctl.c b/src/network/networkctl.c index ffbda5dc0e2..8c0b096e1de 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -708,7 +708,8 @@ static int link_get_property( sd_bus_error *error, sd_bus_message **reply, const char *iface, - const char *propname) { + const char *propname, + const char *type) { _cleanup_free_ char *path = NULL; char ifindex_str[DECIMAL_STR_MAX(int)]; @@ -721,6 +722,7 @@ static int link_get_property( assert(reply); assert(iface); assert(propname); + assert(type); xsprintf(ifindex_str, "%i", link->ifindex); @@ -728,7 +730,7 @@ static int link_get_property( if (r < 0) return r; - return sd_bus_get_property(bus, "org.freedesktop.network1", path, iface, propname, error, reply, "ss"); + return sd_bus_get_property(bus, "org.freedesktop.network1", path, iface, propname, error, reply, type); } static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) { @@ -739,7 +741,7 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) { assert(bus); assert(link); - r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.Link", "BitRates"); + r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.Link", "BitRates", "(tt)"); if (r < 0) { bool quiet = sd_bus_error_has_names(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY, BUS_ERROR_SPEED_METER_INACTIVE); @@ -748,10 +750,6 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) { r, "Failed to query link bit rates: %s", bus_error_message(&error, r)); } - r = sd_bus_message_enter_container(reply, 'v', "(tt)"); - if (r < 0) - return bus_log_parse_error(r); - r = sd_bus_message_read(reply, "(tt)", &link->tx_bitrate, &link->rx_bitrate); if (r < 0) return bus_log_parse_error(r); @@ -1402,7 +1400,7 @@ static int dump_dhcp_leases(Table *table, const char *prefix, sd_bus *bus, const assert(bus); assert(link); - r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.DHCPServer", "Leases"); + r = link_get_property(bus, link, &error, &reply, "org.freedesktop.network1.DHCPServer", "Leases", "a(uayayayayt)"); if (r < 0) { bool quiet = sd_bus_error_has_name(&error, SD_BUS_ERROR_UNKNOWN_PROPERTY); @@ -1411,10 +1409,6 @@ static int dump_dhcp_leases(Table *table, const char *prefix, sd_bus *bus, const return 0; } - r = sd_bus_message_enter_container(reply, 'v', "a(uayayayayt)"); - if (r < 0) - return bus_log_parse_error(r); - r = sd_bus_message_enter_container(reply, 'a', "(uayayayayt)"); if (r < 0) return bus_log_parse_error(r); diff --git a/test/test-network/systemd-networkd-tests.py b/test/test-network/systemd-networkd-tests.py index 8f4cb788d29..01336bc1751 100755 --- a/test/test-network/systemd-networkd-tests.py +++ b/test/test-network/systemd-networkd-tests.py @@ -4710,6 +4710,9 @@ class NetworkdDHCPServerTests(unittest.TestCase, Utilities): self.assertRegex(output, 'DNS: 192.168.5.1\n *192.168.5.10') self.assertRegex(output, 'NTP: 192.168.5.1\n *192.168.5.11') + output = check_output(*networkctl_cmd, '-n', '0', 'status', 'veth-peer', env=env) + self.assertRegex(output, "Offered DHCP leases: 192.168.5.[0-9]*") + def test_dhcp_server_with_uplink(self): copy_network_unit('25-veth.netdev', '25-dhcp-client.network', '25-dhcp-server-downstream.network', '12-dummy.netdev', '25-dhcp-server-uplink.network') -- 2.47.3