diff mbox series

[ovs-dev] odp-execute: Add check for L4 header size.

Message ID 20221208155935.1922700-1-emma.finn@intel.com
State Accepted
Commit 69e71bf791c89690e38afe3b7012066e5d64a129
Headers show
Series [ovs-dev] odp-execute: Add check for L4 header size. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation fail test: fail

Commit Message

Finn, Emma Dec. 8, 2022, 3:59 p.m. UTC
This patch adds check for L4 header size for avx512
implementation of the ipv4 action.

Fixes: 92eb03f7b03a ("odp-execute: Add ISA implementation of set_masked IPv4 action")
Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 lib/odp-execute-avx512.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Ilya Maximets Dec. 14, 2022, 1:42 p.m. UTC | #1
On 12/8/22 16:59, Emma Finn wrote:
> This patch adds check for L4 header size for avx512
> implementation of the ipv4 action.
> 
> Fixes: 92eb03f7b03a ("odp-execute: Add ISA implementation of set_masked IPv4 action")
> Signed-off-by: Emma Finn <emma.finn@intel.com>
> ---
>  lib/odp-execute-avx512.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Thanks!  Applied and backported to 3.0.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/odp-execute-avx512.c b/lib/odp-execute-avx512.c
index ac5c1c63d..c28461ec1 100644
--- a/lib/odp-execute-avx512.c
+++ b/lib/odp-execute-avx512.c
@@ -477,8 +477,9 @@  action_avx512_ipv4_set_addrs(struct dp_packet_batch *batch,
 
             uint16_t delta_checksum = avx512_ipv4_addr_csum_delta(v_packet,
                                                                   v_new_hdr);
+            size_t l4_size = dp_packet_l4_size(packet);
 
-            if (nh->ip_proto == IPPROTO_UDP) {
+            if (nh->ip_proto == IPPROTO_UDP && l4_size >= UDP_HEADER_LEN) {
                 /* New UDP checksum. */
                 struct udp_header *uh = dp_packet_l4(packet);
                 if (uh->udp_csum) {
@@ -492,7 +493,8 @@  action_avx512_ipv4_set_addrs(struct dp_packet_batch *batch,
                     /* Insert new udp checksum. */
                     uh->udp_csum = udp_checksum;
                 }
-            } else if (nh->ip_proto == IPPROTO_TCP) {
+            } else if (nh->ip_proto == IPPROTO_TCP &&
+                       l4_size >= TCP_HEADER_LEN) {
                 /* New TCP checksum. */
                 struct tcp_header *th = dp_packet_l4(packet);
                 uint16_t old_tcp_checksum = ~th->tcp_csum;