docs: more nitfixes
[vpp.git] / src / vnet / vxlan-gpe / vxlan_gpe.c
index 07b7ac9..6fd0561 100644 (file)
@@ -26,6 +26,7 @@
 #include <vnet/mfib/mfib_table.h>
 #include <vnet/adj/adj_mcast.h>
 #include <vnet/interface.h>
+#include <vnet/udp/udp_local.h>
 #include <vlib/vlib.h>
 
 /**
@@ -384,35 +385,6 @@ vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t, u32 extension_size,
   return (0);
 }
 
-static uword
-vtep_addr_ref (ip46_address_t * ip)
-{
-  uword *vtep = ip46_address_is_ip4 (ip) ?
-    hash_get (vxlan_gpe_main.vtep4, ip->ip4.as_u32) :
-    hash_get_mem (vxlan_gpe_main.vtep6, &ip->ip6);
-  if (vtep)
-    return ++(*vtep);
-  ip46_address_is_ip4 (ip) ?
-    hash_set (vxlan_gpe_main.vtep4, ip->ip4.as_u32, 1) :
-    hash_set_mem_alloc (&vxlan_gpe_main.vtep6, &ip->ip6, 1);
-  return 1;
-}
-
-static uword
-vtep_addr_unref (ip46_address_t * ip)
-{
-  uword *vtep = ip46_address_is_ip4 (ip) ?
-    hash_get (vxlan_gpe_main.vtep4, ip->ip4.as_u32) :
-    hash_get_mem (vxlan_gpe_main.vtep6, &ip->ip6);
-  ALWAYS_ASSERT (vtep);
-  if (--(*vtep) != 0)
-    return *vtep;
-  ip46_address_is_ip4 (ip) ?
-    hash_unset (vxlan_gpe_main.vtep4, ip->ip4.as_u32) :
-    hash_unset_mem_free (&vxlan_gpe_main.vtep6, &ip->ip6);
-  return 0;
-}
-
 /* *INDENT-OFF* */
 typedef CLIB_PACKED(union {
   struct {
@@ -620,7 +592,7 @@ int vnet_vxlan_gpe_add_del_tunnel
           * when the forwarding for the entry updates, and the tunnel can
           * re-stack accordingly
           */
-         vtep_addr_ref (&t->local);
+         vtep_addr_ref (&ngm->vtep_table, t->encap_fib_index, &t->local);
          t->fib_entry_index = fib_entry_track (t->encap_fib_index,
                                                &tun_remote_pfx,
                                                FIB_NODE_TYPE_VXLAN_GPE_TUNNEL,
@@ -637,7 +609,8 @@ int vnet_vxlan_gpe_add_del_tunnel
           */
          fib_protocol_t fp = fib_ip_proto (is_ip6);
 
-         if (vtep_addr_ref (&t->remote) == 1)
+         if (vtep_addr_ref (&ngm->vtep_table,
+                            t->encap_fib_index, &t->remote) == 1)
            {
              fib_node_index_t mfei;
              adj_index_t ai;
@@ -726,10 +699,11 @@ int vnet_vxlan_gpe_add_del_tunnel
 
       if (!ip46_address_is_multicast (&t->remote))
        {
-         vtep_addr_unref (&t->local);
+         vtep_addr_unref (&ngm->vtep_table, t->encap_fib_index, &t->local);
          fib_entry_untrack (t->fib_entry_index, t->sibling_index);
        }
-      else if (vtep_addr_unref (&t->remote) == 0)
+      else if (vtep_addr_unref (&ngm->vtep_table,
+                               t->encap_fib_index, &t->remote) == 0)
        {
          mcast_shared_remove (&t->remote);
        }
@@ -1024,10 +998,10 @@ show_vxlan_gpe_tunnel_command_fn (vlib_main_t * vm,
     vlib_cli_output (vm, "No vxlan-gpe tunnels configured.");
 
   /* *INDENT-OFF* */
-  pool_foreach (t, ngm->tunnels,
-  ({
+  pool_foreach (t, ngm->tunnels)
+   {
     vlib_cli_output (vm, "%U", format_vxlan_gpe_tunnel, t);
-  }));
+  }
   /* *INDENT-ON* */
 
   return 0;
@@ -1113,11 +1087,12 @@ set_ip4_vxlan_gpe_bypass (vlib_main_t * vm,
 }
 
 /*?
- * This command adds the 'ip4-vxlan-gpe-bypass' graph node for a given interface.
- * By adding the IPv4 vxlan-gpe-bypass graph node to an interface, the node checks
- *  for and validate input vxlan_gpe packet and bypass ip4-lookup, ip4-local,
- * ip4-udp-lookup nodes to speedup vxlan_gpe packet forwarding. This node will
- * cause extra overhead to for non-vxlan_gpe packets which is kept at a minimum.
+ * This command adds the 'ip4-vxlan-gpe-bypass' graph node for a given
+ * interface. By adding the IPv4 vxlan-gpe-bypass graph node to an interface,
+ * the node checks for and validate input vxlan_gpe packet and bypass
+ * ip4-lookup, ip4-local, ip4-udp-lookup nodes to speedup vxlan_gpe packet
+ * forwarding. This node will cause extra overhead to for non-vxlan_gpe
+ * packets which is kept at a minimum.
  *
  * @cliexpar
  * @parblock
@@ -1134,10 +1109,10 @@ set_ip4_vxlan_gpe_bypass (vlib_main_t * vm,
  *
  * Example of graph node after ip4-vxlan-gpe-bypass is enabled:
  * @cliexstart{show vlib graph ip4-vxlan-gpe-bypass}
- *            Name                      Next                    Previous
- * ip4-vxlan-gpe-bypass                error-drop [0]               ip4-input
- *                                vxlan4-gpe-input [1]        ip4-input-no-checksum
- *                                 ip4-lookup [2]
+ *            Name             Next                      Previous
+ * ip4-vxlan-gpe-bypass       error-drop [0]            ip4-input
+ *                       vxlan4-gpe-input [1]      ip4-input-no-checksum
+ *                        ip4-lookup [2]
  * @cliexend
  *
  * Example of how to display the feature enabled on an interface:
@@ -1170,11 +1145,12 @@ set_ip6_vxlan_gpe_bypass (vlib_main_t * vm,
 }
 
 /*?
- * This command adds the 'ip6-vxlan-gpe-bypass' graph node for a given interface.
- * By adding the IPv6 vxlan-gpe-bypass graph node to an interface, the node checks
- *  for and validate input vxlan_gpe packet and bypass ip6-lookup, ip6-local,
- * ip6-udp-lookup nodes to speedup vxlan_gpe packet forwarding. This node will
- * cause extra overhead to for non-vxlan_gpe packets which is kept at a minimum.
+ * This command adds the 'ip6-vxlan-gpe-bypass' graph node for a given
+ * interface. By adding the IPv6 vxlan-gpe-bypass graph node to an interface,
+ * the node checks for and validate input vxlan_gpe packet and bypass
+ * ip6-lookup, ip6-local, ip6-udp-lookup nodes to speedup vxlan_gpe packet
+ * forwarding. This node will cause extra overhead to for non-vxlan_gpe packets
+ * which is kept at a minimum.
  *
  * @cliexpar
  * @parblock
@@ -1191,10 +1167,10 @@ set_ip6_vxlan_gpe_bypass (vlib_main_t * vm,
  *
  * Example of graph node after ip6-vxlan-gpe-bypass is enabled:
  * @cliexstart{show vlib graph ip6-vxlan-gpe-bypass}
- *            Name                      Next                    Previous
- * ip6-vxlan-gpe-bypass                error-drop [0]               ip6-input
- *                                vxlan6-gpe-input [1]        ip4-input-no-checksum
- *                                 ip6-lookup [2]
+ *            Name               Next                    Previous
+ * ip6-vxlan-gpe-bypass         error-drop [0]          ip6-input
+ *                         vxlan6-gpe-input [1]    ip4-input-no-checksum
+ *                          ip6-lookup [2]
  * @cliexend
  *
  * Example of how to display the feature enabled on an interface:
@@ -1261,7 +1237,7 @@ vxlan_gpe_init (vlib_main_t * vm)
   ngm->mcast_shared = hash_create_mem (0,
                                       sizeof (ip46_address_t),
                                       sizeof (mcast_shared_t));
-  ngm->vtep6 = hash_create_mem (0, sizeof (ip6_address_t), sizeof (uword));
+  ngm->vtep_table = vtep_table_create ();
 
   /* Register the list of standard decap protocols supported */
   vxlan_gpe_register_decap_protocol (VXLAN_GPE_PROTOCOL_IP4,