Skip to contentSkip to conversation

net/kni: reset rte_kni_conf struct before initialization

PATCH Superseded Harold Huang 2 participants 3 messages Dec 3, 2021 – Feb 27, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/kni: reset rte_kni_conf struct before initialization

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 in some time we could not change the kni device mtu with ip link command.

Fixes ff1e35fb5f8 ("kni: calculate MTU from mbuf size")
---
 drivers/net/kni/rte_eth_kni.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/kni/rte_eth_kni.c +1 -0
index c428caf441..23b15edfac 100644
@@ -128,6 +128,7 @@ eth_kni_start(struct rte_eth_dev *dev)
  const char *name = dev->device->name + 4; /* remove net_ */
 
  mb_pool = internals->rx_queues[0].mb_pool;
+ memset(&conf, 0, sizeof(conf));
  strlcpy(conf.name, name, RTE_KNI_NAMESIZE);
  conf.force_bind = 0;
  conf.group_id = port_id;

--
2.18.2

#1 lore raw

PATCH v4 1/1 net/kni: reset rte_kni_conf struct before initialization

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 isunexpected and in some time we could not change the kni device mtu with ip link command.

Fixes ff1e35fb5f8 ("kni: calculate MTU from mbuf size")
---
 drivers/net/kni/rte_eth_kni.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/kni/rte_eth_kni.c +1 -0
index c428caf441..23b15edfac 100644
@@ -128,6 +128,7 @@ eth_kni_start(struct rte_eth_dev *dev)
 	const char *name = dev->device->name + 4; /* remove net_ */
 
 	mb_pool = internals->rx_queues[0].mb_pool;
+	memset(&conf, 0, sizeof(conf));
 	strlcpy(conf.name, name, RTE_KNI_NAMESIZE);
 	conf.force_bind = 0;
 	conf.group_id = port_id;
Signature · 1 line
2.27.0
#2 lore raw

+Cc Ferruh

05/12/2021 07:21, Harold Huang:

Quoted 24 lines

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 isunexpected and in some time we could not change the kni device mtu with ip link command.

Fixes ff1e35fb5f8 ("kni: calculate MTU from mbuf size")
---
 drivers/net/kni/rte_eth_kni.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/kni/rte_eth_kni.c +1 -0
index c428caf441..23b15edfac 100644
@@ -128,6 +128,7 @@ eth_kni_start(struct rte_eth_dev *dev)
 	const char *name = dev->device->name + 4; /* remove net_ */
 
 	mb_pool = internals->rx_queues[0].mb_pool;
+	memset(&conf, 0, sizeof(conf));
 	strlcpy(conf.name, name, RTE_KNI_NAMESIZE);
 	conf.force_bind = 0;
 	conf.group_id = port_id;