vlib: fix the offload flags size 17/32217/3
authorMohsin Kazmi <sykazmi@cisco.com>
Wed, 5 May 2021 12:26:38 +0000 (14:26 +0200)
committerDamjan Marion <dmarion@me.com>
Thu, 6 May 2021 10:28:02 +0000 (10:28 +0000)
Type: fix

Change-Id: I433fe3799975fe3ba00fa30226f6e8dae34e88fc
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
14 files changed:
src/plugins/avf/output.c
src/plugins/dpdk/device/device.c
src/plugins/vmxnet3/input.c
src/vnet/buffer.h
src/vnet/devices/af_packet/node.c
src/vnet/devices/virtio/device.c
src/vnet/devices/virtio/node.c
src/vnet/devices/virtio/vhost_user_input.c
src/vnet/devices/virtio/vhost_user_output.c
src/vnet/interface_format.c
src/vnet/interface_output.h
src/vnet/ip/ip6_forward.c
src/vnet/ipsec/ipsec_output.c
src/vnet/pg/input.c

index 7b940eb..b50a1e2 100644 (file)
@@ -60,7 +60,7 @@ avf_tx_prepare_cksum (vlib_buffer_t * b, u8 is_tso)
   if (!is_tso && !(b->flags & VNET_BUFFER_F_OFFLOAD))
     return 0;
 
-  u32 oflags = vnet_buffer (b)->oflags;
+  vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
   u32 is_tcp = is_tso || oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM;
   u32 is_udp = !is_tso && oflags & VNET_BUFFER_OFFLOAD_F_UDP_CKSUM;
   u32 is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
