]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: also include information about LLDP sender in reply for Describe() method
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Jun 2025 01:13:25 +0000 (10:13 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Jun 2025 16:51:19 +0000 (01:51 +0900)
Addresses https://github.com/systemd/systemd/pull/37845#issuecomment-2973257825.

src/network/networkd-json.c

index d07227d2882ab871a0f4d62f69fe017a2d15805a..b6b4b02c06fb1075b22e1629a9546f76f1ef5307 100644 (file)
@@ -1404,6 +1404,23 @@ static int dhcp_client_append_json(Link *link, sd_json_variant **v) {
         return json_variant_set_field_non_null(v, "DHCPv4Client", w);
 }
 
+static int lldp_tx_append_json(Link *link, sd_json_variant **v) {
+        _cleanup_(sd_json_variant_unrefp) sd_json_variant *w = NULL;
+        int r;
+
+        assert(link);
+        assert(v);
+
+        if (!link->lldp_tx)
+                return 0;
+
+        r = sd_lldp_tx_describe(link->lldp_tx, &w);
+        if (r < 0)
+                return r;
+
+        return json_variant_set_field_non_null(v, "LLDP", w);
+}
+
 int link_build_json(Link *link, sd_json_variant **ret) {
         _cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
         _cleanup_free_ char *type = NULL, *flags = NULL;
@@ -1540,6 +1557,10 @@ int link_build_json(Link *link, sd_json_variant **ret) {
         if (r < 0)
                 return r;
 
+        r = lldp_tx_append_json(link, &v);
+        if (r < 0)
+                return r;
+
         *ret = TAKE_PTR(v);
         return 0;
 }