sr: Show IPv6 address used as SRv6 Encaps source 26/29826/2
authorAhmed Abdelsalam <ahabdels@cisco.com>
Mon, 9 Nov 2020 14:04:07 +0000 (14:04 +0000)
committerNeale Ranns <nranns@cisco.com>
Tue, 10 Nov 2020 14:50:47 +0000 (14:50 +0000)
Implements CLI to show the IPv6 address used as source address for the SRv6 encapsulation.

Type: feature
Signed-off-by: Ahmed Abdelsalam <ahabdels@cisco.com>
Change-Id: Ia442d9345a7793836148d890745fc5dc92729b6f

src/vnet/srv6/sr.h
src/vnet/srv6/sr_policy_rewrite.c

index 41adef3..7452b95 100644 (file)
@@ -360,6 +360,7 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index,
                    u32 sw_if_index, u8 traffic_type);
 
 extern void sr_set_source (ip6_address_t * address);
+extern ip6_address_t *sr_get_encaps_source ();
 
 extern void sr_set_hop_limit (u8 hop_limit);
 extern u8 sr_get_hop_limit (void);
index 7c4f757..77e1485 100644 (file)
@@ -119,6 +119,12 @@ sr_set_source (ip6_address_t * address)
   clib_memcpy_fast (&sr_pr_encaps_src, address, sizeof (sr_pr_encaps_src));
 }
 
+ip6_address_t *
+sr_get_encaps_source ()
+{
+  return &sr_pr_encaps_src;
+}
+
 static clib_error_t *
 set_sr_src_command_fn (vlib_main_t * vm, unformat_input_t * input,
                       vlib_cli_command_t * cmd)
@@ -1162,6 +1168,27 @@ VLIB_CLI_COMMAND (show_sr_policies_command, static) = {
 };
 /* *INDENT-ON* */
 
+/**
+ * @brief CLI to display onscreen the SR encaps source addr
+ */
+static clib_error_t *
+show_sr_encaps_source_command_fn (vlib_main_t * vm, unformat_input_t * input,
+                                 vlib_cli_command_t * cmd)
+{
+  vlib_cli_output (vm, "SR encaps source addr = %U", format_ip6_address,
+                  sr_get_encaps_source ());
+
+  return 0;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_sr_encaps_source_command, static) = {
+  .path = "show sr encaps source addr",
+  .short_help = "show sr encaps source addr",
+  .function = show_sr_encaps_source_command_fn,
+};
+/* *INDENT-ON* */
+
 /*************************** SR rewrite graph node ****************************/
 /**
  * @brief Trace for the SR Policy Rewrite graph node