]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: add flavors display in json attributes
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 11 Apr 2025 19:41:54 +0000 (21:41 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 1 May 2025 07:15:53 +0000 (09:15 +0200)
Add flavors display in json nexthop attributes.

> # ip -6 route add 2007::1 encap seg6local action End flavors psp dev dum1
> # vtysh -c "show ipv6 route json"
> [..]
> ,"2007::1/128":[{"prefix":"2007::1/128","prefixLen":128,"protocol":"kernel","vrfId":0,
> "vrfName":"default","selected":true,"destSelected":true,"distance":0,"metric":1024,
> "installed":true,"table":254,"internalStatus":16,"internalFlags":8,"internalNextHopNum":1,
> "internalNextHopActiveNum":1,"nexthopGroupId":28,"installedNexthopGroupId":28,"uptime":"00:04:20",
> "nexthops":[{"flags":3,"fib":true,"directlyConnected":true,"interfaceIndex":19,"interfaceName":"dum1",
> "active":true,"weight":1,"seg6local":{"action":"End","sidStructure":{"blockLen":0,"nodeLen":0,"funcLen":0,"argLen":0}},
> "seg6localContext":{"flavors":["psp"]}}]}]
> [..]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
lib/srv6.c

index e8a0d505df9aca07a731a33a933f1df8b019621a..4e973e3642be2f0dd192dab26386d02efb1fc2b5 100644 (file)
@@ -71,6 +71,21 @@ int snprintf_seg6_segs(char *str,
        return strlen(str);
 }
 
+static void seg6local_flavors2json(json_object *json, const struct seg6local_flavors_info *flv_info)
+{
+       json_object *json_flavors;
+
+       json_flavors = json_object_new_array();
+       json_object_object_add(json, "flavors", json_flavors);
+
+       if (CHECK_SRV6_FLV_OP(flv_info->flv_ops, ZEBRA_SEG6_LOCAL_FLV_OP_PSP))
+               json_array_string_add(json_flavors, "psp");
+       if (CHECK_SRV6_FLV_OP(flv_info->flv_ops, ZEBRA_SEG6_LOCAL_FLV_OP_USP))
+               json_array_string_add(json_flavors, "usp");
+       if (CHECK_SRV6_FLV_OP(flv_info->flv_ops, ZEBRA_SEG6_LOCAL_FLV_OP_USD))
+               json_array_string_add(json_flavors, "usd");
+}
+
 void srv6_sid_structure2json(const struct seg6local_context *ctx, json_object *json)
 {
        json_object_int_add(json, "blockLen", ctx->block_len);
@@ -82,6 +97,7 @@ void srv6_sid_structure2json(const struct seg6local_context *ctx, json_object *j
 void seg6local_context2json(const struct seg6local_context *ctx,
                            uint32_t action, json_object *json)
 {
+       seg6local_flavors2json(json, &ctx->flv);
        switch (action) {
        case ZEBRA_SEG6_LOCAL_ACTION_END:
                return;