API: Change ip4_address and ip6_address to use type alias.
[vpp.git] / src / vnet / ip / ip_frag.c
index 628d9d6..de09987 100644 (file)
@@ -61,6 +61,13 @@ frag_set_sw_if_index (vlib_buffer_t * to, vlib_buffer_t * from)
     vnet_buffer (from)->ip.adj_index[VLIB_RX];
   vnet_buffer (to)->ip.adj_index[VLIB_TX] =
     vnet_buffer (from)->ip.adj_index[VLIB_TX];
+
+  /* Copy QoS Bits */
+  if (PREDICT_TRUE (from->flags & VNET_BUFFER_F_QOS_DATA_VALID))
+    {
+      vnet_buffer2 (to)->qos = vnet_buffer2 (from)->qos;
+      to->flags |= VNET_BUFFER_F_QOS_DATA_VALID;
+    }
 }
 
 static vlib_buffer_t *
@@ -101,7 +108,8 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
   ip4 = (ip4_header_t *) vlib_buffer_get_current (from_b);
 
   rem = clib_net_to_host_u16 (ip4->length) - sizeof (ip4_header_t);
-  max = (mtu - sizeof (ip4_header_t)) & ~0x7;
+  max =
+    (clib_min (mtu, VLIB_BUFFER_DATA_SIZE) - sizeof (ip4_header_t)) & ~0x7;
 
   if (rem >
       (vlib_buffer_length_in_chain (vm, from_b) - sizeof (ip4_header_t)))
@@ -152,7 +160,7 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
       ip4_header_t *to_ip4;
       u8 *to_data;
 
-      len = (rem > (mtu - sizeof (ip4_header_t)) ? max : rem);
+      len = (rem > max ? max : rem);
       if (len != rem)          /* Last fragment does not need to divisible by 8 */
        len &= ~0x7;
       if ((to_b = frag_buffer_alloc (org_from_b, &to_bi)) == 0)
@@ -164,7 +172,7 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
       frag_set_sw_if_index (to_b, org_from_b);
 
       /* Copy ip4 header */
-      clib_memcpy (to_b->data, org_from_packet, sizeof (ip4_header_t));
+      clib_memcpy_fast (to_b->data, org_from_packet, sizeof (ip4_header_t));
       to_ip4 = vlib_buffer_get_current (to_b);
       to_data = (void *) (to_ip4 + 1);
 
@@ -177,7 +185,7 @@ ip4_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
          /* Figure out how many bytes we can safely copy */
          bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ?
            left_in_to_buffer : left_in_from_buffer;
-         clib_memcpy (to_data + to_ptr, from_data + ptr, bytes_to_copy);
+         clib_memcpy_fast (to_data + to_ptr, from_data + ptr, bytes_to_copy);
          left_in_to_buffer -= bytes_to_copy;
          ptr += bytes_to_copy;
          left_in_from_buffer -= bytes_to_copy;
@@ -440,7 +448,7 @@ ip6_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
       frag_set_sw_if_index (to_b, org_from_b);
 
       /* Copy ip6 header */
-      clib_memcpy (to_b->data, ip6, sizeof (ip6_header_t));
+      clib_memcpy_fast (to_b->data, ip6, sizeof (ip6_header_t));
       to_ip6 = vlib_buffer_get_current (to_b);
       to_frag_hdr = (ip6_frag_hdr_t *) (to_ip6 + 1);
       to_data = (void *) (to_frag_hdr + 1);
@@ -454,7 +462,7 @@ ip6_frag_do_fragment (vlib_main_t * vm, u32 from_bi, u32 ** buffer,
          /* Figure out how many bytes we can safely copy */
          bytes_to_copy = left_in_to_buffer <= left_in_from_buffer ?
            left_in_to_buffer : left_in_from_buffer;
-         clib_memcpy (to_data + to_ptr, from_data + ptr, bytes_to_copy);
+         clib_memcpy_fast (to_data + to_ptr, from_data + ptr, bytes_to_copy);
          left_in_to_buffer -= bytes_to_copy;
          ptr += bytes_to_copy;
          left_in_from_buffer -= bytes_to_copy;