From 7aeb647c69d5d583d6df319ee7eac7a32bc9fced Mon Sep 17 00:00:00 2001 From: Arthur de Kerhor Date: Tue, 1 Jun 2021 11:27:48 +0200 Subject: udp: calculate inner checksums if needed before udp encap We do not want to encap headers containing wrong checksums. Additionnally, this clears the checksums offlads flags, which was something missing since the outer headers checksums were calculated during the encap. Hence, those should not be recalculated afterwards. Type: fix Change-Id: I7fd07987b4f13f76c6990a1c08dc2f960bdd8de1 Signed-off-by: Arthur de Kerhor --- src/vnet/udp/udp_encap.c | 2 +- src/vnet/udp/udp_inlines.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vnet/udp/udp_encap.c b/src/vnet/udp/udp_encap.c index 28ea56050a6..cb93adb8d39 100644 --- a/src/vnet/udp/udp_encap.c +++ b/src/vnet/udp/udp_encap.c @@ -64,7 +64,7 @@ udp_encap_add_and_lock (fib_protocol_t proto, u8 pfx_len = 0; index_t uei; - pool_get_aligned (udp_encap_pool, ue, CLIB_CACHE_LINE_BYTES); + pool_get_aligned_zero (udp_encap_pool, ue, CLIB_CACHE_LINE_BYTES); uei = ue - udp_encap_pool; vlib_validate_combined_counter (&(udp_encap_counters), uei); diff --git a/src/vnet/udp/udp_inlines.h b/src/vnet/udp/udp_inlines.h index 067289c9979..e4eb0c88e83 100644 --- a/src/vnet/udp/udp_inlines.h +++ b/src/vnet/udp/udp_inlines.h @@ -20,6 +20,7 @@ #include #include #include +#include always_inline void * vlib_buffer_push_udp (vlib_buffer_t * b, u16 sp, u16 dp, u8 offload_csum) @@ -99,6 +100,8 @@ always_inline void ip_udp_encap_one (vlib_main_t * vm, vlib_buffer_t * b0, u8 * ec0, word ec_len, u8 is_ip4) { + vnet_calc_checksums_inline (vm, b0, is_ip4, !is_ip4); + vlib_buffer_advance (b0, -ec_len); if (is_ip4) @@ -132,6 +135,9 @@ ip_udp_encap_two (vlib_main_t * vm, vlib_buffer_t * b0, vlib_buffer_t * b1, ASSERT (_vec_len (ec0) == _vec_len (ec1)); + vnet_calc_checksums_inline (vm, b0, is_v4, !is_v4); + vnet_calc_checksums_inline (vm, b1, is_v4, !is_v4); + vlib_buffer_advance (b0, -ec_len); vlib_buffer_advance (b1, -ec_len); -- cgit 1.2.3-korg