[dpdk-dev] [PATCH 1/2] app/testpmd: fix integer overflow during get DCB conf

Li, Xiaoyun xiaoyun.li at intel.com
Sun Apr 25 04:05:23 CEST 2021


Hi

> -----Original Message-----
> From: Min Hu (Connor) <humin29 at huawei.com>
> Sent: Thursday, April 22, 2021 15:04
> To: dev at dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit at intel.com>; Li, Xiaoyun <xiaoyun.li at intel.com>
> Subject: [PATCH 1/2] app/testpmd: fix integer overflow during get DCB conf
> 
> From: Chengchang Tang <tangchengchang at huawei.com>
> 
> In C, constant is treated as integer. Therefore, if nb_queque_pools is
> ETH_32_POOLS, the shift here may cause integer overflow.
> 
> Fixes: 1a572499beb6 ("app/testpmd: setup DCB forwarding based on traffic
> class")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Chengchang Tang <tangchengchang at huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
> ---
>  app/test-pmd/testpmd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index
> afa2a6b..6784160 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -3640,7 +3640,7 @@ get_eth_dcb_conf(portid_t pid, struct rte_eth_conf
> *eth_conf,
>  		for (i = 0; i < vmdq_rx_conf->nb_pool_maps; i++) {
>  			vmdq_rx_conf->pool_map[i].vlan_id = vlan_tags[i];
>  			vmdq_rx_conf->pool_map[i].pools =
> -				1 << (i % vmdq_rx_conf->nb_queue_pools);
> +				1ULL << (i % vmdq_rx_conf->nb_queue_pools);

In get_eth_dcb_conf(),
vmdq_rx_conf->nb_queue_pools =
			(num_tcs ==  ETH_4_TCS ? ETH_32_POOLS : ETH_16_POOLS);

It will only be 16 or 32.
So I don't think this patch is necessary unless you're going to use the value ETH_64_POOLS.

>  		}
>  		for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) {
>  			vmdq_rx_conf->dcb_tc[i] = i % num_tcs;
> --
> 2.7.4



More information about the dev mailing list