Commit 2a3c025037 for frr
commit 2a3c02503729ea3167f2625bcec2d5dfb1391d93
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date: Mon Nov 30 16:43:19 2026 +0100
lib: keep the ipv4 adj-sids in the json display of an edge
The json display of a TED edge with both IPv4 and IPv6 MPLS Adj-SIDs,
for instance an IS-IS edge in a single topology carrying both address
families, shows only the IPv6 Adj-SIDs in its "segment-routing" array
("show isis mpls-te database edge <edge> json").
ls_show_edge_json() always creates a new "segment-routing" array for
the primary IPv6 Adj-SID. json_object_object_add() then replaces the
array holding the IPv4 Adj-SIDs, which are lost. The backup Adj-SID
blocks already reuse the array when it exists.
Fix this by creating the array for the primary IPv6 Adj-SID only when
no IPv4 Adj-SID was added.
Fixes: 8693b4d66e02 ("lib: Update Link State functions to handle IPv6")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
diff --git a/lib/link_state.c b/lib/link_state.c
index fd59242c5f..6940c8e5ae 100644
--- a/lib/link_state.c
+++ b/lib/link_state.c
@@ -2818,8 +2818,10 @@ static void ls_show_edge_json(struct ls_edge *edge, struct json_object *json)
json_object_array_add(jsr, jobj);
}
if (CHECK_FLAG(attr->flags, LS_ATTR_ADJ_SID6)) {
- jsr = json_object_new_array();
- json_object_object_add(json, "segment-routing", jsr);
+ if (!jsr) {
+ jsr = json_object_new_array();
+ json_object_object_add(json, "segment-routing", jsr);
+ }
jobj = json_object_new_object();
json_object_int_add(jobj, "adj-sid",
attr->adj_sid[ADJ_PRI_IPV6].sid);