Migrate to libyang2
Also update buildroot to latest master:
- the sdbus-cpp version bump patch has been removed, because upstream
now bumped it to an even newer version
- Fix RAUC not able to start a service
(https://github.com/buildroot/buildroot/commit/72308ab9a32de6e8b4b23e42f115ed5ee87e5f33)
Depends-on: https://cesnet-gerrit-czechlight/c/CzechLight/netconf-cli/+/4539
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/netconf-cli/+/4539
Depends-on: https://cesnet-gerrit-czechlight/c/CzechLight/rousette/+/5391
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/5391
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/cla-sysrepo/+/5292
Depends-on: https://cesnet-gerrit-czechlight/c/CzechLight/velia/+/5237
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/velia/+/5237
Change-Id: I6edc19f35accfd41a4b32f7b396981d470e0c07b
diff --git a/board/czechlight/common/patches/systemd/0009-networkctl-JSON-output-in-networkctl-lldp.patch b/board/czechlight/common/patches/systemd/0009-networkctl-JSON-output-in-networkctl-lldp.patch
index 5d43f1d..f85c6c3 100644
--- a/board/czechlight/common/patches/systemd/0009-networkctl-JSON-output-in-networkctl-lldp.patch
+++ b/board/czechlight/common/patches/systemd/0009-networkctl-JSON-output-in-networkctl-lldp.patch
@@ -1,4 +1,4 @@
-From 7479e9e720909a2d2360f684e85821195301dce2 Mon Sep 17 00:00:00 2001
+From f681abcf74f1a03f64fbcec15c33aae026dcdf51 Mon Sep 17 00:00:00 2001
From: Tomas Pecka <peckato1@users.noreply.github.com>
Date: Wed, 6 Oct 2021 10:11:31 +0200
Subject: [PATCH 9/9] networkctl: JSON output in networkctl lldp
@@ -6,27 +6,35 @@
`networkctl lldp` now outputs also in JSON format when `--json=*`
argument passed. The LLDP neighbors are listed in per interface lists.
---
- src/network/networkctl.c | 123 ++++++++++++++++++++++++++-------------
- 1 file changed, 82 insertions(+), 41 deletions(-)
+ src/network/networkctl.c | 136 +++++++++++++++++++++++++--------------
+ 1 file changed, 88 insertions(+), 48 deletions(-)
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
-index 89abaf26da..124ee8f0c7 100644
+index 9fbeed6908..0f48aa4bf7 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
-@@ -2510,6 +2510,7 @@ typedef struct LLDPUserdata {
+@@ -2507,12 +2507,14 @@ typedef struct LLDPUserdata {
+ uint16_t capabilities_all;
+
+ Table *table;
++ JsonVariant *json;
char *link_name;
- Table *table;
-+ JsonVariant **json_list;
} LLDPUserdata;
- static int lldp_neighbours_varlink_reply(Varlink *link, JsonVariant *parameters, const char *error_id, VarlinkReplyFlags flags, void *userdata) {
-@@ -2556,6 +2557,26 @@ static int lldp_neighbours_varlink_reply(Varlink *link, JsonVariant *parameters,
- if (udata->capabilities_all)
- *(udata->capabilities_all) |= entry.capabilities;
+ static void lldp_userdata_freep(LLDPUserdata* p) {
+ table_unref(p->table);
++ json_variant_unref(p->json);
+ }
-+ if (udata->json_list) {
+ static int lldp_neighbors_varlink_reply(Varlink *link, JsonVariant *parameters, const char *error_id, VarlinkReplyFlags flags, void *userdata) {
+@@ -2556,6 +2558,34 @@ static int lldp_neighbors_varlink_reply(Varlink *link, JsonVariant *parameters,
+ udata->neighbors_count += 1;
+ udata->capabilities_all |= entry.capabilities;
+
++ if (udata->json) {
+ _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
++ _cleanup_(json_variant_unrefp) JsonVariant *neighbors = NULL;
+
+ capabilities = lldp_capabilities_to_string(entry.capabilities, false);
+
@@ -40,7 +48,14 @@
+ if (r < 0)
+ return r;
+
-+ r = json_variant_append_array(udata->json_list, v);
++
++ neighbors = json_variant_ref(json_variant_by_key(udata->json, udata->link_name));
++
++ r = json_variant_append_array(&neighbors, v);
++ if (r < 0)
++ return r;
++
++ r = json_variant_set_field(&udata->json, udata->link_name, neighbors);
+ if (r < 0)
+ return r;
+ }
@@ -48,156 +63,134 @@
return 0;
}
-@@ -2568,10 +2589,10 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
+@@ -2568,7 +2598,6 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
_cleanup_(link_info_array_freep) LinkInfo *links = NULL;
- _cleanup_(table_unrefp) Table *table = NULL;
-+ _cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
- int neighbors_count = 0;
- uint16_t capabilities_all = 0;
- LLDPUserdata udata = {};
+ _cleanup_(lldp_userdata_freep) LLDPUserdata udata = {};
- TableCell *cell;
r = varlink_connect_address(&link, address);
if (r < 0)
-@@ -2592,50 +2613,58 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
- if (c < 0)
+@@ -2590,47 +2619,54 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
return c;
-- (void) pager_open(arg_pager_flags);
+ pager_open(arg_pager_flags);
+-
+- udata.table = table_new("link",
+- "chassis id",
+- "system name",
+- "caps",
+- "port id",
+- "port description");
+- if (!udata.table)
+- return log_oom();
+-
+- if (arg_full)
+- table_set_width(udata.table, 0);
+-
+- table_set_header(udata.table, arg_legend);
+-
+- assert_se(cell = table_get_cell(udata.table, 0, 0));
+- table_set_minimum_width(udata.table, cell, 16);
+- table_set_maximum_width(udata.table, cell, 16);
+-
+- assert_se(cell = table_get_cell(udata.table, 0, 1));
+- table_set_minimum_width(udata.table, cell, 17);
+- table_set_maximum_width(udata.table, cell, 17);
+-
+- assert_se(cell = table_get_cell(udata.table, 0, 2));
+- table_set_minimum_width(udata.table, cell, 16);
+- table_set_maximum_width(udata.table, cell, 16);
+-
+- assert_se(cell = table_get_cell(udata.table, 0, 3));
+- table_set_minimum_width(udata.table, cell, 11);
+- table_set_maximum_width(udata.table, cell, 11);
+-
+- assert_se(cell = table_get_cell(udata.table, 0, 4));
+- table_set_minimum_width(udata.table, cell, 17);
+- table_set_maximum_width(udata.table, cell, 17);
+-
+- assert_se(cell = table_get_cell(udata.table, 0, 5));
+- table_set_minimum_width(udata.table, cell, 16);
+- table_set_maximum_width(udata.table, cell, 16);
+-
+- if (table_set_empty_string(udata.table, "n/a") < 0)
+- return log_oom();
+ if (arg_json_format_flags == JSON_FORMAT_OFF) {
+ TableCell *cell;
-
-- table = table_new("link",
-- "chassis id",
-- "system name",
-- "caps",
-- "port id",
-- "port description");
-- if (!table)
-- return log_oom();
-+ (void) pager_open(arg_pager_flags);
-
-- if (arg_full)
-- table_set_width(table, 0);
-+ table = table_new("link",
-+ "chassis id",
-+ "system name",
-+ "caps",
-+ "port id",
-+ "port description");
-+ if (!table)
-+ return log_oom();
-
-- table_set_header(table, arg_legend);
-+ if (arg_full)
-+ table_set_width(table, 0);
-
-- assert_se(cell = table_get_cell(table, 0, 0));
-- table_set_minimum_width(table, cell, 16);
-- table_set_maximum_width(table, cell, 16);
-+ table_set_header(table, arg_legend);
-
-- assert_se(cell = table_get_cell(table, 0, 1));
-- table_set_minimum_width(table, cell, 17);
-- table_set_maximum_width(table, cell, 17);
-+ assert_se(cell = table_get_cell(table, 0, 0));
-+ table_set_minimum_width(table, cell, 16);
-+ table_set_maximum_width(table, cell, 16);
-
-- assert_se(cell = table_get_cell(table, 0, 2));
-- table_set_minimum_width(table, cell, 16);
-- table_set_maximum_width(table, cell, 16);
-+ assert_se(cell = table_get_cell(table, 0, 1));
-+ table_set_minimum_width(table, cell, 17);
-+ table_set_maximum_width(table, cell, 17);
-
-- assert_se(cell = table_get_cell(table, 0, 3));
-- table_set_minimum_width(table, cell, 11);
-- table_set_maximum_width(table, cell, 11);
-+ assert_se(cell = table_get_cell(table, 0, 2));
-+ table_set_minimum_width(table, cell, 16);
-+ table_set_maximum_width(table, cell, 16);
-
-- assert_se(cell = table_get_cell(table, 0, 4));
-- table_set_minimum_width(table, cell, 17);
-- table_set_maximum_width(table, cell, 17);
-+ assert_se(cell = table_get_cell(table, 0, 3));
-+ table_set_minimum_width(table, cell, 11);
-+ table_set_maximum_width(table, cell, 11);
-
-- assert_se(cell = table_get_cell(table, 0, 5));
-- table_set_minimum_width(table, cell, 16);
-- table_set_maximum_width(table, cell, 16);
-+ assert_se(cell = table_get_cell(table, 0, 4));
-+ table_set_minimum_width(table, cell, 17);
-+ table_set_maximum_width(table, cell, 17);
-
-- if (table_set_empty_string(table, "n/a") < 0)
-- return log_oom();
-+ assert_se(cell = table_get_cell(table, 0, 5));
-+ table_set_minimum_width(table, cell, 16);
-+ table_set_maximum_width(table, cell, 16);
+
-+ if (table_set_empty_string(table, "n/a") < 0)
++ udata.table = table_new("link",
++ "chassis id",
++ "system name",
++ "caps",
++ "port id",
++ "port description");
++ if (!udata.table)
+ return log_oom();
-
-- udata.table = table;
-+ udata.table = table;
++
++ if (arg_full)
++ table_set_width(udata.table, 0);
++
++ table_set_header(udata.table, arg_legend);
++
++ assert_se(cell = table_get_cell(udata.table, 0, 0));
++ table_set_minimum_width(udata.table, cell, 16);
++ table_set_maximum_width(udata.table, cell, 16);
++
++ assert_se(cell = table_get_cell(udata.table, 0, 1));
++ table_set_minimum_width(udata.table, cell, 17);
++ table_set_maximum_width(udata.table, cell, 17);
++
++ assert_se(cell = table_get_cell(udata.table, 0, 2));
++ table_set_minimum_width(udata.table, cell, 16);
++ table_set_maximum_width(udata.table, cell, 16);
++
++ assert_se(cell = table_get_cell(udata.table, 0, 3));
++ table_set_minimum_width(udata.table, cell, 11);
++ table_set_maximum_width(udata.table, cell, 11);
++
++ assert_se(cell = table_get_cell(udata.table, 0, 4));
++ table_set_minimum_width(udata.table, cell, 17);
++ table_set_maximum_width(udata.table, cell, 17);
++
++ assert_se(cell = table_get_cell(udata.table, 0, 5));
++ table_set_minimum_width(udata.table, cell, 16);
++ table_set_maximum_width(udata.table, cell, 16);
++
++ if (table_set_empty_string(udata.table, "n/a") < 0)
++ return log_oom();
+ } else {
-+ r = json_build(&v, JSON_BUILD_EMPTY_OBJECT);
++ r = json_build(&udata.json, JSON_BUILD_EMPTY_OBJECT);
+ if (r < 0)
+ return r;
+ }
- udata.neighbors_count = &neighbors_count;
- udata.capabilities_all = &capabilities_all;
-@@ -2643,10 +2672,14 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
varlink_set_userdata(link, &udata);
- for (int i = 0; i < c; i++) {
-- _cleanup_(json_variant_unrefp) JsonVariant *cparams = NULL;
-+ _cleanup_(json_variant_unrefp) JsonVariant *cparams = NULL, *neighbors = NULL;
-
- udata.link_name = links[i].name;
-
-+ if (arg_json_format_flags != JSON_FORMAT_OFF) {
-+ udata.json_list = &neighbors;
-+ }
-+
- r = json_build(&cparams, JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR("ifindex", JSON_BUILD_UNSIGNED(links[i].ifindex))));
- if (r < 0)
-@@ -2659,15 +2692,23 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
- r = varlink_observe_complete(link);
- if (r < 0)
+@@ -2653,13 +2689,17 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
return r;
-+
-+ if (!json_variant_is_blank_array(neighbors)) {
-+ json_variant_set_field(&v, links[i].name, neighbors);
-+ }
}
-- r = table_print(table, NULL);
+- r = table_print(udata.table, NULL);
- if (r < 0)
- return table_log_print_error(r);
+ if (arg_json_format_flags == JSON_FORMAT_OFF) {
-+ r = table_print(table, NULL);
++ r = table_print(udata.table, NULL);
+ if (r < 0)
+ return table_log_print_error(r);
- if (arg_legend) {
-- lldp_capabilities_legend(capabilities_all);
-- printf("\n%i neighbors listed.\n", neighbors_count);
+- lldp_capabilities_legend(udata.capabilities_all);
+- printf("\n%i neighbors listed.\n", udata.neighbors_count);
+ if (arg_legend) {
-+ lldp_capabilities_legend(capabilities_all);
-+ printf("\n%i neighbors listed.\n", neighbors_count);
++ lldp_capabilities_legend(udata.capabilities_all);
++ printf("\n%i neighbors listed.\n", udata.neighbors_count);
+ }
+ } else {
-+ json_variant_dump(v, arg_json_format_flags, NULL, NULL);
++ json_variant_dump(udata.json, arg_json_format_flags, NULL, NULL);
}
return 0;
--
-2.33.0
+2.34.1