net/kni: initialize rte_kni_conf to 0 before using it

Message ID 20220303021803.382374-1-baymaxhuang@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/kni: initialize rte_kni_conf to 0 before using it |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing fail Testing issues
ci/iol-x86_64-unit-testing fail Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Harold Huang March 3, 2022, 2:18 a.m. UTC
  When kni driver calls eth_kni_start to start device, some fields such as
min_mtu and max_mtu of rte_kni_conf are not initialized. It will cause
kni_ioctl_create create a kni netdevice with a random min_mtu and max_mtu
value. This is unexpected and sometimes we could not change the kni
device mtu with ip link command.

Fixes: ff1e35fb5f83 ("kni: calculate MTU from mbuf size")
Cc: stable@dpdk.org
Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
---
 drivers/net/kni/rte_eth_kni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ferruh Yigit March 3, 2022, 11:31 a.m. UTC | #1
On 3/3/2022 2:18 AM, Harold Huang wrote:
> When kni driver calls eth_kni_start to start device, some fields such as
> min_mtu and max_mtu of rte_kni_conf are not initialized. It will cause
> kni_ioctl_create create a kni netdevice with a random min_mtu and max_mtu
> value. This is unexpected and sometimes we could not change the kni
> device mtu with ip link command.
> 
> Fixes: ff1e35fb5f83 ("kni: calculate MTU from mbuf size")
> Cc: stable@dpdk.org
> Signed-off-by: Harold Huang <baymaxhuang@gmail.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/main, thanks.
  
Ferruh Yigit March 4, 2022, 2:27 p.m. UTC | #2
On 3/3/2022 2:18 AM, Harold Huang wrote:
> When kni driver calls eth_kni_start to start device, some fields such as
> min_mtu and max_mtu of rte_kni_conf are not initialized. It will cause
> kni_ioctl_create create a kni netdevice with a random min_mtu and max_mtu
> value. This is unexpected and sometimes we could not change the kni
> device mtu with ip link command.
> 
> Fixes: ff1e35fb5f83 ("kni: calculate MTU from mbuf size")
> Cc: stable@dpdk.org
> Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
> ---
>   drivers/net/kni/rte_eth_kni.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
> index c428caf441..ba58d9dbae 100644
> --- a/drivers/net/kni/rte_eth_kni.c
> +++ b/drivers/net/kni/rte_eth_kni.c
> @@ -124,7 +124,7 @@ eth_kni_start(struct rte_eth_dev *dev)
>   	struct pmd_internals *internals = dev->data->dev_private;
>   	uint16_t port_id = dev->data->port_id;
>   	struct rte_mempool *mb_pool;
> -	struct rte_kni_conf conf;
> +	struct rte_kni_conf conf = { 0 };

This is causing build error [1], updated in next-net [2] to fix.

Normally '{ 0 }' should be universal zero-initializer, but I guess
it fails because of old compiler version:
gcc 4.8.5 "cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)"


[1]
FAILED: drivers/a715181@@tmp_rte_net_kni@sta/net_kni_rte_eth_kni.c.o
../drivers/net/kni/rte_eth_kni.c: In function 'eth_kni_start':
../drivers/net/kni/rte_eth_kni.c:127:9:
	error: missing braces around initializer [-Werror=missing-braces]
   struct rte_kni_conf conf = { 0 };
          ^

[2]
struct rte_kni_conf conf = {{0}};

>   	const char *name = dev->device->name + 4; /* remove net_ */
>   
>   	mb_pool = internals->rx_queues[0].mb_pool;
  

Patch

diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index c428caf441..ba58d9dbae 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -124,7 +124,7 @@  eth_kni_start(struct rte_eth_dev *dev)
 	struct pmd_internals *internals = dev->data->dev_private;
 	uint16_t port_id = dev->data->port_id;
 	struct rte_mempool *mb_pool;
-	struct rte_kni_conf conf;
+	struct rte_kni_conf conf = { 0 };
 	const char *name = dev->device->name + 4; /* remove net_ */
 
 	mb_pool = internals->rx_queues[0].mb_pool;