DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
To: dev@dpdk.org, Yongseok Koh <yskoh@mellanox.com>
Cc: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Subject: [dpdk-dev] [PATCH v3 1/3] net/mlx5: more checks on MAC addresses
Date: Mon, 23 Apr 2018 13:09:26 +0200	[thread overview]
Message-ID: <bdfe13ff64e3576c7ce6c6e4ea8e19a7741f2c1a.1524477133.git.nelio.laranjeiro@6wind.com> (raw)
In-Reply-To: <cover.1524477133.git.nelio.laranjeiro@6wind.com>
In-Reply-To: <cover.1524477133.git.nelio.laranjeiro@6wind.com>

Verify MAC address before further process.

Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
---
 drivers/net/mlx5/mlx5_mac.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c
index edc7a32ae..f24b5f759 100644
--- a/drivers/net/mlx5/mlx5_mac.c
+++ b/drivers/net/mlx5/mlx5_mac.c
@@ -71,7 +71,10 @@ mlx5_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 	const int vf = priv->config.vf;
 	int ret;
 
-	assert(index < MLX5_MAX_MAC_ADDRESSES);
+	if (index >= MLX5_MAX_MAC_ADDRESSES)
+		return;
+	if (is_zero_ether_addr(&dev->data->mac_addrs[index]))
+		return;
 	if (vf)
 		mlx5_nl_mac_addr_remove(dev, &dev->data->mac_addrs[index],
 					index);
@@ -107,7 +110,14 @@ mlx5_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac,
 	const int vf = priv->config.vf;
 	unsigned int i;
 
-	assert(index < MLX5_MAX_MAC_ADDRESSES);
+	if (index >= MLX5_MAX_MAC_ADDRESSES) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
+	if (is_zero_ether_addr(mac)) {
+		rte_errno = EINVAL;
+		return -rte_errno;
+	}
 	/* First, make sure this address isn't already configured. */
 	for (i = 0; (i != MLX5_MAX_MAC_ADDRESSES); ++i) {
 		/* Skip this index, it's going to be reconfigured. */
-- 
2.17.0

  parent reply	other threads:[~2018-04-23 11:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-18 11:24 [dpdk-dev] [PATCH 0/2] implement set_mc_addr devop Nelio Laranjeiro
2018-04-18 11:24 ` [dpdk-dev] [PATCH 1/2] net/mlx5: split MAC address add/remove code Nelio Laranjeiro
2018-04-18 11:24 ` [dpdk-dev] [PATCH 2/2] net/mlx5: implement multicast add list devop Nelio Laranjeiro
2018-04-18 13:50 ` [dpdk-dev] [PATCH v2 0/3] net/mlx5: implement set_mc_addr devop Nelio Laranjeiro
2018-04-18 14:43   ` Adrien Mazarguil
2018-04-23 11:09   ` [dpdk-dev] [PATCH v3 " Nelio Laranjeiro
2018-04-23 12:46     ` Shahaf Shuler
2018-04-23 11:09   ` Nelio Laranjeiro [this message]
2018-04-23 11:09   ` [dpdk-dev] [PATCH v3 2/3] net/mlx5: split MAC address add/remove code Nelio Laranjeiro
2018-04-23 11:09   ` [dpdk-dev] [PATCH v3 3/3] net/mlx5: implement multicast add list devop Nelio Laranjeiro
2018-04-18 13:50 ` [dpdk-dev] [PATCH v2 1/3] net/mlx5: more checks on MAC addresses Nelio Laranjeiro
2018-04-18 13:50 ` [dpdk-dev] [PATCH v2 2/3] net/mlx5: split MAC address add/remove code Nelio Laranjeiro
2018-04-18 13:50 ` [dpdk-dev] [PATCH v2 3/3] net/mlx5: implement multicast add list devop Nelio Laranjeiro
2018-04-23  5:52   ` Shahaf Shuler
2018-04-23  7:33     ` Nélio Laranjeiro
2018-04-23  7:57       ` Shahaf Shuler
2018-04-23  9:34         ` Nélio Laranjeiro
2018-04-23  9:58           ` Shahaf Shuler

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=bdfe13ff64e3576c7ce6c6e4ea8e19a7741f2c1a.1524477133.git.nelio.laranjeiro@6wind.com \
    --to=nelio.laranjeiro@6wind.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=yskoh@mellanox.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).