From: "Dai, Wei" <wei.dai@intel.com>
To: "Nélio Laranjeiro" <nelio.laranjeiro@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
"thomas.monjalon@6wind.com" <thomas.monjalon@6wind.com>,
"harish.patil@cavium.com" <harish.patil@cavium.com>,
"rasesh.mody@cavium.com" <rasesh.mody@cavium.com>,
"stephen.hurd@broadcom.com" <stephen.hurd@broadcom.com>,
"ajit.khaparde@broadcom.com" <ajit.khaparde@broadcom.com>,
"Lu, Wenzhuo" <wenzhuo.lu@intel.com>,
"Zhang, Helin" <helin.zhang@intel.com>,
"Ananyev, Konstantin" <konstantin.ananyev@intel.com>,
"Wu, Jingjing" <jingjing.wu@intel.com>,
"Chen, Jing D" <jing.d.chen@intel.com>,
"adrien.mazarguil@6wind.com" <adrien.mazarguil@6wind.com>,
"Richardson, Bruce" <bruce.richardson@intel.com>,
"yuanhan.liu@linux.intel.com" <yuanhan.liu@linux.intel.com>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-stable] [PATCH 1/2] ethdev: fix adding invalid MAC addr
Date: Fri, 7 Apr 2017 01:38:34 +0000 [thread overview]
Message-ID: <49759EB36A64CF4892C1AFEC9231E8D650A52D88@PGSMSX106.gar.corp.intel.com> (raw)
In-Reply-To: <20170403091816.GC16796@autoinstall.dev.6wind.com>
Hi, Nélio Laranjeiro
Thanks for your feedback.
I will change them in my next version of patch set.
-Wei
> -----Original Message-----
> From: Nélio Laranjeiro [mailto:nelio.laranjeiro@6wind.com]
> Sent: Monday, April 3, 2017 5:18 PM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org; thomas.monjalon@6wind.com; harish.patil@cavium.com;
> rasesh.mody@cavium.com; stephen.hurd@broadcom.com;
> ajit.khaparde@broadcom.com; Lu, Wenzhuo <wenzhuo.lu@intel.com>; Zhang,
> Helin <helin.zhang@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Chen,
> Jing D <jing.d.chen@intel.com>; adrien.mazarguil@6wind.com; Richardson,
> Bruce <bruce.richardson@intel.com>; yuanhan.liu@linux.intel.com;
> maxime.coquelin@redhat.com; stable@dpdk.org
> Subject: Re: [PATCH 1/2] ethdev: fix adding invalid MAC addr
>
> Hi,
>
> Please see below some comments,
>
> On Sat, Apr 01, 2017 at 04:03:16PM +0800, Wei Dai wrote:
> >[...]
> > diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index
> >79efaaa..d61bb27 100644
> > --- a/drivers/net/mlx4/mlx4.c
> > +++ b/drivers/net/mlx4/mlx4.c
> > @@ -4630,26 +4630,30 @@ mlx4_mac_addr_remove(struct rte_eth_dev
> *dev, uint32_t index)
> > * @param vmdq
> > * VMDq pool index to associate address with (ignored).
> > */
> > -static void
> > +static int
>
> Please keep function documentation up to date.
>
> > mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr
> *mac_addr,
> > uint32_t index, uint32_t vmdq)
> > {
> > struct priv *priv = dev->data->dev_private;
> > + int re;
> >
> > if (mlx4_is_secondary())
> > - return;
> > + return -1;
>
> Should not it return ENOSUP instead?
>
> > (void)vmdq;
> > priv_lock(priv);
> > DEBUG("%p: adding MAC address at index %" PRIu32,
> > (void *)dev, index);
> > /* Last array entry is reserved for broadcast. */
> > - if (index >= (elemof(priv->mac) - 1))
> > - goto end;
> > - priv_mac_addr_add(priv, index,
> > + if (index >= (elemof(priv->mac) - 1)) {
> > + priv_unlock(priv);
> > + return -2;
> > + }
> > + re = priv_mac_addr_add(priv, index,
> > (const uint8_t (*)[ETHER_ADDR_LEN])
> > mac_addr->addr_bytes);
>
> You have an issue here, internal function of mlx drivers return positives errno
> (as described in their functions documentation).
> It should be negated before returning.
>
> > end:
> > priv_unlock(priv);
> > + return re;
> > }
> >
> > /**
> > diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index
> > 879da5e..cca7a36 100644
> > --- a/drivers/net/mlx5/mlx5.h
> > +++ b/drivers/net/mlx5/mlx5.h
> > @@ -229,8 +229,8 @@ int hash_rxq_mac_addrs_add(struct hash_rxq *);
> > int priv_mac_addr_add(struct priv *, unsigned int,
> > const uint8_t (*)[ETHER_ADDR_LEN]); int
> > priv_mac_addrs_enable(struct priv *); -void mlx5_mac_addr_add(struct
> > rte_eth_dev *, struct ether_addr *, uint32_t,
> > - uint32_t);
> > +int mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr
> *mac_addr,
> > + uint32_t index, uint32_t vmdq);
> > void mlx5_mac_addr_set(struct rte_eth_dev *, struct ether_addr *);
> >
> > /* mlx5_rss.c */
> > diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
> > index 4fcfd3b..db93f4e 100644
> > --- a/drivers/net/mlx5/mlx5_mac.c
> > +++ b/drivers/net/mlx5/mlx5_mac.c
> > @@ -470,26 +470,30 @@ priv_mac_addrs_enable(struct priv *priv)
> > * @param vmdq
> > * VMDq pool index to associate address with (ignored).
> > */
> > -void
> > +int
> > mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr
> *mac_addr,
> > uint32_t index, uint32_t vmdq)
> > {
> > struct priv *priv = dev->data->dev_private;
> > + int re;
> >
> > if (mlx5_is_secondary())
> > - return;
> > + return -1;
> >
> > (void)vmdq;
> > priv_lock(priv);
> > DEBUG("%p: adding MAC address at index %" PRIu32,
> > (void *)dev, index);
> > - if (index >= RTE_DIM(priv->mac))
> > + if (index >= RTE_DIM(priv->mac)) {
> > + re = -2;
> > goto end;
> > - priv_mac_addr_add(priv, index,
> > + }
> > + re = priv_mac_addr_add(priv, index,
> > (const uint8_t (*)[ETHER_ADDR_LEN])
> > mac_addr->addr_bytes);
> > end:
> > priv_unlock(priv);
> > + return re;
> > }
> >[...]
>
> Same remarks here,
>
> Thanks,
>
> --
> Nélio Laranjeiro
> 6WIND
next prev parent reply other threads:[~2017-04-07 1:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1491033797-14186-1-git-send-email-wei.dai@intel.com>
2017-04-01 8:03 ` Wei Dai
2017-04-03 9:18 ` Nélio Laranjeiro
2017-04-07 1:38 ` Dai, Wei [this message]
[not found] <1490979887-27827-1-git-send-email-wei.dai@intel.com>
2017-03-31 17:04 ` [dpdk-stable] [PATCH 1/2] ethdev: fix adding invalid mac addr Wei Dai
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=49759EB36A64CF4892C1AFEC9231E8D650A52D88@PGSMSX106.gar.corp.intel.com \
--to=wei.dai@intel.com \
--cc=adrien.mazarguil@6wind.com \
--cc=ajit.khaparde@broadcom.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=harish.patil@cavium.com \
--cc=helin.zhang@intel.com \
--cc=jing.d.chen@intel.com \
--cc=jingjing.wu@intel.com \
--cc=konstantin.ananyev@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=nelio.laranjeiro@6wind.com \
--cc=rasesh.mody@cavium.com \
--cc=stable@dpdk.org \
--cc=stephen.hurd@broadcom.com \
--cc=thomas.monjalon@6wind.com \
--cc=wenzhuo.lu@intel.com \
--cc=yuanhan.liu@linux.intel.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).