app/testpmd: avoid process ID out of range
authorHaiyue Wang <haiyue.wang@intel.com>
Mon, 15 Nov 2021 06:05:09 +0000 (14:05 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 15 Nov 2021 15:26:17 +0000 (16:26 +0100)
The 'proc_id' should be less than 'num_procs', if not, exit the testpmd
and show the error message.

Fixes: a550baf24af9 ("app/testpmd: support multi-process")

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Acked-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/parameters.c

index 0974b0a..5251722 100644 (file)
@@ -1527,6 +1527,12 @@ launch_args_parse(int argc, char** argv)
                rte_exit(EXIT_FAILURE, "Command line is incorrect\n");
        }
 
+       if (proc_id >= (int)num_procs)
+               rte_exit(EXIT_FAILURE,
+                        "The multi-process option '%s(%d)' should be less than '%s(%u)'\n",
+                        PARAM_PROC_ID, proc_id,
+                        PARAM_NUM_PROCS, num_procs);
+
        /* Set offload configuration from command line parameters. */
        rx_mode.offloads = rx_offloads;
        tx_mode.offloads = tx_offloads;