docs: more nitfixes
[vpp.git] / src / vnet / vxlan-gbp / vxlan_gbp.c
index e39c26f..1a1d2c2 100644 (file)
  */
 #include <vnet/vxlan-gbp/vxlan_gbp.h>
 #include <vnet/ip/format.h>
+#include <vnet/ip/punt.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/adj/rewrite.h>
@@ -290,7 +292,7 @@ vtep_addr_unref (ip46_address_t * ip)
   uword *vtep = ip46_address_is_ip4 (ip) ?
     hash_get (vxlan_gbp_main.vtep4, ip->ip4.as_u32) :
     hash_get_mem (vxlan_gbp_main.vtep6, &ip->ip6);
-  ASSERT (vtep);
+  ALWAYS_ASSERT (vtep);
   if (--(*vtep) != 0)
     return *vtep;
   ip46_address_is_ip4 (ip) ?
@@ -316,7 +318,7 @@ mcast_shared_get (ip46_address_t * ip)
 {
   ASSERT (ip46_address_is_multicast (ip));
   uword *p = hash_get_mem (vxlan_gbp_main.mcast_shared, ip);
-  ASSERT (p);
+  ALWAYS_ASSERT (p);
   mcast_shared_t ret = {.as_u64 = *p };
   return ret;
 }
@@ -529,12 +531,11 @@ int vnet_vxlan_gbp_tunnel_add_del
           * re-stack accordingly
           */
          vtep_addr_ref (&t->src);
-         t->fib_entry_index = fib_table_entry_special_add
-           (t->encap_fib_index, &tun_dst_pfx, FIB_SOURCE_RR,
-            FIB_ENTRY_FLAG_NONE);
-         t->sibling_index = fib_entry_child_add
-           (t->fib_entry_index, FIB_NODE_TYPE_VXLAN_GBP_TUNNEL,
-            dev_instance);
+         t->fib_entry_index = fib_entry_track (t->encap_fib_index,
+                                               &tun_dst_pfx,
+                                               FIB_NODE_TYPE_VXLAN_GBP_TUNNEL,
+                                               dev_instance,
+                                               &t->sibling_index);
          vxlan_gbp_tunnel_restack_dpo (t);
        }
       else
@@ -557,6 +558,7 @@ int vnet_vxlan_gbp_tunnel_add_del
                .frp_fib_index = ~0,
                .frp_weight = 0,
                .frp_flags = FIB_ROUTE_PATH_LOCAL,
+               .frp_mitf_flags = MFIB_ITF_FLAG_FORWARD,
              };
              const mfib_prefix_t mpfx = {
                .fp_proto = fp,
@@ -571,16 +573,15 @@ int vnet_vxlan_gbp_tunnel_add_del
               */
              mfib_table_entry_path_update (t->encap_fib_index,
                                            &mpfx,
-                                           MFIB_SOURCE_VXLAN_GBP,
-                                           &path, MFIB_ITF_FLAG_FORWARD);
+                                           MFIB_SOURCE_VXLAN_GBP, &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_VXLAN_GBP,
-                                                  &path,
-                                                  MFIB_ITF_FLAG_ACCEPT);
+                                                  &path);
 
              /*
               * Create the mcast adjacency to send traffic to the group
@@ -640,8 +641,7 @@ int vnet_vxlan_gbp_tunnel_add_del
       if (!ip46_address_is_multicast (&t->dst))
        {
          vtep_addr_unref (&t->src);
-         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->dst) == 0)
        {
@@ -930,10 +930,10 @@ show_vxlan_gbp_tunnel_command_fn (vlib_main_t * vm,
     vlib_cli_output (vm, "No vxlan-gbp tunnels configured...");
 
 /* *INDENT-OFF* */
-  pool_foreach (t, vxm->tunnels,
-  ({
+  pool_foreach (t, vxm->tunnels)
+   {
     vlib_cli_output (vm, "%U", format_vxlan_gbp_tunnel, t);
-  }));
+  }
 /* *INDENT-ON* */
 
   if (raw)