index 7e0f2d4..1fdee48 100644 (file)
@@ -221,8 +221,9 @@ dpdk_buffer_tx_offload (dpdk_device_t * xd, vlib_buffer_t * b,
 {
   int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
   u32 tso = b->flags & VNET_BUFFER_F_GSO, max_pkt_len;
-  u32 oflags, ip_cksum, tcp_cksum, udp_cksum;
+  u32 ip_cksum, tcp_cksum, udp_cksum;
   u64 ol_flags;
+  vnet_buffer_oflags_t oflags = 0;
 
   /* Is there any work for us? */
   if (PREDICT_TRUE (((b->flags & VNET_BUFFER_F_OFFLOAD) | tso) == 0))
index be528b2..3015fb1 100644 (file)
@@ -79,7 +79,7 @@ vmxnet3_handle_offload (vmxnet3_rx_comp * rx_comp, vlib_buffer_t * hb,
                        u16 gso_size)
 {
   u8 l4_hdr_sz = 0;
-  u32 oflags = 0;
+  vnet_buffer_oflags_t oflags = 0;
 
   if (rx_comp->flags & VMXNET3_RXCF_IP4)
     {
index 0816232..0798de4 100644 (file)
@@ -107,6 +107,21 @@ enum
 STATIC_ASSERT (((VNET_BUFFER_FLAGS_ALL_AVAIL & VLIB_BUFFER_FLAGS_ALL) == 0),
               "VLIB / VNET buffer flags overlap");
 
+#define foreach_vnet_buffer_offload_flag                                      \
+  _ (0, IP_CKSUM, "offload-ip-cksum", 1)                                      \
+  _ (1, TCP_CKSUM, "offload-tcp-cksum", 1)                                    \
+  _ (2, UDP_CKSUM, "offload-udp-cksum", 1)                                    \
+  _ (3, OUTER_IP_CKSUM, "offload-outer-ip-cksum", 1)                          \
+  _ (4, OUTER_TCP_CKSUM, "offload-outer-tcp-cksum", 1)                        \
+  _ (5, OUTER_UDP_CKSUM, "offload-outer-udp-cksum", 1)
+
+typedef enum
+{
+#define _(bit, name, s, v) VNET_BUFFER_OFFLOAD_F_##name = (1 << bit),
+  foreach_vnet_buffer_offload_flag
+#undef _
+} vnet_buffer_oflags_t;
+
 #define foreach_buffer_opaque_union_subtype     \
 _(ip)                                           \
 _(l2)                                           \
@@ -139,7 +154,7 @@ typedef struct
   i16 l4_hdr_offset;
   u8 feature_arc_index;
   /* offload flags */
-  u8 oflags;
+  vnet_buffer_oflags_t oflags : 8;
 
   union
   {
@@ -421,21 +436,6 @@ STATIC_ASSERT (sizeof (vnet_buffer_opaque_t) <=
 
 #define vnet_buffer(b) ((vnet_buffer_opaque_t *) (b)->opaque)
 
-#define foreach_vnet_buffer_offload_flag                                      \
-  _ (0, IP_CKSUM, "offload-ip-cksum", 1)                                      \
-  _ (1, TCP_CKSUM, "offload-tcp-cksum", 1)                                    \
-  _ (2, UDP_CKSUM, "offload-udp-cksum", 1)                                    \
-  _ (3, OUTER_IP_CKSUM, "offload-outer-ip-cksum", 1)                          \
-  _ (4, OUTER_TCP_CKSUM, "offload-outer-tcp-cksum", 1)                        \
-  _ (5, OUTER_UDP_CKSUM, "offload-outer-udp-cksum", 1)
-
-enum
-{
-#define _(bit, name, s, v) VNET_BUFFER_OFFLOAD_F_##name = (1 << bit),
-  foreach_vnet_buffer_offload_flag
-#undef _
-};
-
 /* Full cache line (64 bytes) of additional space */
 typedef struct
 {
@@ -519,7 +519,7 @@ format_function_t format_vnet_buffer_opaque;
 format_function_t format_vnet_buffer_opaque2;
 
 static_always_inline void
-vnet_buffer_offload_flags_set (vlib_buffer_t *b, u32 oflags)
+vnet_buffer_offload_flags_set (vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
 {
   if (b->flags & VNET_BUFFER_F_OFFLOAD)
     {
@@ -535,7 +535,7 @@ vnet_buffer_offload_flags_set (vlib_buffer_t *b, u32 oflags)
 }
 
 static_always_inline void
-vnet_buffer_offload_flags_clear (vlib_buffer_t *b, u32 oflags)
+vnet_buffer_offload_flags_clear (vlib_buffer_t *b, vnet_buffer_oflags_t oflags)
 {
   vnet_buffer (b)->oflags &= ~oflags;
   if (0 == vnet_buffer (b)->oflags)
index 16cd69a..9fd115f 100644 (file)
@@ -120,7 +120,7 @@ static_always_inline void
 mark_tcp_udp_cksum_calc (vlib_buffer_t *b, u8 *l4_hdr_sz)
 {
   ethernet_header_t *eth = vlib_buffer_get_current (b);
-  u32 oflags = 0;
+  vnet_buffer_oflags_t oflags = 0;
   if (clib_net_to_host_u16 (eth->type) == ETHERNET_TYPE_IP4)
     {
       ip4_header_t *ip4 =
index 2026478..666cd16 100644 (file)
@@ -285,7 +285,7 @@ static void
 set_checksum_offsets (vlib_buffer_t *b, virtio_net_hdr_v1_t *hdr,
                      const int is_l2)
 {
-  u32 oflags = vnet_buffer (b)->oflags;
+  vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
 
   if (b->flags & VNET_BUFFER_F_IS_IP4)
     {
@@ -334,7 +334,7 @@ set_checksum_offsets (vlib_buffer_t *b, virtio_net_hdr_v1_t *hdr,
 static void
 set_gso_offsets (vlib_buffer_t *b, virtio_net_hdr_v1_t *hdr, const int is_l2)
 {
-  u32 oflags = vnet_buffer (b)->oflags;
+  vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
 
   if (b->flags & VNET_BUFFER_F_IS_IP4)
     {
index f91dc87..c36c080 100644 (file)
@@ -75,7 +75,7 @@ virtio_needs_csum (vlib_buffer_t * b0, virtio_net_hdr_v1_t * hdr,
   if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM)
     {
       u16 ethertype = 0, l2hdr_sz = 0;
-      u32 oflags = 0;
+      vnet_buffer_oflags_t oflags = 0;
 
       if (type == VIRTIO_IF_TYPE_TUN)
        {
index 1636bd8..69fba41 100644 (file)
@@ -253,7 +253,7 @@ vhost_user_handle_rx_offload (vlib_buffer_t * b0, u8 * b0_data,
   ethernet_header_t *eh = (ethernet_header_t *) b0_data;
   u16 ethertype = clib_net_to_host_u16 (eh->type);
   u16 l2hdr_sz = sizeof (ethernet_header_t);
-  u32 oflags = 0;
+  vnet_buffer_oflags_t oflags = 0;
 
   if (ethernet_frame_is_tagged (ethertype))
     {
index 6406fe3..59ea810 100644 (file)
@@ -225,7 +225,7 @@ vhost_user_handle_tx_offload (vhost_user_intf_t * vui, vlib_buffer_t * b,
   generic_header_offset_t gho = { 0 };
   int is_ip4 = b->flags & VNET_BUFFER_F_IS_IP4;
   int is_ip6 = b->flags & VNET_BUFFER_F_IS_IP6;
-  u32 oflags = vnet_buffer (b)->oflags;
+  vnet_buffer_oflags_t oflags = vnet_buffer (b)->oflags;
 
   ASSERT (!(is_ip4 && is_ip6));
   vnet_generic_header_offset_parser (b, &gho, 1 /* l2 */ , is_ip4, is_ip6);
index 036ca53..86a3d59 100644 (file)
@@ -745,7 +745,7 @@ unformat_vnet_buffer_offload_flags (unformat_input_t *input, va_list *args)
 {
   u32 *flagp = va_arg (*args, u32 *);
   int rv = 0;
-  u32 oflags = 0;
+  vnet_buffer_oflags_t oflags = 0;
 
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
@@ -762,7 +762,7 @@ unformat_vnet_buffer_offload_flags (unformat_input_t *input, va_list *args)
        else break;
     }
   if (rv)
-    *flagp = oflags;
+    *flagp = (u32) oflags;
   return rv;
 }
 
index bb27cdb..15b0a1d 100644 (file)
@@ -44,7 +44,8 @@
 
 static_always_inline void
 vnet_calc_ip4_checksums (vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ip4,
-                        tcp_header_t *th, udp_header_t *uh, u32 oflags)
+                        tcp_header_t *th, udp_header_t *uh,
+                        vnet_buffer_oflags_t oflags)
 {
   if (oflags & VNET_BUFFER_OFFLOAD_F_IP_CKSUM)
     ip4->checksum = ip4_header_checksum (ip4);
@@ -62,7 +63,8 @@ vnet_calc_ip4_checksums (vlib_main_t *vm, vlib_buffer_t *b, ip4_header_t *ip4,
 
 static_always_inline void
 vnet_calc_ip6_checksums (vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6,
-                        tcp_header_t *th, udp_header_t *uh, u32 oflags)
+                        tcp_header_t *th, udp_header_t *uh,
+                        vnet_buffer_oflags_t oflags)
 {
   int bogus;
   if (oflags & VNET_BUFFER_OFFLOAD_F_TCP_CKSUM)
@@ -85,7 +87,7 @@ vnet_calc_checksums_inline (vlib_main_t * vm, vlib_buffer_t * b,
   ip6_header_t *ip6;
   tcp_header_t *th;
   udp_header_t *uh;
-  u32 oflags;
+  vnet_buffer_oflags_t oflags;
 
   if (!(b->flags & VNET_BUFFER_F_OFFLOAD))
     return;
index 4f1b148..5d70140 100644 (file)
@@ -1333,7 +1333,7 @@ ip6_local_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          flags[0] = b[0]->flags;
          flags[1] = b[1]->flags;
 
-         u32 oflags[2];
+         vnet_buffer_oflags_t oflags[2];
          oflags[0] = vnet_buffer (b[0])->oflags;
          oflags[1] = vnet_buffer (b[1])->oflags;
 
@@ -1524,7 +1524,7 @@ ip6_local_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
          u32 flags = b[0]->flags;
 
-         u32 oflags = vnet_buffer (b[0])->oflags;
+         vnet_buffer_oflags_t oflags = vnet_buffer (b[0])->oflags;
 
          u32 l4_offload = (flags & VNET_BUFFER_F_OFFLOAD) &&
                           (oflags & (VNET_BUFFER_OFFLOAD_F_TCP_CKSUM |
index 598195f..8fb9566 100644 (file)
@@ -309,7 +309,7 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
              if (PREDICT_FALSE (b0->flags & VNET_BUFFER_F_OFFLOAD))
                {
-                 u32 oflags = vnet_buffer (b0)->oflags;
+                 vnet_buffer_oflags_t oflags = vnet_buffer (b0)->oflags;
 
                  /*
                   * Clearing offload flags before checksum is computed
index d3501b3..98db46a 100644 (file)
@@ -1544,7 +1544,7 @@ fill_buffer_offload_flags (vlib_main_t *vm, u32 *buffers, u32 n_buffers,
     {
       vlib_buffer_t *b0 = vlib_get_buffer (vm, buffers[i]);
       u8 l4_proto = 0;
-      u32 oflags = 0;
+      vnet_buffer_oflags_t oflags = 0;
 
       ethernet_header_t *eh =
        (ethernet_header_t *) vlib_buffer_get_current (b0);