misc: Purge unused pg includes
[vpp.git] / src / plugins / dhcp / dhcp4_proxy_node.c
index 53c95c0..bf1d12d 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 #include <vlib/vlib.h>
-#include <vnet/pg/pg.h>
 #include <dhcp/dhcp_proxy.h>
 #include <dhcp/client.h>
 #include <vnet/fib/ip4_fib.h>
@@ -364,6 +363,13 @@ dhcp_proxy_to_server_input (vlib_main_t * vm,
                  u32 ci0;
 
                  c0 = vlib_buffer_copy (vm, b0);
+                 if (c0 == NULL)
+                   {
+                     vlib_node_increment_counter
+                       (vm, dhcp_proxy_to_server_node.index,
+                        DHCP_PROXY_ERROR_ALLOC_FAIL, 1);
+                     continue;
+                   }
                  VLIB_BUFFER_TRACE_TRAJECTORY_INIT (c0);
                  ci0 = vlib_get_buffer_index (vm, c0);
                  server = &proxy->dhcp_servers[ii];
@@ -525,6 +531,8 @@ dhcp_proxy_to_client_input (vlib_main_t * vm,
          vnet_hw_interface_t *hi0;
          u32 sw_if_index = ~0;
          vnet_sw_interface_t *si0;
+         u32 inner_vlan = (u32) ~ 0;
+         u32 outer_vlan = (u32) ~ 0;
          u32 error0 = (u32) ~ 0;
          vnet_sw_interface_t *swif;
          u32 fib_index;
@@ -712,7 +720,19 @@ dhcp_proxy_to_client_input (vlib_main_t * vm,
          vlib_buffer_advance (b0, -(sizeof (ethernet_header_t)));
          si0 = vnet_get_sw_interface (vnm, original_sw_if_index);
          if (si0->type == VNET_SW_INTERFACE_TYPE_SUB)
-           vlib_buffer_advance (b0, -4 /* space for VLAN tag */ );
+           {
+             if (si0->sub.eth.flags.one_tag == 1)
+               {
+                 vlib_buffer_advance (b0, -4 /* space for 1 VLAN tag */ );
+                 outer_vlan = (si0->sub.eth.outer_vlan_id << 16) | 0x0800;
+               }
+             else if (si0->sub.eth.flags.two_tags == 1)
+               {
+                 vlib_buffer_advance (b0, -8 /* space for 2 VLAN tag */ );
+                 outer_vlan = (si0->sub.eth.outer_vlan_id << 16) | 0x8100;
+                 inner_vlan = (si0->sub.eth.inner_vlan_id << 16) | 0x0800;
+               }
+           }
 
          mac0 = vlib_buffer_get_current (b0);
 
@@ -721,15 +741,23 @@ dhcp_proxy_to_client_input (vlib_main_t * vm,
          clib_memcpy (mac0->src_address, ei0->address,
                       sizeof (ei0->address));
          clib_memset (mac0->dst_address, 0xff, sizeof (mac0->dst_address));
-         mac0->type = (si0->type == VNET_SW_INTERFACE_TYPE_SUB) ?
-           clib_net_to_host_u16 (0x8100) : clib_net_to_host_u16 (0x0800);
 
-         if (si0->type == VNET_SW_INTERFACE_TYPE_SUB)
+         if (si0->type == VNET_SW_INTERFACE_TYPE_SUB
+             && outer_vlan != (u32) ~ 0)
            {
+             mac0->type = (si0->sub.eth.flags.dot1ad == 1) ?
+               clib_net_to_host_u16 (0x88a8) : clib_net_to_host_u16 (0x8100);
              u32 *vlan_tag = (u32 *) (mac0 + 1);
-             u32 tmp;
-             tmp = (si0->sub.id << 16) | 0x0800;
-             *vlan_tag = clib_host_to_net_u32 (tmp);
+             *vlan_tag = clib_host_to_net_u32 (outer_vlan);
+             if (inner_vlan != (u32) ~ 0)
+               {
+                 u32 *inner_vlan_tag = (u32 *) (vlan_tag + 1);
+                 *inner_vlan_tag = clib_host_to_net_u32 (inner_vlan);
+               }
+           }
+         else
+           {
+             mac0->type = clib_net_to_host_u16 (0x0800);
            }
 
        do_trace: