Restore punt/inject after FIB2.0
[vpp.git] / vnet / vnet / unix / tuntap.c
index e4d0544..4eab391 100644 (file)
@@ -47,6 +47,7 @@
 #include <vnet/ip/ip.h>
 
 #include <vnet/ethernet/ethernet.h>
+#include <vnet/devices/devices.h>
 #include <vnet/feature/feature.h>
 
 #if DPDK == 1
@@ -212,14 +213,6 @@ VLIB_REGISTER_NODE (tuntap_tx_node,static) = {
   .vector_size = 4,
 };
 
-enum {
-  TUNTAP_RX_NEXT_IP4_INPUT,
-  TUNTAP_RX_NEXT_IP6_INPUT,
-  TUNTAP_RX_NEXT_ETHERNET_INPUT,
-  TUNTAP_RX_NEXT_DROP,
-  TUNTAP_RX_N_NEXT,
-};
-
 /**
  * @brief TUNTAP receive node
  * @node tuntap-rx
@@ -370,19 +363,19 @@ tuntap_rx (vlib_main_t * vm,
 
     if (tm->is_ether)
       {
-       next_index = TUNTAP_RX_NEXT_ETHERNET_INPUT;
+       next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
       }
     else
       switch (b->data[0] & 0xf0)
         {
         case 0x40:
-          next_index = TUNTAP_RX_NEXT_IP4_INPUT;
+          next_index = VNET_DEVICE_INPUT_NEXT_IP4_INPUT;
           break;
         case 0x60:
-          next_index = TUNTAP_RX_NEXT_IP6_INPUT;
+          next_index = VNET_DEVICE_INPUT_NEXT_IP6_INPUT;
           break;
         default:
-          next_index = TUNTAP_RX_NEXT_DROP;
+          next_index = VNET_DEVICE_INPUT_NEXT_DROP;
           break;
         }
 
@@ -393,10 +386,10 @@ tuntap_rx (vlib_main_t * vm,
         vnet_sw_interface_t * si;
         si = vnet_get_sw_interface (vnm, tm->sw_if_index);
         if (!(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
-          next_index = TUNTAP_RX_NEXT_DROP;
+          next_index = VNET_DEVICE_INPUT_NEXT_DROP;
       }
 
-    vnet_feature_device_input_redirect_x1 (node, tm->hw_if_index, &next_index, b, 0);
+    vnet_feature_start_device_input_x1 (tm->sw_if_index, &next_index, b, 0);
 
     vlib_set_next_frame_buffer (vm, node, next_index, bi);
 
@@ -427,13 +420,8 @@ VLIB_REGISTER_NODE (tuntap_rx_node,static) = {
   .n_errors = 1,
   .error_strings = tuntap_rx_error_strings,
 
-  .n_next_nodes = TUNTAP_RX_N_NEXT,
-  .next_nodes = {
-    [TUNTAP_RX_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
-    [TUNTAP_RX_NEXT_IP6_INPUT] = "ip6-input",
-    [TUNTAP_RX_NEXT_DROP] = "error-drop",
-    [TUNTAP_RX_NEXT_ETHERNET_INPUT] = "ethernet-input",
-  },
+  .n_next_nodes = VNET_DEVICE_INPUT_N_NEXT_NODES,
+  .next_nodes = VNET_DEVICE_INPUT_NEXT_NODES,
 };
 
 /**
@@ -765,6 +753,12 @@ tuntap_ip4_add_del_interface_address (ip4_main_t * im,
   snprintf (ifr.ifr_name, sizeof(ifr.ifr_name), 
             "%s:%d", tm->tun_name, (int)(ap - tm->subifs));
 
+  /* the tuntap punt/inject is enabled for IPv4 RX so long as
+   * any vpp interface has an IPv4 address.
+   * this is also ref counted.
+   */
+  ip4_sw_interface_enable_disable (tm->sw_if_index, !is_delete);
+
   if (! is_delete)
     {
       struct sockaddr_in * sin;
@@ -868,6 +862,12 @@ tuntap_ip6_add_del_interface_address (ip6_main_t * im,
   snprintf (ifr.ifr_name, sizeof(ifr.ifr_name), 
             "%s:%d", tm->tun_name, (int)(ap - tm->subifs));
 
+  /* the tuntap punt/inject is enabled for IPv6 RX so long as
+   * any vpp interface has an IPv6 address.
+   * this is also ref counted.
+   */
+  ip6_sw_interface_enable_disable (tm->sw_if_index, !is_delete);
+
   if (! is_delete)
     {
       int sockfd = socket (AF_INET6, SOCK_STREAM, 0);