]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Extend nexthop json helper to display SRv6 encap behavior
authorCarmine Scarpitta <cscarpit@cisco.com>
Thu, 20 Feb 2025 10:33:56 +0000 (11:33 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Wed, 30 Apr 2025 16:54:43 +0000 (16:54 +0000)
This commit extends the `show ip route json` and `show ipv6 route json`
output to display the SRv6 encapsulation behavior associated with the
SRv6 nexthop.

```
router# show ipv6 route json
[...]
"2001:db8:1:1::1/128": [
{
"prefix": "2001:db8:1:1::1/128",
"prefixLen": 128,
"protocol": "static",
"selected": true,
"destSelected": true,
"distance": 1,
"metric": 0,
"installed": true,
"nexthops": [
{
"directlyConnected": true,
"active": true,
"weight": 1,
"seg6local": {
"action": "unspec"
},
"seg6": [
"fcbb:bbbb:1:2:3:4:5:6",
"fcbb:bbbb:7:8:fe00::"
],
"srv6EncapBehavior": "H.Encaps"
}
]
}
],
[...]
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
lib/nexthop.c

index 09ff295a98441bcc02a2542e9fb9bb989acf0a2a..b17205e1bf274e4c0b7e634d2b645eb6ad8445f5 100644 (file)
@@ -1348,6 +1348,9 @@ void nexthop_json_helper(json_object *json_nexthop,
                                                &nexthop->nh_srv6->seg6_segs
                                                         ->seg[0]);
                        json_object_object_add(json_nexthop, "seg6", json_seg6);
+                       json_object_string_add(json_nexthop, "srv6EncapBehavior",
+                                              srv6_headend_behavior2str(
+                                                      nexthop->nh_srv6->seg6_segs->encap_behavior));
                } else {
                        if (nexthop->nh_srv6->seg6_segs) {
                                json_segs = json_object_new_array();
@@ -1364,6 +1367,10 @@ void nexthop_json_helper(json_object *json_nexthop,
                                                                 ->seg[seg_idx]));
                                json_object_object_add(json_nexthop, "seg6",
                                                       json_segs);
+                               json_object_string_add(json_nexthop, "srv6EncapBehavior",
+                                                      srv6_headend_behavior2str(
+                                                              nexthop->nh_srv6->seg6_segs
+                                                                      ->encap_behavior));
                        }
                }
        }