acl-plugin: introduce a format function for l4 session key
[vpp.git] / src / plugins / acl / sess_mgmt_node.c
index f38677f..7da6da4 100644 (file)
 #include <plugins/acl/public_inlines.h>
 #include <plugins/acl/session_inlines.h>
 
-static u8 *
-format_ip6_session_bihash_kv (u8 * s, va_list * args)
+
+
+static_always_inline u8 *
+format_ip46_session_bihash_kv (u8 * s, va_list * args, int is_ip6)
 {
-  clib_bihash_kv_40_8_t *kv_40_8 = va_arg (*args, clib_bihash_kv_40_8_t *);
   fa_5tuple_t a5t;
+  void *paddr0;
+  void *paddr1;
+  void *format_addr_func;
+
+  if (is_ip6)
+    {
+      clib_bihash_kv_40_8_t *kv_40_8 =
+       va_arg (*args, clib_bihash_kv_40_8_t *);
+      a5t.kv_40_8 = *kv_40_8;
+      paddr0 = &a5t.ip6_addr[0];
+      paddr1 = &a5t.ip6_addr[1];
+      format_addr_func = format_ip6_address;
+    }
+  else
+    {
+      clib_bihash_kv_16_8_t *kv_16_8 =
+       va_arg (*args, clib_bihash_kv_16_8_t *);
+      a5t.kv_16_8 = *kv_16_8;
+      paddr0 = &a5t.ip4_addr[0];
+      paddr1 = &a5t.ip4_addr[1];
+      format_addr_func = format_ip4_address;
+    }
 
-  a5t.kv_40_8 = *kv_40_8;
   fa_full_session_id_t *sess = (fa_full_session_id_t *) & a5t.pkt;
 
-  return (format (s, "l3 %U -> %U"
-                 " l4 lsb_of_sw_if_index %d proto %d l4_is_input %d l4_slow_path %d l4_reserved0 %d port %d -> %d | sess id %d thread id %d epoch %04x",
-                 format_ip6_address, &a5t.ip6_addr[0],
-                 format_ip6_address, &a5t.ip6_addr[1],
-                 a5t.l4.lsb_of_sw_if_index,
-                 a5t.l4.proto, a5t.l4.is_input, a5t.l4.is_slowpath,
-                 a5t.l4.reserved0, a5t.l4.port[0], a5t.l4.port[1],
+  return (format (s, "l3 %U -> %U %U | sess id %d thread id %d epoch %04x",
+                 format_addr_func, paddr0,
+                 format_addr_func, paddr1,
+                 format_fa_session_l4_key, &a5t.l4,
                  sess->session_index, sess->thread_index,
                  sess->intf_policy_epoch));
 }
 
 static u8 *
-format_ip4_session_bihash_kv (u8 * s, va_list * args)
+format_ip6_session_bihash_kv (u8 * s, va_list * args)
 {
-  clib_bihash_kv_16_8_t *kv_16_8 = va_arg (*args, clib_bihash_kv_16_8_t *);
-  fa_5tuple_t a5t;
-
-  a5t.kv_16_8 = *kv_16_8;
-  fa_full_session_id_t *sess = (fa_full_session_id_t *) & a5t.pkt;
+  return format_ip46_session_bihash_kv (s, args, 1);
+}
 
-  return (format (s, "l3 %U -> %U"
-                 " l4 lsb_of_sw_if_index %d proto %d l4_is_input %d l4_slow_path %d l4_reserved0 %d port %d -> %d | sess id %d thread id %d epoch %04x",
-                 format_ip4_address, &a5t.ip4_addr[0],
-                 format_ip4_address, &a5t.ip4_addr[1],
-                 a5t.l4.lsb_of_sw_if_index,
-                 a5t.l4.proto, a5t.l4.is_input, a5t.l4.is_slowpath,
-                 a5t.l4.reserved0, a5t.l4.port[0], a5t.l4.port[1],
-                 sess->session_index, sess->thread_index,
-                 sess->intf_policy_epoch));
+static u8 *
+format_ip4_session_bihash_kv (u8 * s, va_list * args)
+{
+  return format_ip46_session_bihash_kv (s, args, 0);
 }
 
 
@@ -689,7 +700,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                    }
                }
            }
-           acl_log_err
+           acl_log_info
              ("ACL_FA_CLEANER_DELETE_BY_SW_IF_INDEX bitmap: %U, clear_all: %u",
               format_bitmap_hex, clear_sw_if_index_bitmap, clear_all);
            vec_foreach (pw0, am->per_worker_data)
@@ -727,7 +738,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                      pw0->pending_clear_sw_if_index_bitmap =
                        clib_bitmap_dup (clear_sw_if_index_bitmap);
                    }
-                 acl_log_err
+                 acl_log_info
                    ("ACL_FA_CLEANER: thread %u, pending clear bitmap: %U",
                     (am->per_worker_data - pw0), format_bitmap_hex,
                     pw0->pending_clear_sw_if_index_bitmap);
@@ -738,8 +749,9 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
            send_interrupts_to_workers (vm, am);
 
            /* now wait till they all complete */
-           acl_log_err ("CLEANER mains len: %u per-worker len: %d",
-                        vec_len (vlib_mains), vec_len (am->per_worker_data));
+           acl_log_info ("CLEANER mains len: %u per-worker len: %d",
+                         vec_len (vlib_mains),
+                         vec_len (am->per_worker_data));
            vec_foreach (pw0, am->per_worker_data)
            {
              CLIB_MEMORY_BARRIER ();
@@ -758,7 +770,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                    }
                }
            }
-           acl_log_err ("ACL_FA_NODE_CLEAN: cleaning done");
+           acl_log_info ("ACL_FA_NODE_CLEAN: cleaning done");
            clib_bitmap_free (clear_sw_if_index_bitmap);
          }
          am->fa_cleaner_cnt_delete_by_sw_index_ok++;