ipsec: move the IPSec SA pool out of ipsec_main
[vpp.git] / src / vnet / ipsec / esp_encrypt.c
index 08f82db..16bca1d 100644 (file)
@@ -646,7 +646,7 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
                                             current_sa_bytes);
          current_sa_packets = current_sa_bytes = 0;
 
-         sa0 = pool_elt_at_index (im->sad, sa_index0);
+         sa0 = ipsec_sa_get (sa_index0);
 
          /* fetch the second cacheline ASAP */
          CLIB_PREFETCH (sa0->cacheline1, CLIB_CACHE_LINE_BYTES, LOAD);
@@ -685,6 +685,7 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
 
       if (PREDICT_FALSE (thread_index != sa0->thread_index))
        {
+         vnet_buffer (b[0])->ipsec.thread_index = sa0->thread_index;
          esp_set_next_index (is_async, from, nexts, from[b - bufs],
                              &n_async_drop, handoff_next, next);
          goto trace;
@@ -829,6 +830,7 @@ esp_encrypt_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            }
          else
            next[0] = ESP_ENCRYPT_NEXT_INTERFACE_OUTPUT;
+         b[0]->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
        }
       else                     /* transport mode */
        {
@@ -1476,6 +1478,31 @@ VLIB_REGISTER_NODE (esp6_no_crypto_tun_node) =
 };
 /* *INDENT-ON* */
 
+#ifndef CLIB_MARCH_VARIANT
+
+static clib_error_t *
+esp_encrypt_init (vlib_main_t *vm)
+{
+  ipsec_main_t *im = &ipsec_main;
+
+  im->esp4_enc_fq_index =
+    vlib_frame_queue_main_init (esp4_encrypt_node.index, 0);
+  im->esp6_enc_fq_index =
+    vlib_frame_queue_main_init (esp6_encrypt_node.index, 0);
+  im->esp4_enc_tun_fq_index =
+    vlib_frame_queue_main_init (esp4_encrypt_tun_node.index, 0);
+  im->esp6_enc_tun_fq_index =
+    vlib_frame_queue_main_init (esp6_encrypt_tun_node.index, 0);
+  im->esp_mpls_enc_tun_fq_index =
+    vlib_frame_queue_main_init (esp_mpls_encrypt_tun_node.index, 0);
+
+  return 0;
+}
+
+VLIB_INIT_FUNCTION (esp_encrypt_init);
+
+#endif
+
 /*
  * fd.io coding-style-patch-verification: ON
  *