When using "enable [ports] range" command to enable the range sending feature, 
the code will only set the "SEND_RANGE_PKTS" without any 
"CLEAR_FAST_ALLOC_FLAG" (belongs to "start" command).
If the enable actiong is done when no packets are sending, everything will be 
OK. But when sending packets, it will automaticlly switch the bufferpool from 
tx_mp to range_mp without "pktgen_setup_packets" called to set up and fill some 
fileds of the buffers. I assume that the sending process will fail and the 
buffers will get leaked. (Correct me if anything wrong). And the alloc function 
will return -105 which indicates no free buffer. Then the only thing we can do 
is to quit the process and restart it.
To avoid such wrong operation procedures, a check is added in the enable_range 


Signed-off-by: Bing Zhao <iloveth...@163.com>
 app/pktgen-cmds.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/app/pktgen-cmds.c b/app/pktgen-cmds.c
index 66ea98a..cc3a2ec 100644
--- a/app/pktgen-cmds.c
+++ b/app/pktgen-cmds.c
@@ -2591,6 +2591,10 @@ void
 enable_range(port_info_t *info, uint32_t state)
        if (state == ENABLE_STATE) {
+               if (SENDING_PACKETS & rte_atomic32_read(&info->port_flags)) {
+                       pktgen_log_warning("Cannot enable the range settings 
while sending packets!");
+                       return;
+               }
                pktgen_clr_port_flags(info, SEND_SEQ_PKTS);
                pktgen_clr_port_flags(info, SEND_PCAP_PKTS);
                pktgen_set_port_flags(info, SEND_RANGE_PKTS);

Reply via email to