misc: move to new pool_foreach macros
[vpp.git] / src / vnet / udp / udp_encap.c
index 072bc79..28ea560 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2019 Cisco and/or its affiliates.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
@@ -15,6 +15,7 @@
 
 #include <vnet/udp/udp_encap.h>
 #include <vnet/fib/fib_entry.h>
+#include <vnet/fib/fib_entry_track.h>
 #include <vnet/fib/fib_table.h>
 #include <vnet/dpo/drop_dpo.h>
 
@@ -117,14 +118,10 @@ udp_encap_add_and_lock (fib_protocol_t proto,
     .fp_addr = *dst_ip,
   };
 
-  ue->ue_fib_entry_index =
-    fib_table_entry_special_add (fib_index,
-                                &dst_pfx,
-                                FIB_SOURCE_RR, FIB_ENTRY_FLAG_NONE);
-  ue->ue_fib_sibling =
-    fib_entry_child_add (ue->ue_fib_entry_index,
-                        FIB_NODE_TYPE_UDP_ENCAP, uei);
-
+  ue->ue_fib_entry_index = fib_entry_track (fib_index,
+                                           &dst_pfx,
+                                           FIB_NODE_TYPE_UDP_ENCAP,
+                                           uei, &ue->ue_fib_sibling);
   udp_encap_restack (ue);
 
   return (uei);
@@ -211,7 +208,7 @@ format_udp_encap_i (u8 * s, va_list * args)
   ue = udp_encap_get (uei);
 
   // FIXME
-  s = format (s, "udp-ecap:[%d]: ip-fib-index:%d ", uei, ue->ue_fib_index);
+  s = format (s, "udp-encap:[%d]: ip-fib-index:%d ", uei, ue->ue_fib_index);
   if (FIB_PROTOCOL_IP4 == ue->ue_ip_proto)
     {
       s = format (s, "ip:[src:%U, dst:%U] udp:[src:%d, dst:%d]",
@@ -322,9 +319,7 @@ udp_encap_fib_last_lock_gone (fib_node_t * node)
      */
   dpo_reset (&ue->ue_dpo);
 
-  fib_entry_child_remove (ue->ue_fib_entry_index, ue->ue_fib_sibling);
-  fib_table_entry_delete_index (ue->ue_fib_entry_index, FIB_SOURCE_RR);
-
+  fib_entry_untrack (ue->ue_fib_entry_index, ue->ue_fib_sibling);
 
   pool_put (udp_encap_pool, ue);
 }
@@ -513,11 +508,11 @@ udp_encap_walk (udp_encap_walk_cb_t cb, void *ctx)
   index_t uei;
 
   /* *INDENT-OFF* */
-  pool_foreach_index(uei, udp_encap_pool,
-  ({
+  pool_foreach_index (uei, udp_encap_pool)
+   {
     if (WALK_STOP == cb(uei, ctx))
       break;
-  }));
+  }
   /* *INDENT-ON* */
 }
 
@@ -542,10 +537,10 @@ udp_encap_show (vlib_main_t * vm,
   if (INDEX_INVALID == uei)
     {
       /* *INDENT-OFF* */
-      pool_foreach_index(uei, udp_encap_pool,
-      ({
+      pool_foreach_index (uei, udp_encap_pool)
+       {
         vlib_cli_output(vm, "%U", format_udp_encap, uei, 0);
-      }));
+      }
       /* *INDENT-ON* */
     }
   else