@@ -1031,11 +1031,12 @@ set_ip4_vxlan_gbp_bypass (vlib_main_t * vm,
 }
 
 /*?
- * This command adds the 'ip4-vxlan-gbp-bypass' graph node for a given interface.
- * By adding the IPv4 vxlan_gbp-bypass graph node to an interface, the node checks
- *  for and validate input vxlan_gbp packet and bypass ip4-lookup, ip4-local,
- * ip4-udp-lookup nodes to speedup vxlan_gbp packet forwarding. This node will
- * cause extra overhead to for non-vxlan_gbp packets which is kept at a minimum.
+ * This command adds the 'ip4-vxlan-gbp-bypass' graph node for a given
+ * interface. By adding the IPv4 vxlan_gbp-bypass graph node to an interface,
+ * the node checks for and validate input vxlan_gbp packet and bypass
+ * ip4-lookup, ip4-local, ip4-udp-lookup nodes to speedup vxlan_gbp packet
+ * forwarding. This node will cause extra overhead to for non-vxlan_gbp packets
+ * which is kept at a minimum.
  *
  * @cliexpar
  * @parblock
@@ -1052,10 +1053,10 @@ set_ip4_vxlan_gbp_bypass (vlib_main_t * vm,
  *
  * Example of graph node after ip4-vxlan-gbp-bypass is enabled:
  * @cliexstart{show vlib graph ip4-vxlan-gbp-bypass}
- *            Name                      Next                    Previous
- * ip4-vxlan-gbp-bypass              error-drop [0]               ip4-input
- *                                vxlan4-gbp-input [1]        ip4-input-no-checksum
- *                                   ip4-lookup [2]
+ *            Name             Next                      Previous
+ * ip4-vxlan-gbp-bypass     error-drop [0]               ip4-input
+ *                       vxlan4-gbp-input [1]       ip4-input-no-checksum
+ *                          ip4-lookup [2]
  * @cliexend
  *
  * Example of how to display the feature enabled on an interface:
@@ -1088,11 +1089,12 @@ set_ip6_vxlan_gbp_bypass (vlib_main_t * vm,
 }
 
 /*?
- * This command adds the 'ip6-vxlan-gbp-bypass' graph node for a given interface.
- * By adding the IPv6 vxlan-gbp-bypass graph node to an interface, the node checks
- *  for and validate input vxlan_gbp packet and bypass ip6-lookup, ip6-local,
- * ip6-udp-lookup nodes to speedup vxlan_gbp packet forwarding. This node will
- * cause extra overhead to for non-vxlan packets which is kept at a minimum.
+ * This command adds the 'ip6-vxlan-gbp-bypass' graph node for a given
+ * interface. By adding the IPv6 vxlan-gbp-bypass graph node to an interface,
+ * the node checks for and validate input vxlan_gbp packet and bypass
+ * ip6-lookup, ip6-local, ip6-udp-lookup nodes to speedup vxlan_gbp packet
+ * forwarding. This node will cause extra overhead to for non-vxlan packets
+ * which is kept at a minimum.
  *
  * @cliexpar
  * @parblock
@@ -1109,10 +1111,10 @@ set_ip6_vxlan_gbp_bypass (vlib_main_t * vm,
  *
  * Example of graph node after ip6-vxlan-gbp-bypass is enabled:
  * @cliexstart{show vlib graph ip6-vxlan-gbp-bypass}
- *            Name                      Next                    Previous
- * ip6-vxlan-gbp-bypass              error-drop [0]               ip6-input
- *                                vxlan6-gbp-input [1]        ip4-input-no-checksum
- *                                   ip6-lookup [2]
+ *            Name             Next                    Previous
+ * ip6-vxlan-gbp-bypass     error-drop [0]             ip6-input
+ *                       vxlan6-gbp-input [1]      ip4-input-no-checksum
+ *                          ip6-lookup [2]
  * @cliexend
  *
  * Example of how to display the feature enabled on an interface:
@@ -1133,7 +1135,7 @@ set_ip6_vxlan_gbp_bypass (vlib_main_t * vm,
 VLIB_CLI_COMMAND (set_interface_ip6_vxlan_gbp_bypass_command, static) = {
   .path = "set interface ip6 vxlan-gbp-bypass",
   .function = set_ip6_vxlan_gbp_bypass,
-  .short_help = "set interface ip vxlan-gbp-bypass <interface> [del]",
+  .short_help = "set interface ip6 vxlan-gbp-bypass <interface> [del]",
 };
 /* *INDENT-ON* */
 
@@ -1144,14 +1146,10 @@ clib_error_t *
 vxlan_gbp_init (vlib_main_t * vm)
 {
   vxlan_gbp_main_t *vxm = &vxlan_gbp_main;
-  clib_error_t *error;
 
   vxm->vnet_main = vnet_get_main ();
   vxm->vlib_main = vm;
 
-  if ((error = vlib_call_init_function (vm, punt_init)))
-    return (error);
-
   /* initialize the ip6 hash */
   clib_bihash_init_16_8 (&vxm->vxlan4_gbp_tunnel_by_key, "vxlan4-gbp",
                         VXLAN_GBP_HASH_NUM_BUCKETS,
@@ -1168,17 +1166,24 @@ vxlan_gbp_init (vlib_main_t * vm)
 
   punt_hdl = vlib_punt_client_register ("vxlan-gbp");
 
-  vlib_punt_reason_alloc (punt_hdl,
-                         "VXLAN-GBP-no-such-v4-tunnel",
-                         &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4]);
-  vlib_punt_reason_alloc (punt_hdl,
-                         "VXLAN-GBP-no-such-v6-tunnel",
-                         &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6]);
+  vlib_punt_reason_alloc (punt_hdl, "VXLAN-GBP-no-such-v4-tunnel", NULL, NULL,
+                         &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP4],
+                         VNET_PUNT_REASON_F_IP4_PACKET,
+                         format_vnet_punt_reason_flags);
+  vlib_punt_reason_alloc (punt_hdl, "VXLAN-GBP-no-such-v6-tunnel", NULL, NULL,
+                         &vxm->punt_no_such_tunnel[FIB_PROTOCOL_IP6],
+                         VNET_PUNT_REASON_F_IP6_PACKET,
+                         format_vnet_punt_reason_flags);
 
-  return (error);
+  return (0);
 }
 
-VLIB_INIT_FUNCTION (vxlan_gbp_init);
+/* *INDENT-OFF* */
+VLIB_INIT_FUNCTION (vxlan_gbp_init) =
+{
+  .runs_after = VLIB_INITS("punt_init"),
+};
+/* *INDENT-ON* */
 
 /*
  * fd.io coding-style-patch-verification: ON