L2 BD: introduce a BD interface on which to send UU packets
[vpp.git] / src / vnet / gre / interface.c
index 97c4f16..181a908 100644 (file)
@@ -24,6 +24,7 @@
 #include <vnet/adj/adj_midchain.h>
 #include <vnet/adj/adj_nbr.h>
 #include <vnet/mpls/mpls.h>
+#include <vnet/l2/l2_input.h>
 
 static const char *gre_tunnel_type_names[] = GRE_TUNNEL_TYPE_NAMES;
 
@@ -127,7 +128,9 @@ gre_tunnel_from_fib_node (fib_node_t * node)
 void
 gre_tunnel_stack (adj_index_t ai)
 {
+  fib_forward_chain_type_t fib_fwd;
   gre_main_t *gm = &gre_main;
+  dpo_id_t tmp = DPO_INVALID;
   ip_adjacency_t *adj;
   gre_tunnel_t *gt;
   u32 sw_if_index;
@@ -135,7 +138,7 @@ gre_tunnel_stack (adj_index_t ai)
   adj = adj_get (ai);
   sw_if_index = adj->rewrite_header.sw_if_index;
 
-  if ((vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index) ||
+  if ((vec_len (gm->tunnel_index_by_sw_if_index) <= sw_if_index) ||
       (~0 == gm->tunnel_index_by_sw_if_index[sw_if_index]))
     return;
 
@@ -149,9 +152,7 @@ gre_tunnel_stack (adj_index_t ai)
       return;
     }
 
-  dpo_id_t tmp = DPO_INVALID;
-  fib_forward_chain_type_t fib_fwd = (FIB_PROTOCOL_IP6 == adj->ia_nh_proto) ?
-    FIB_FORW_CHAIN_TYPE_UNICAST_IP6 : FIB_FORW_CHAIN_TYPE_UNICAST_IP4;
+  fib_fwd = fib_forw_chain_type_from_fib_proto (gt->tunnel_dst.fp_proto);
 
   fib_entry_contribute_forwarding (gt->fib_entry_index, fib_fwd, &tmp);
   if (DPO_LOAD_BALANCE == tmp.dpoi_type)
@@ -309,9 +310,11 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
   else
     {
       /* Default MAC address (d00b:eed0:0000 + sw_if_index) */
-      u8 address[6] = { 0xd0, 0x0b, 0xee, 0xd0, (u8) t_idx >> 8, (u8) t_idx };
-      error = ethernet_register_interface (vnm, gre_device_class.index, t_idx,
-                                          address, &hw_if_index, 0);
+      u8 address[6] =
+       { 0xd0, 0x0b, 0xee, 0xd0, (u8) (t_idx >> 8), (u8) t_idx };
+      error =
+       ethernet_register_interface (vnm, gre_device_class.index, t_idx,
+                                    address, &hw_if_index, 0);
       if (error)
        {
          clib_error_report (error);
@@ -346,11 +349,8 @@ vnet_gre_tunnel_add (vnet_gre_add_del_tunnel_args_t * a,
        64 + sizeof (gre_header_t) + sizeof (ip6_header_t);
     }
 
-  hi->per_packet_overhead_bytes =
-    /* preamble */ 8 + /* inter frame gap */ 12;
-
   /* Standard default gre MTU. */
-  hi->max_l3_packet_bytes[VLIB_RX] = hi->max_l3_packet_bytes[VLIB_TX] = 9000;
+  vnet_sw_interface_set_mtu (vnm, sw_if_index, 9000);
 
   /*
    * source the FIB entry for the tunnel's destination
@@ -423,7 +423,8 @@ vnet_gre_tunnel_delete (vnet_gre_add_del_tunnel_args_t * a,
   vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
 
   /* make sure tunnel is removed from l2 bd or xconnect */
-  set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0, 0, 0, 0);
+  set_int_l2_mode (gm->vlib_main, vnm, MODE_L3, sw_if_index, 0,
+                  L2_BD_PORT_TYPE_NORMAL, 0, 0);
   gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0;
 
   if (t->type == GRE_TUNNEL_TYPE_L3)