session: show session rules does not display ip6 entries 79/41279/4
authorSteven Luong <[email protected]>
Thu, 18 Jul 2024 16:10:48 +0000 (09:10 -0700)
committerFlorin Coras <[email protected]>
Fri, 19 Jul 2024 17:05:29 +0000 (17:05 +0000)
1. Adding an ip6 rule entry
session rule add proto tcp ee80::/10 0 ee80::/10 0 action 2

2. show session rules does not display the entry.
show session rules tcp

3. However, show session rules for a specific entry shows the entry
show session rules tcp ee80::/10 0 ee80::/10 0

Type: fix

Change-Id: I65c881665d3698a2a9452a186ed657eee0bf13e0
Signed-off-by: Steven Luong <[email protected]>
src/vnet/session/session_lookup.c

index ff20bc2..ff6e581 100644 (file)
@@ -1665,9 +1665,9 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input,
       else if (unformat (input, "appns %_%v%_", &ns_id))
        ;
       else if (unformat (input, "scope global"))
-       scope = 1;
+       scope = SESSION_RULE_SCOPE_GLOBAL;
       else if (unformat (input, "scope local"))
-       scope = 2;
+       scope = SESSION_RULE_SCOPE_LOCAL;
       else if (unformat (input, "%U/%d %d %U/%d %d", unformat_ip4_address,
                         &lcl_ip.ip4, &lcl_plen, &lcl_port,
                         unformat_ip4_address, &rmt_ip.ip4, &rmt_plen,
@@ -1709,7 +1709,7 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input,
       app_ns = app_namespace_get_default ();
     }
 
-  if (scope == 1 || scope == 0)
+  if (scope == SESSION_RULE_SCOPE_GLOBAL || scope == 0)
     {
       fib_proto = is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
       fib_index = is_ip4 ? app_ns->ip4_fib_index : app_ns->ip6_fib_index;
@@ -1730,9 +1730,36 @@ show_session_rules_command_fn (vlib_main_t * vm, unformat_input_t * input,
 
   vlib_cli_output (vm, "%U rules table", format_transport_proto,
                   transport_proto);
-  srt = &st->session_rules[transport_proto];
-  session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP4);
-  session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP6);
+  if (scope == SESSION_RULE_SCOPE_LOCAL)
+    {
+      if (st)
+       {
+         srt = &st->session_rules[transport_proto];
+         session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP4);
+         session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP6);
+       }
+    }
+  else
+    {
+      /*
+       * 2 separate session tables for global entries, 1 for ip4 and 1 for ip6
+       */
+      st = session_table_get_for_fib_index (FIB_PROTOCOL_IP4,
+                                           app_ns->ip4_fib_index);
+      if (st)
+       {
+         srt = &st->session_rules[transport_proto];
+         session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP4);
+       }
+
+      st = session_table_get_for_fib_index (FIB_PROTOCOL_IP6,
+                                           app_ns->ip6_fib_index);
+      if (st)
+       {
+         srt = &st->session_rules[transport_proto];
+         session_rules_table_cli_dump (vm, srt, FIB_PROTOCOL_IP6);
+       }
+    }
 
   vec_free (ns_id);
   return 0;