[dpdk-dev,v2,32/32] app/testpmd: fix invalid port ID
Checks
Commit Message
Some CLIs don't check the input port ID, it
may cause segmentation fault (core dumped).
Fixes: 425781ff5afe ("app/testpmd: add ixgbe VF management")
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
---
app/test-pmd/cmdline.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
Comments
On 12/7/2016 3:32 AM, Wenzhuo Lu wrote:
> Some CLIs don't check the input port ID, it
> may cause segmentation fault (core dumped).
Are these functions (that we are adding extra check) added with this
patchset? If so why not add these checks where function implemented.
If these functions are already implemented before this patchset, this
patch can be standalone patch, instead of being part of this patchset,
and can be before this patchset so that it can be easily backported to
stable trees.
>
> Fixes: 425781ff5afe ("app/testpmd: add ixgbe VF management")
>
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
> ---
<...>
Hi Ferruh,
> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Wednesday, December 7, 2016 11:49 PM
> To: Lu, Wenzhuo; dev@dpdk.org
> Cc: Chen, Jing D
> Subject: Re: [dpdk-dev] [PATCH v2 32/32] app/testpmd: fix invalid port ID
>
> On 12/7/2016 3:32 AM, Wenzhuo Lu wrote:
> > Some CLIs don't check the input port ID, it may cause segmentation
> > fault (core dumped).
>
> Are these functions (that we are adding extra check) added with this patchset? If
> so why not add these checks where function implemented.
>
> If these functions are already implemented before this patchset, this patch can
> be standalone patch, instead of being part of this patchset, and can be before
> this patchset so that it can be easily backported to stable trees.
This patch is for the existing code. I think you're right. I'll remove it from this patch set and send an isolate patch for it.
>
> >
> > Fixes: 425781ff5afe ("app/testpmd: add ixgbe VF management")
> >
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
> > ---
>
> <...>
@@ -10829,6 +10829,9 @@ struct cmd_vf_vlan_anti_spoof_result {
int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
struct rte_eth_dev_info dev_info;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
memset(&dev_info, 0, sizeof(dev_info));
rte_eth_dev_info_get(res->port_id, &dev_info);
@@ -10930,6 +10933,9 @@ struct cmd_vf_mac_anti_spoof_result {
int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
struct rte_eth_dev_info dev_info;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
memset(&dev_info, 0, sizeof(dev_info));
rte_eth_dev_info_get(res->port_id, &dev_info);
@@ -11031,6 +11037,9 @@ struct cmd_vf_vlan_stripq_result {
int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
struct rte_eth_dev_info dev_info;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
memset(&dev_info, 0, sizeof(dev_info));
rte_eth_dev_info_get(res->port_id, &dev_info);
@@ -11129,6 +11138,9 @@ struct cmd_vf_vlan_insert_result {
int ret;
struct rte_eth_dev_info dev_info;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
memset(&dev_info, 0, sizeof(dev_info));
rte_eth_dev_info_get(res->port_id, &dev_info);
@@ -11218,6 +11230,9 @@ struct cmd_tx_loopback_result {
int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
struct rte_eth_dev_info dev_info;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
memset(&dev_info, 0, sizeof(dev_info));
rte_eth_dev_info_get(res->port_id, &dev_info);
@@ -11307,6 +11322,9 @@ struct cmd_all_queues_drop_en_result {
int ret = 0;
int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
switch (ret) {
case 0:
@@ -11390,6 +11408,9 @@ struct cmd_vf_split_drop_en_result {
int ret;
int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id,
is_on);
switch (ret) {
@@ -11474,6 +11495,9 @@ struct cmd_set_vf_mac_addr_result {
struct cmd_set_vf_mac_addr_result *res = parsed_result;
int ret;
+ if (port_id_is_invalid(res->port_id, ENABLED_WARN))
+ return;
+
ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
&res->mac_addr);
switch (ret) {