[3/3] app/testpmd: fix uninitialized members when setting PFC

Message ID 20200121114433.57543-4-huwei013@chinasoftinc.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: fixes for testpmd application |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed

Commit Message

Wei Hu (Xavier) Jan. 21, 2020, 11:44 a.m. UTC
  From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>

Only a part of members in the local structure variable named pfc_conf are
initialized in the function named cmd_priority_flow_ctrl_set_parsed when
typing "set pfc_ctrl..." command, and others are random values. However,
those uninitialized members may cause failure.

This patch adds clearing zero operation before calling the API named
rte_eth_dev_priority_flow_ctrl_set API with pfc_conf as the input
parameter.

Fixes: 9b53e542e9e1 ("app/testpmd: add priority flow control")
Cc: stable@dpdk.org

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Xuan Li <lixuan47@hisilicon.com>
---
 app/test-pmd/cmdline.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Ferruh Yigit Jan. 28, 2020, 11:21 a.m. UTC | #1
On 1/21/2020 11:44 AM, Wei Hu (Xavier) wrote:
> From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
> 
> Only a part of members in the local structure variable named pfc_conf are
> initialized in the function named cmd_priority_flow_ctrl_set_parsed when
> typing "set pfc_ctrl..." command, and others are random values. However,
> those uninitialized members may cause failure.
> 
> This patch adds clearing zero operation before calling the API named
> rte_eth_dev_priority_flow_ctrl_set API with pfc_conf as the input
> parameter.
> 
> Fixes: 9b53e542e9e1 ("app/testpmd: add priority flow control")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Huisong Li <lihuisong@huawei.com>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> Signed-off-by: Xuan Li <lixuan47@hisilicon.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Ferruh Yigit Feb. 4, 2020, 6:25 p.m. UTC | #2
On 1/28/2020 11:21 AM, Ferruh Yigit wrote:
> On 1/21/2020 11:44 AM, Wei Hu (Xavier) wrote:
>> From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
>>
>> Only a part of members in the local structure variable named pfc_conf are
>> initialized in the function named cmd_priority_flow_ctrl_set_parsed when
>> typing "set pfc_ctrl..." command, and others are random values. However,
>> those uninitialized members may cause failure.
>>
>> This patch adds clearing zero operation before calling the API named
>> rte_eth_dev_priority_flow_ctrl_set API with pfc_conf as the input
>> parameter.
>>
>> Fixes: 9b53e542e9e1 ("app/testpmd: add priority flow control")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Huisong Li <lihuisong@huawei.com>
>> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
>> Signed-off-by: Xuan Li <lixuan47@hisilicon.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index a09cb87e1..b6d8ef0f0 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -7090,6 +7090,7 @@  cmd_priority_flow_ctrl_set_parsed(void *parsed_result,
 		{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
 	};
 
+	memset(&pfc_conf, 0, sizeof(struct rte_eth_pfc_conf));
 	rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0;
 	tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0;
 	pfc_conf.fc.mode       = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable];