summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2020-10-06 11:58:40 +0200
committerBeno�t Ganne <bganne@cisco.com>2020-10-19 12:58:31 +0000
commitf8d421f2bda94ac9f90bebe06c4ec4816f0a6696 (patch)
tree865bfabe778d8cd959b5205f6972f28fc23e7e58 /src
parent931c6f54bad50d880560e8705e08b16bf8a19337 (diff)
gso: add checksum validation in gro
Type: improvement Change-Id: I0680c1626a46c8afcb7b6e665cc0734b7b37fd18 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vnet/gso/gro_func.h23
-rw-r--r--src/vnet/gso/node.c1
2 files changed, 23 insertions, 1 deletions
diff --git a/src/vnet/gso/gro_func.h b/src/vnet/gso/gro_func.h
index a410a651933..95def6f8eba 100644
--- a/src/vnet/gso/gro_func.h
+++ b/src/vnet/gso/gro_func.h
@@ -140,6 +140,23 @@ gro_merge_buffers (vlib_main_t * vm, vlib_buffer_t * b0,
}
static_always_inline u32
+gro_validate_checksum (vlib_main_t * vm, vlib_buffer_t * b0,
+ generic_header_offset_t * gho0, int is_ip4)
+{
+ u32 flags = 0;
+
+ if (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM)
+ return VNET_BUFFER_F_L4_CHECKSUM_CORRECT;
+ vlib_buffer_advance (b0, gho0->l3_hdr_offset);
+ if (is_ip4)
+ flags = ip4_tcp_udp_validate_checksum (vm, b0);
+ else
+ flags = ip6_tcp_udp_icmp_validate_checksum (vm, b0);
+ vlib_buffer_advance (b0, -gho0->l3_hdr_offset);
+ return flags;
+}
+
+static_always_inline u32
gro_get_packet_data (vlib_main_t * vm, vlib_buffer_t * b0,
generic_header_offset_t * gho0,
gro_flow_key_t * flow_key0, int is_l2)
@@ -147,6 +164,7 @@ gro_get_packet_data (vlib_main_t * vm, vlib_buffer_t * b0,
ip4_header_t *ip4_0 = 0;
ip6_header_t *ip6_0 = 0;
tcp_header_t *tcp0 = 0;
+ u32 flags = 0;
u32 pkt_len0 = 0;
u16 l234_sz0 = 0;
u32 sw_if_index0[VLIB_N_RX_TX] = { ~0 };
@@ -181,17 +199,22 @@ gro_get_packet_data (vlib_main_t * vm, vlib_buffer_t * b0,
if (gho0->gho_flags & GHO_F_IP4)
{
+ flags = gro_validate_checksum (vm, b0, gho0, 1);
gro_get_ip4_flow_from_packet (sw_if_index0, ip4_0, tcp0, flow_key0,
is_l2);
}
else if (gho0->gho_flags & GHO_F_IP6)
{
+ flags = gro_validate_checksum (vm, b0, gho0, 0);
gro_get_ip6_flow_from_packet (sw_if_index0, ip6_0, tcp0, flow_key0,
is_l2);
}
else
return 0;
+ if ((flags & VNET_BUFFER_F_L4_CHECKSUM_CORRECT) == 0)
+ return 0;
+
pkt_len0 = vlib_buffer_length_in_chain (vm, b0);
if (PREDICT_FALSE (pkt_len0 >= TCP_MAX_GSO_SZ))
return 0;
diff --git a/src/vnet/gso/node.c b/src/vnet/gso/node.c
index 23213a76b0f..d0c5ca054e6 100644
--- a/src/vnet/gso/node.c
+++ b/src/vnet/gso/node.c
@@ -97,7 +97,6 @@ tso_segment_ipip_tunnel_fixup (vlib_main_t * vm,
i++;
}
return n_tx_bytes;
-
}
static_always_inline void