fib: fix crash when create vxlan/vxlan-gpe/geneve/gtpu tunnel.
[vpp.git] / src / plugins / gtpu / gtpu.c
index 960454a..d3a2f05 100644 (file)
@@ -292,7 +292,7 @@ ip_udp_gtpu_rewrite (gtpu_tunnel_t * t, bool is_ip6)
 
   t->rewrite = r.rw;
   /* Now only support 8-byte gtpu header. TBD */
-  _vec_len (t->rewrite) = sizeof (ip4_gtpu_header_t) - 4;
+  vec_set_len (t->rewrite, sizeof (ip4_gtpu_header_t) - 4);
 
   return;
 }
@@ -419,7 +419,7 @@ int vnet_gtpu_add_mod_del_tunnel
          vnet_interface_main_t *im = &vnm->interface_main;
          hw_if_index = gtm->free_gtpu_tunnel_hw_if_indices
            [vec_len (gtm->free_gtpu_tunnel_hw_if_indices) - 1];
-         _vec_len (gtm->free_gtpu_tunnel_hw_if_indices) -= 1;
+         vec_dec_len (gtm->free_gtpu_tunnel_hw_if_indices, 1);
 
          hi = vnet_get_hw_interface (vnm, hw_if_index);
          hi->dev_instance = t - gtm->tunnels;
@@ -473,7 +473,8 @@ int vnet_gtpu_add_mod_del_tunnel
       fib_prefix_t tun_dst_pfx;
       vnet_flood_class_t flood_class = VNET_FLOOD_CLASS_TUNNEL_NORMAL;
 
-      fib_prefix_from_ip46_addr (&t->dst, &tun_dst_pfx);
+      fib_protocol_t fp = fib_ip_proto (is_ip6);
+      fib_prefix_from_ip46_addr (fp, &t->dst, &tun_dst_pfx);
       if (!ip46_address_is_multicast (&t->dst))
        {
          /* Unicast tunnel -
@@ -497,8 +498,6 @@ int vnet_gtpu_add_mod_del_tunnel
           * with different VNIs, create the output adjacency only if
           * it does not already exist
           */
-         fib_protocol_t fp = fib_ip_proto (is_ip6);
-
          if (vtep_addr_ref (&gtm->vtep_table,
                             t->encap_fib_index, &t->dst) == 1)
            {
@@ -524,15 +523,16 @@ int vnet_gtpu_add_mod_del_tunnel
               *  - the forwarding interface is for-us
               *  - the accepting interface is that from the API
               */
-             mfib_table_entry_path_update (t->encap_fib_index,
-                                           &mpfx, MFIB_SOURCE_GTPU, &path);
+             mfib_table_entry_path_update (t->encap_fib_index, &mpfx,
+                                           MFIB_SOURCE_GTPU,
+                                           MFIB_ENTRY_FLAG_NONE, &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_GTPU, &path);
+             mfei = mfib_table_entry_path_update (
+               t->encap_fib_index, &mpfx, MFIB_SOURCE_GTPU,
+               MFIB_ENTRY_FLAG_NONE, &path);
 
              /*
               * Create the mcast adjacency to send traffic to the group
@@ -577,6 +577,7 @@ int vnet_gtpu_add_mod_del_tunnel
          if (a->tteid == 0)
            return VNET_API_ERROR_INVALID_VALUE;
          t->tteid = a->tteid;
+         vec_free (t->rewrite);
          ip_udp_gtpu_rewrite (t, is_ip6);
          return 0;
        }
@@ -1261,7 +1262,7 @@ gtpu_init (vlib_main_t * vm)
                                       sizeof (ip46_address_t),
                                       sizeof (mcast_shared_t));
 
-  gtm->fib_node_type = fib_node_register_new_type (&gtpu_vft);
+  gtm->fib_node_type = fib_node_register_new_type ("gtpu", &gtpu_vft);
 
   return 0;
 }