forked from amzn/amzn-drivers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0019-net-ena-fix-L4-checksum-Tx-offload.patch
52 lines (44 loc) · 2.05 KB
/
0019-net-ena-fix-L4-checksum-Tx-offload.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From 4d2331ea6805d5fb1e6f5509618317bfe91ee4a2 Mon Sep 17 00:00:00 2001
From: Maciej Bielski <[email protected]>
Date: Thu, 1 Aug 2019 13:45:36 +0200
Subject: [PATCH 19/19] net/ena: fix L4 checksum Tx offload
[ upstream commit 40e7c02155625f18a87faf5e6a8cec2e986146e8 ]
During an if-condition evaluation, a 2-bit flag evaluates to 'true' for
'0x1', '0x2' and '0x3'. Thus, from this perspective these flags are
indistinguishable. To make them distinct, respective bits must be
extracted with a mask and then checked for strict equality.
Specifically here, even if `PKT_TX_UDP_CKSUM` (value '0x3') was set, the
expression `mbuf->ol_flags & PKT_TX_TCP` (the second flag of value
'0x1') is evaluated first and the result is 'true'. In consequence, for
UDP packets the execution flow enters an incorrect branch.
Fixes: 56b8b9b7e5d2 ("net/ena: convert to new Tx offloads API")
Change-Id: I7917b209856f24e5d0b6481a94b322d09266bc5b
Reported-by: Eduard Serra <[email protected]>
Signed-off-by: Maciej Bielski <[email protected]>
Acked-by: Michal Krawczyk <[email protected]>
---
drivers/net/ena/ena_ethdev.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index f25e5ba827..7768eabbab 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -335,12 +335,13 @@ static inline void ena_tx_mbuf_prepare(struct rte_mbuf *mbuf,
}
/* check if L4 checksum is needed */
- if ((mbuf->ol_flags & PKT_TX_TCP_CKSUM) &&
+ if (((mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) &&
(queue_offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) {
ena_tx_ctx->l4_proto = ENA_ETH_IO_L4_PROTO_TCP;
ena_tx_ctx->l4_csum_enable = true;
- } else if ((mbuf->ol_flags & PKT_TX_UDP_CKSUM) &&
- (queue_offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
+ } else if (((mbuf->ol_flags & PKT_TX_L4_MASK) ==
+ PKT_TX_UDP_CKSUM) &&
+ (queue_offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
ena_tx_ctx->l4_proto = ENA_ETH_IO_L4_PROTO_UDP;
ena_tx_ctx->l4_csum_enable = true;
} else {
--
2.20.1