Skip to content

Commit

Permalink
zebra: Add CLI command to verify SRv6 Manager
Browse files Browse the repository at this point in the history
Add a new CLI command `show segment-routing srv6 manager [json]` to
verify the overall SRv6 state. The current output displays only the
configured source address of outer encapsulating IPv6 header. The output
can be extended in the future to show more information, including
summary SRv6 information and supported capabilities.

Example:

```
r1# show segment-routing srv6 manager
Parameters:
  Encapsulation:
    Source Address:
      Configured: fc00:0:1::1

r1# show segment-routing srv6 manager json
{
  "parameters":{
    "encapsulation":{
      "sourceAddress":{
        "configured":"fc00:0:1::1"
      }
    }
  }
}
```

Signed-off-by: Carmine Scarpitta <[email protected]>
  • Loading branch information
cscarpitta committed Dec 1, 2023
1 parent 28265cb commit 9b36dd0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions zebra/zebra_srv6_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,45 @@ static struct cmd_node srv6_encap_node = {
.prompt = "%s(config-srv6-encap)# "
};

DEFPY (show_srv6_manager,
show_srv6_manager_cmd,
"show segment-routing srv6 manager [json]",
SHOW_STR
"Segment Routing\n"
"Segment Routing SRv6\n"
"Verify SRv6 Manager\n"
JSON_STR)
{
const bool uj = use_json(argc, argv);
struct zebra_srv6 *srv6 = zebra_srv6_get_default();
json_object *json = NULL;
json_object *json_parameters = NULL;
json_object *json_encapsulation = NULL;
json_object *json_source_address = NULL;

if (uj) {
json = json_object_new_object();
json_parameters = json_object_new_object();
json_object_object_add(json, "parameters", json_parameters);
json_encapsulation = json_object_new_object();
json_object_object_add(json_parameters, "encapsulation",
json_encapsulation);
json_source_address = json_object_new_object();
json_object_object_add(json_encapsulation, "sourceAddress",
json_source_address);
json_object_string_addf(json_source_address, "configured",
"%pI6", &srv6->encap_src_addr);
vty_json(vty, json);
} else {
vty_out(vty, "Parameters:\n");
vty_out(vty, " Encapsulation:\n");
vty_out(vty, " Source Address:\n");
vty_out(vty, " Configured: %pI6\n", &srv6->encap_src_addr);
}

return CMD_SUCCESS;
}

DEFUN (show_srv6_locator,
show_srv6_locator_cmd,
"show segment-routing srv6 locator [json]",
Expand Down Expand Up @@ -508,4 +547,5 @@ void zebra_srv6_vty_init(void)
/* Command for operation */
install_element(VIEW_NODE, &show_srv6_locator_cmd);
install_element(VIEW_NODE, &show_srv6_locator_detail_cmd);
install_element(VIEW_NODE, &show_srv6_manager_cmd);
}

0 comments on commit 9b36dd0

Please sign in to comment.