* [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
@ 2022-03-02 12:33 Harold Huang
2022-03-02 18:16 ` Ferruh Yigit
2022-03-03 2:18 ` Harold Huang
0 siblings, 2 replies; 6+ messages in thread
From: Harold Huang @ 2022-03-02 12:33 UTC (permalink / raw)
To: dev; +Cc: Harold Huang, Ferruh Yigit, Liron Himi
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")
Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
---
drivers/net/kni/rte_eth_kni.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
index c428caf441..23b15edfac 100644
--- a/drivers/net/kni/rte_eth_kni.c
+++ b/drivers/net/kni/rte_eth_kni.c
@@ -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.27.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
2022-03-02 12:33 [PATCH] net/kni: initialize rte_kni_conf to 0 before using it Harold Huang
@ 2022-03-02 18:16 ` Ferruh Yigit
2022-03-03 1:57 ` Harold Huang
2022-03-03 2:18 ` Harold Huang
1 sibling, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2022-03-02 18:16 UTC (permalink / raw)
To: Harold Huang, dev; +Cc: Liron Himi
On 3/2/2022 12:33 PM, 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 in some time we could not change the kni
> device mtu with ip link command.
>
Agree on the problem and the solution, thanks for the fix.
> Fixes: ff1e35fb5f8 ("kni: calculate MTU from mbuf size")
> Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
> ---
> drivers/net/kni/rte_eth_kni.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
> index c428caf441..23b15edfac 100644
> --- a/drivers/net/kni/rte_eth_kni.c
> +++ b/drivers/net/kni/rte_eth_kni.c
> @@ -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));
Can you prefer initialize to zero, instead of 'memset', I think it
is more clear that way:
- struct rte_kni_conf conf;
+ struct rte_kni_conf conf = { 0 };
> strlcpy(conf.name, name, RTE_KNI_NAMESIZE);
> conf.force_bind = 0;
> conf.group_id = port_id;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
2022-03-02 18:16 ` Ferruh Yigit
@ 2022-03-03 1:57 ` Harold Huang
0 siblings, 0 replies; 6+ messages in thread
From: Harold Huang @ 2022-03-03 1:57 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, Liron Himi
On Thu, Mar 3, 2022 at 2:16 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> On 3/2/2022 12:33 PM, 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 in some time we could not change the kni
> > device mtu with ip link command.
> >
>
> Agree on the problem and the solution, thanks for the fix.
>
> > Fixes: ff1e35fb5f8 ("kni: calculate MTU from mbuf size")
> > Signed-off-by: Harold Huang <baymaxhuang@gmail.com>
> > ---
> > drivers/net/kni/rte_eth_kni.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c
> > index c428caf441..23b15edfac 100644
> > --- a/drivers/net/kni/rte_eth_kni.c
> > +++ b/drivers/net/kni/rte_eth_kni.c
> > @@ -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));
>
> Can you prefer initialize to zero, instead of 'memset', I think it
> is more clear that way:
Thanks. Sounds good, fix it.
>
> - struct rte_kni_conf conf;
> + struct rte_kni_conf conf = { 0 };
>
> > strlcpy(conf.name, name, RTE_KNI_NAMESIZE);
> > conf.force_bind = 0;
> > conf.group_id = port_id;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
2022-03-02 12:33 [PATCH] net/kni: initialize rte_kni_conf to 0 before using it Harold Huang
2022-03-02 18:16 ` Ferruh Yigit
@ 2022-03-03 2:18 ` Harold Huang
2022-03-03 11:31 ` Ferruh Yigit
2022-03-04 14:27 ` Ferruh Yigit
1 sibling, 2 replies; 6+ messages in thread
From: Harold Huang @ 2022-03-03 2:18 UTC (permalink / raw)
To: dev; +Cc: Harold Huang, stable, Ferruh Yigit, Liron Himi
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 };
const char *name = dev->device->name + 4; /* remove net_ */
mb_pool = internals->rx_queues[0].mb_pool;
--
2.27.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
2022-03-03 2:18 ` Harold Huang
@ 2022-03-03 11:31 ` Ferruh Yigit
2022-03-04 14:27 ` Ferruh Yigit
1 sibling, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2022-03-03 11:31 UTC (permalink / raw)
To: Harold Huang, dev; +Cc: stable, Liron Himi
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
2022-03-03 2:18 ` Harold Huang
2022-03-03 11:31 ` Ferruh Yigit
@ 2022-03-04 14:27 ` Ferruh Yigit
1 sibling, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2022-03-04 14:27 UTC (permalink / raw)
To: Harold Huang, dev; +Cc: stable, Liron Himi
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;
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-04 14:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 12:33 [PATCH] net/kni: initialize rte_kni_conf to 0 before using it Harold Huang
2022-03-02 18:16 ` Ferruh Yigit
2022-03-03 1:57 ` Harold Huang
2022-03-03 2:18 ` Harold Huang
2022-03-03 11:31 ` Ferruh Yigit
2022-03-04 14:27 ` Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).