api: clean up use of deprecated flag
[vpp.git] / src / plugins / nat / nat64_db.c
index ca8358e..6e4973b 100644 (file)
@@ -23,8 +23,8 @@
 #include <vnet/fib/fib_table.h>
 
 int
-nat64_db_init (nat64_db_t * db, u32 bib_buckets, u32 bib_memory_size,
-              u32 st_buckets, u32 st_memory_size,
+nat64_db_init (nat64_db_t * db, u32 bib_buckets, uword bib_memory_size,
+              u32 st_buckets, uword st_memory_size,
               nat64_db_free_addr_port_function_t free_addr_port_cb)
 {
   clib_bihash_init_24_8 (&db->bib.in2out, "bib-in2out", bib_buckets,
@@ -50,7 +50,8 @@ nat64_db_init (nat64_db_t * db, u32 bib_buckets, u32 bib_memory_size,
 }
 
 nat64_db_bib_entry_t *
-nat64_db_bib_entry_create (nat64_db_t * db, ip6_address_t * in_addr,
+nat64_db_bib_entry_create (u32 thread_index, nat64_db_t * db,
+                          ip6_address_t * in_addr,
                           ip4_address_t * out_addr, u16 in_port,
                           u16 out_port, u32 fib_index, u8 proto,
                           u8 is_static)
@@ -63,20 +64,20 @@ nat64_db_bib_entry_create (nat64_db_t * db, ip6_address_t * in_addr,
   if (db->bib.bib_entries_num >= db->bib.limit)
     {
       db->free_addr_port_cb (db, out_addr, out_port, proto);
-      nat_ipfix_logging_max_bibs (db->bib.limit);
+      nat_ipfix_logging_max_bibs (thread_index, db->bib.limit);
       return 0;
     }
 
   /* create pool entry */
-  switch (ip_proto_to_snat_proto (proto))
+  switch (ip_proto_to_nat_proto (proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       pool_get (db->bib._##n##_bib, bibe); \
       kv.value = bibe - db->bib._##n##_bib; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -119,13 +120,14 @@ nat64_db_bib_entry_create (nat64_db_t * db, ip6_address_t * in_addr,
   clib_bihash_add_del_24_8 (&db->bib.out2in, &kv, 1);
 
   fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
-  nat_ipfix_logging_nat64_bib (in_addr, out_addr, proto, in_port, out_port,
-                              fib->ft_table_id, 1);
+  nat_ipfix_logging_nat64_bib (thread_index, in_addr, out_addr, proto,
+                              in_port, out_port, fib->ft_table_id, 1);
   return bibe;
 }
 
 void
-nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe)
+nat64_db_bib_entry_free (u32 thread_index, nat64_db_t * db,
+                        nat64_db_bib_entry_t * bibe)
 {
   nat64_db_bib_entry_key_t bibe_key;
   clib_bihash_kv_24_8_t kv;
@@ -134,15 +136,15 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe)
   nat64_db_st_entry_t *st, *ste;
   fib_table_t *fib;
 
-  switch (ip_proto_to_snat_proto (bibe->proto))
+  switch (ip_proto_to_nat_proto (bibe->proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       bib = db->bib._##n##_bib; \
       st = db->st._##n##_st; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -164,7 +166,8 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe)
                               vec_add1 (ste_to_be_free, ste - st);}
                    ));
       vec_foreach (ste_index, ste_to_be_free)
-       nat64_db_st_entry_free (db, pool_elt_at_index (st, ste_index[0]));
+       nat64_db_st_entry_free (thread_index, db,
+                               pool_elt_at_index (st, ste_index[0]));
       vec_free (ste_to_be_free);
     }
 
@@ -193,8 +196,8 @@ nat64_db_bib_entry_free (nat64_db_t * db, nat64_db_bib_entry_t * bibe)
     db->free_addr_port_cb (db, &bibe->out_addr, bibe->out_port, bibe->proto);
 
   fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
-  nat_ipfix_logging_nat64_bib (&bibe->in_addr, &bibe->out_addr, bibe->proto,
-                              bibe->in_port, bibe->out_port,
+  nat_ipfix_logging_nat64_bib (thread_index, &bibe->in_addr, &bibe->out_addr,
+                              bibe->proto, bibe->in_port, bibe->out_port,
                               fib->ft_table_id, 0);
 
   /* delete from pool */
@@ -211,14 +214,14 @@ nat64_db_bib_entry_find (nat64_db_t * db, ip46_address_t * addr, u16 port,
   clib_bihash_kv_24_8_t kv, value;
   nat64_db_bib_entry_t *bib;
 
-  switch (ip_proto_to_snat_proto (proto))
+  switch (ip_proto_to_nat_proto (proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       bib = db->bib._##n##_bib; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -259,7 +262,7 @@ nat64_db_bib_walk (nat64_db_t * db, u8 proto,
         if (fn (bibe, ctx)) \
           return; \
       }));
-      foreach_snat_protocol
+      foreach_nat_protocol
     #undef _
       bib = db->bib._unk_proto_bib;
       pool_foreach (bibe, bib, ({
@@ -270,14 +273,14 @@ nat64_db_bib_walk (nat64_db_t * db, u8 proto,
     }
   else
     {
-      switch (ip_proto_to_snat_proto (proto))
+      switch (ip_proto_to_nat_proto (proto))
        {
     /* *INDENT-OFF* */
     #define _(N, i, n, s) \
-        case SNAT_PROTOCOL_##N: \
+        case NAT_PROTOCOL_##N: \
           bib = db->bib._##n##_bib; \
           break;
-          foreach_snat_protocol
+          foreach_nat_protocol
     #undef _
     /* *INDENT-ON* */
        default:
@@ -300,14 +303,14 @@ nat64_db_bib_entry_by_index (nat64_db_t * db, u8 proto, u32 bibe_index)
 {
   nat64_db_bib_entry_t *bib;
 
-  switch (ip_proto_to_snat_proto (proto))
+  switch (ip_proto_to_nat_proto (proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       bib = db->bib._##n##_bib; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -333,7 +336,7 @@ nat64_db_st_walk (nat64_db_t * db, u8 proto,
         if (fn (ste, ctx)) \
           return; \
       }));
-      foreach_snat_protocol
+      foreach_nat_protocol
     #undef _
       st = db->st._unk_proto_st;
       pool_foreach (ste, st, ({
@@ -344,14 +347,14 @@ nat64_db_st_walk (nat64_db_t * db, u8 proto,
     }
   else
     {
-      switch (ip_proto_to_snat_proto (proto))
+      switch (ip_proto_to_nat_proto (proto))
        {
     /* *INDENT-OFF* */
     #define _(N, i, n, s) \
-        case SNAT_PROTOCOL_##N: \
+        case NAT_PROTOCOL_##N: \
           st = db->st._##n##_st; \
           break;
-          foreach_snat_protocol
+          foreach_nat_protocol
     #undef _
     /* *INDENT-ON* */
        default:
@@ -370,7 +373,8 @@ nat64_db_st_walk (nat64_db_t * db, u8 proto,
 }
 
 nat64_db_st_entry_t *
-nat64_db_st_entry_create (nat64_db_t * db, nat64_db_bib_entry_t * bibe,
+nat64_db_st_entry_create (u32 thread_index, nat64_db_t * db,
+                         nat64_db_bib_entry_t * bibe,
                          ip6_address_t * in_r_addr,
                          ip4_address_t * out_r_addr, u16 r_port)
 {
@@ -382,21 +386,21 @@ nat64_db_st_entry_create (nat64_db_t * db, nat64_db_bib_entry_t * bibe,
 
   if (db->st.st_entries_num >= db->st.limit)
     {
-      nat_ipfix_logging_max_sessions (db->st.limit);
+      nat_ipfix_logging_max_sessions (thread_index, db->st.limit);
       return 0;
     }
 
   /* create pool entry */
-  switch (ip_proto_to_snat_proto (bibe->proto))
+  switch (ip_proto_to_nat_proto (bibe->proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       pool_get (db->st._##n##_st, ste); \
       kv.value = ste - db->st._##n##_st; \
       bib = db->bib._##n##_bib; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -452,8 +456,9 @@ nat64_db_st_entry_create (nat64_db_t * db, nat64_db_bib_entry_t * bibe,
   clib_bihash_add_del_48_8 (&db->st.out2in, &kv, 1);
 
   fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
-  nat_ipfix_logging_nat64_session (&bibe->in_addr, &bibe->out_addr,
-                                  bibe->proto, bibe->in_port, bibe->out_port,
+  nat_ipfix_logging_nat64_session (thread_index, &bibe->in_addr,
+                                  &bibe->out_addr, bibe->proto,
+                                  bibe->in_port, bibe->out_port,
                                   &ste->in_r_addr, &ste->out_r_addr,
                                   ste->r_port, ste->r_port, fib->ft_table_id,
                                   1);
@@ -464,7 +469,8 @@ nat64_db_st_entry_create (nat64_db_t * db, nat64_db_bib_entry_t * bibe,
 }
 
 void
-nat64_db_st_entry_free (nat64_db_t * db, nat64_db_st_entry_t * ste)
+nat64_db_st_entry_free (u32 thread_index,
+                       nat64_db_t * db, nat64_db_st_entry_t * ste)
 {
   nat64_db_st_entry_t *st;
   nat64_db_bib_entry_t *bib, *bibe;
@@ -472,15 +478,15 @@ nat64_db_st_entry_free (nat64_db_t * db, nat64_db_st_entry_t * ste)
   clib_bihash_kv_48_8_t kv;
   fib_table_t *fib;
 
-  switch (ip_proto_to_snat_proto (ste->proto))
+  switch (ip_proto_to_nat_proto (ste->proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       st = db->st._##n##_st; \
       bib = db->bib._##n##_bib; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -526,8 +532,9 @@ nat64_db_st_entry_free (nat64_db_t * db, nat64_db_st_entry_t * ste)
   clib_bihash_add_del_48_8 (&db->st.out2in, &kv, 0);
 
   fib = fib_table_get (bibe->fib_index, FIB_PROTOCOL_IP6);
-  nat_ipfix_logging_nat64_session (&bibe->in_addr, &bibe->out_addr,
-                                  bibe->proto, bibe->in_port, bibe->out_port,
+  nat_ipfix_logging_nat64_session (thread_index, &bibe->in_addr,
+                                  &bibe->out_addr, bibe->proto,
+                                  bibe->in_port, bibe->out_port,
                                   &ste->in_r_addr, &ste->out_r_addr,
                                   ste->r_port, ste->r_port, fib->ft_table_id,
                                   0);
@@ -543,7 +550,7 @@ nat64_db_st_entry_free (nat64_db_t * db, nat64_db_st_entry_t * ste)
 
   /* delete BIB entry if last session and dynamic */
   if (!bibe->is_static && !bibe->ses_num)
-    nat64_db_bib_entry_free (db, bibe);
+    nat64_db_bib_entry_free (thread_index, db, bibe);
 }
 
 nat64_db_st_entry_t *
@@ -556,14 +563,14 @@ nat64_db_st_entry_find (nat64_db_t * db, ip46_address_t * l_addr,
   nat64_db_st_entry_key_t ste_key;
   clib_bihash_kv_48_8_t kv, value;
 
-  switch (ip_proto_to_snat_proto (proto))
+  switch (ip_proto_to_nat_proto (proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       st = db->st._##n##_st; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -599,14 +606,14 @@ nat64_db_st_entry_get_index (nat64_db_t * db, nat64_db_st_entry_t * ste)
 {
   nat64_db_st_entry_t *st;
 
-  switch (ip_proto_to_snat_proto (ste->proto))
+  switch (ip_proto_to_nat_proto (ste->proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       st = db->st._##n##_st; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -622,14 +629,14 @@ nat64_db_st_entry_by_index (nat64_db_t * db, u8 proto, u32 ste_index)
 {
   nat64_db_st_entry_t *st;
 
-  switch (ip_proto_to_snat_proto (proto))
+  switch (ip_proto_to_nat_proto (proto))
     {
 /* *INDENT-OFF* */
 #define _(N, i, n, s) \
-    case SNAT_PROTOCOL_##N: \
+    case NAT_PROTOCOL_##N: \
       st = db->st._##n##_st; \
       break;
-      foreach_snat_protocol
+      foreach_nat_protocol
 #undef _
 /* *INDENT-ON* */
     default:
@@ -641,7 +648,7 @@ nat64_db_st_entry_by_index (nat64_db_t * db, u8 proto, u32 ste_index)
 }
 
 void
-nad64_db_st_free_expired (nat64_db_t * db, u32 now)
+nad64_db_st_free_expired (u32 thread_index, nat64_db_t * db, u32 now)
 {
   u32 *ste_to_be_free = 0, *ste_index;
   nat64_db_st_entry_t *st, *ste;
@@ -650,16 +657,17 @@ nad64_db_st_free_expired (nat64_db_t * db, u32 now)
 #define _(N, i, n, s) \
   st = db->st._##n##_st; \
   pool_foreach (ste, st, ({\
-    if (i == SNAT_PROTOCOL_TCP && !ste->tcp_state) \
+    if (i == NAT_PROTOCOL_TCP && !ste->tcp_state) \
       continue; \
     if (ste->expire < now) \
       vec_add1 (ste_to_be_free, ste - st); \
   })); \
   vec_foreach (ste_index, ste_to_be_free) \
-    nat64_db_st_entry_free (db, pool_elt_at_index(st, ste_index[0])); \
+    nat64_db_st_entry_free (thread_index, db, \
+                            pool_elt_at_index(st, ste_index[0])); \
   vec_free (ste_to_be_free); \
   ste_to_be_free = 0;
-  foreach_snat_protocol
+  foreach_nat_protocol
 #undef _
   st = db->st._unk_proto_st;
   pool_foreach (ste, st, ({
@@ -667,13 +675,15 @@ nad64_db_st_free_expired (nat64_db_t * db, u32 now)
       vec_add1 (ste_to_be_free, ste - st);
   }));
   vec_foreach (ste_index, ste_to_be_free)
-    nat64_db_st_entry_free (db, pool_elt_at_index(st, ste_index[0]));
+    nat64_db_st_entry_free (thread_index, db,
+                            pool_elt_at_index(st, ste_index[0]));
   vec_free (ste_to_be_free);
 /* *INDENT-ON* */
 }
 
 void
-nat64_db_free_out_addr (nat64_db_t * db, ip4_address_t * out_addr)
+nat64_db_free_out_addr (u32 thread_index,
+                       nat64_db_t * db, ip4_address_t * out_addr)
 {
   u32 *ste_to_be_free = 0, *ste_index;
   nat64_db_st_entry_t *st, *ste;
@@ -689,10 +699,11 @@ nat64_db_free_out_addr (nat64_db_t * db, ip4_address_t * out_addr)
       vec_add1 (ste_to_be_free, ste - st); \
   })); \
   vec_foreach (ste_index, ste_to_be_free) \
-    nat64_db_st_entry_free (db, pool_elt_at_index(st, ste_index[0])); \
+    nat64_db_st_entry_free (thread_index, db, \
+                            pool_elt_at_index(st, ste_index[0])); \
   vec_free (ste_to_be_free); \
   ste_to_be_free = 0;
-  foreach_snat_protocol
+  foreach_nat_protocol
 #undef _
   st = db->st._unk_proto_st;
   pool_foreach (ste, st, ({
@@ -701,7 +712,8 @@ nat64_db_free_out_addr (nat64_db_t * db, ip4_address_t * out_addr)
       vec_add1 (ste_to_be_free, ste - st);
   }));
   vec_foreach (ste_index, ste_to_be_free)
-    nat64_db_st_entry_free (db, pool_elt_at_index(st, ste_index[0]));
+    nat64_db_st_entry_free (thread_index, db,
+                            pool_elt_at_index(st, ste_index[0]));
   vec_free (ste_to_be_free);
   db->addr_free = 0;
 /* *INDENT-ON* */