[1/5,pktgen] fix race condition in start

Message ID 1547136846-23319-2-git-send-email-rk@semihalf.com (mailing list archive)
State Not Applicable, archived
Headers
Series fixes and minor features |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Rafal Kozik Jan. 10, 2019, 4:14 p.m. UTC
  Flag SENDING_PACKETS must be set last.
When it is set before SEND_FOREVER flag, Tx lcores start to call
pktgen_send_pkts. But as current_tx_count is 0 and SEND_FOREVER
is not yet set, SENDING_PACKETS will be cleared.
This causes in some cases that start command will no take effect.

Fixes: f5f901fdf52b ("Update for 1.8 rte_mbuf changes.")

Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 app/pktgen-cmds.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/app/pktgen-cmds.c b/app/pktgen-cmds.c
index 95f6ef1..655f6bd 100644
--- a/app/pktgen-cmds.c
+++ b/app/pktgen-cmds.c
@@ -1412,10 +1412,10 @@  pktgen_start_transmitting(port_info_t *info)
 		rte_atomic64_set(&info->current_tx_count,
 				 rte_atomic64_read(&info->transmit_count));
 
-		pktgen_set_port_flags(info, SENDING_PACKETS);
-
 		if (rte_atomic64_read(&info->current_tx_count) == 0)
 			pktgen_set_port_flags(info, SEND_FOREVER);
+
+		pktgen_set_port_flags(info, SENDING_PACKETS);
 	}
 }