gso: fix l3 and l4 header offset in case of tagged interface 99/20899/4
authorMohsin Kazmi <sykazmi@cisco.com>
Mon, 29 Jul 2019 09:39:26 +0000 (11:39 +0200)
committerMohsin Kazmi <sykazmi@cisco.com>
Sat, 17 Aug 2019 15:24:26 +0000 (17:24 +0200)
previously, PG and virtio interfaces calculate wrong l3 and l4
header offset. This patch fixes this issue.

Type: fix
Ticket: VPP-1739

Change-Id: I5ba978e464babeb65e0711e1027320d46b3b9932
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
src/vnet/devices/virtio/node.c
src/vnet/pg/input.c

index 9cb6cca..3b218ab 100644 (file)
@@ -153,6 +153,20 @@ fill_gso_buffer_flags (vlib_buffer_t * b0, struct virtio_net_hdr_v1 *hdr)
       u16 ethertype = clib_net_to_host_u16 (eh->type);
       u16 l2hdr_sz = sizeof (ethernet_header_t);
 
+      if (ethernet_frame_is_tagged (ethertype))
+       {
+         ethernet_vlan_header_t *vlan = (ethernet_vlan_header_t *) (eh + 1);
+
+         ethertype = clib_net_to_host_u16 (vlan->type);
+         l2hdr_sz += sizeof (*vlan);
+         if (ethertype == ETHERNET_TYPE_VLAN)
+           {
+             vlan++;
+             ethertype = clib_net_to_host_u16 (vlan->type);
+             l2hdr_sz += sizeof (*vlan);
+           }
+       }
+
       vnet_buffer (b0)->l2_hdr_offset = 0;
       vnet_buffer (b0)->l3_hdr_offset = l2hdr_sz;
       if (PREDICT_TRUE (ethertype == ETHERNET_TYPE_IP4))
index 757a291..bb760b0 100644 (file)
@@ -1541,6 +1541,20 @@ fill_gso_buffer_flags (vlib_main_t * vm, u32 * buffers, u32 n_buffers,
       u16 ethertype = clib_net_to_host_u16 (eh->type);
       u16 l2hdr_sz = sizeof (ethernet_header_t);
 
+      if (ethernet_frame_is_tagged (ethertype))
+       {
+         ethernet_vlan_header_t *vlan = (ethernet_vlan_header_t *) (eh + 1);
+
+         ethertype = clib_net_to_host_u16 (vlan->type);
+         l2hdr_sz += sizeof (*vlan);
+         if (ethertype == ETHERNET_TYPE_VLAN)
+           {
+             vlan++;
+             ethertype = clib_net_to_host_u16 (vlan->type);
+             l2hdr_sz += sizeof (*vlan);
+           }
+       }
+
       vnet_buffer (b0)->l2_hdr_offset = 0;
       vnet_buffer (b0)->l3_hdr_offset = l2hdr_sz;
       if (PREDICT_TRUE (ethertype == ETHERNET_TYPE_IP4))