summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Bielski <mba@semihalf.com>2019-08-01 13:45:36 +0200
committerKevin Traynor <ktraynor@redhat.com>2019-09-13 10:37:20 +0100
commitc614f8cb4bc2d57b0be321a18f3a6b10cb1b3912 (patch)
tree9a0b86e0ab80f6eca22ecb1fa5f286f016473b34
parent3d2802e7739aacce502e5be043ee3b0f306878be (diff)
downloaddpdk-stable-c614f8cb4bc2d57b0be321a18f3a6b10cb1b3912.zip
dpdk-stable-c614f8cb4bc2d57b0be321a18f3a6b10cb1b3912.tar.gz
dpdk-stable-c614f8cb4bc2d57b0be321a18f3a6b10cb1b3912.tar.xz
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") Reported-by: Eduard Serra <eserra@vmware.com> Signed-off-by: Maciej Bielski <mba@semihalf.com> Acked-by: Michal Krawczyk <mk@semihalf.com>
-rw-r--r--drivers/net/ena/ena_ethdev.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index fa7b58b..0779bb7 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -339,12 +339,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 {