DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harold Huang <baymaxhuang@gmail.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Liron Himi <lironh@marvell.com>
Subject: Re: [PATCH] net/kni: initialize rte_kni_conf to 0 before using it
Date: Thu, 3 Mar 2022 09:57:08 +0800	[thread overview]
Message-ID: <CAHJXk3YAT5AwN10-c0vjgH1yRSZwa4yPLyzo3=bWQcE-aQrDOQ@mail.gmail.com> (raw)
In-Reply-To: <b159443c-9407-cdc5-6704-24c4146b459d@intel.com>

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;
>

  reply	other threads:[~2022-03-03  1:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 12:33 Harold Huang
2022-03-02 18:16 ` Ferruh Yigit
2022-03-03  1:57   ` Harold Huang [this message]
2022-03-03  2:18 ` Harold Huang
2022-03-03 11:31   ` Ferruh Yigit
2022-03-04 14:27   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHJXk3YAT5AwN10-c0vjgH1yRSZwa4yPLyzo3=bWQcE-aQrDOQ@mail.gmail.com' \
    --to=baymaxhuang@gmail.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=lironh@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).