misc: fix coverity warnings
[vpp.git] / src / vnet / geneve / geneve.c
index 8b773c1..a54a538 100644 (file)
@@ -16,6 +16,7 @@
 #include <vnet/ip/format.h>
 #include <vnet/fib/fib_entry.h>
 #include <vnet/fib/fib_table.h>
+#include <vnet/fib/fib_entry_track.h>
 #include <vnet/mfib/mfib_table.h>
 #include <vnet/adj/adj_mcast.h>
 #include <vnet/interface.h>
@@ -311,7 +312,7 @@ vtep_addr_unref (ip46_address_t * ip)
   uword *vtep = ip46_address_is_ip4 (ip) ?
     hash_get (geneve_main.vtep4, ip->ip4.as_u32) :
     hash_get_mem (geneve_main.vtep6, &ip->ip6);
-  ASSERT (vtep);
+  ALWAYS_ASSERT (vtep);
   if (--(*vtep) != 0)
     return *vtep;
   ip46_address_is_ip4 (ip) ?
@@ -498,12 +499,11 @@ int vnet_geneve_add_del_tunnel
           * re-stack accordingly
           */
          vtep_addr_ref (&t->local);
-         t->fib_entry_index = fib_table_entry_special_add
-           (t->encap_fib_index, &tun_remote_pfx, FIB_SOURCE_RR,
-            FIB_ENTRY_FLAG_NONE);
-         t->sibling_index = fib_entry_child_add
-           (t->fib_entry_index, FIB_NODE_TYPE_GENEVE_TUNNEL,
-            t - vxm->tunnels);
+         t->fib_entry_index = fib_entry_track (t->encap_fib_index,
+                                               &tun_remote_pfx,
+                                               FIB_NODE_TYPE_GENEVE_TUNNEL,
+                                               t - vxm->tunnels,
+                                               &t->sibling_index);
          geneve_tunnel_restack_dpo (t);
        }
       else
@@ -524,8 +524,9 @@ int vnet_geneve_add_del_tunnel
                .frp_addr = zero_addr,
                .frp_sw_if_index = 0xffffffff,
                .frp_fib_index = ~0,
-               .frp_weight = 0,
+               .frp_weight = 1,
                .frp_flags = FIB_ROUTE_PATH_LOCAL,
+               .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD,
              };
              const mfib_prefix_t mpfx = {
                .fp_proto = fp,
@@ -539,17 +540,14 @@ int vnet_geneve_add_del_tunnel
               *  - the accepting interface is that from the API
               */
              mfib_table_entry_path_update (t->encap_fib_index,
-                                           &mpfx,
-                                           MFIB_SOURCE_GENEVE,
-                                           &path, MFIB_ITF_FLAG_FORWARD);
+                                           &mpfx, MFIB_SOURCE_GENEVE, &path);
 
              path.frp_sw_if_index = a->mcast_sw_if_index;
              path.frp_flags = FIB_ROUTE_PATH_FLAG_NONE;
+             path.frp_mitf_flags = MFIB_ITF_FLAG_ACCEPT;
              mfei = mfib_table_entry_path_update (t->encap_fib_index,
                                                   &mpfx,
-                                                  MFIB_SOURCE_GENEVE,
-                                                  &path,
-                                                  MFIB_ITF_FLAG_ACCEPT);
+                                                  MFIB_SOURCE_GENEVE, &path);
 
              /*
               * Create the mcast adjacency to send traffic to the group
@@ -607,8 +605,7 @@ int vnet_geneve_add_del_tunnel
       if (!ip46_address_is_multicast (&t->remote))
        {
          vtep_addr_unref (&t->local);
-         fib_entry_child_remove (t->fib_entry_index, t->sibling_index);
-         fib_table_entry_delete_index (t->fib_entry_index, FIB_SOURCE_RR);
+         fib_entry_untrack (t->fib_entry_index, t->sibling_index);
        }
       else if (vtep_addr_unref (&t->remote) == 0)
        {
@@ -1105,7 +1102,7 @@ set_ip6_geneve_bypass (vlib_main_t * vm,
 VLIB_CLI_COMMAND (set_interface_ip6_geneve_bypass_command, static) = {
   .path = "set interface ip6 geneve-bypass",
   .function = set_ip6_geneve_bypass,
-  .short_help = "set interface ip geneve-bypass <interface> [del]",
+  .short_help = "set interface ip6 geneve-bypass <interface> [del]",
 };
 /* *INDENT-ON* */