DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pascal Mazon <pascal.mazon@6wind.com>
To: ferruh.yigit@intel.com, dev@dpdk.org
Cc: pascal.mazon@6wind.com
Subject: [dpdk-dev] [PATCH v3 5/5] net/tap: do not set remote MAC if not necessary
Date: Fri, 12 May 2017 15:01:40 +0200	[thread overview]
Message-ID: <45b478b807ab1cd460204237ead62fff1631a49e.1494593926.git.pascal.mazon@6wind.com> (raw)
In-Reply-To: <cover.1494593926.git.pascal.mazon@6wind.com>

Check for the current MAC address on both the remote and the tap
netdevices before setting a new value.

While there, remove wrong empty lines and ensure tap_ioctl() return
value is negative, just like what is done throughout this code.

Fixes: 2bc06869cd94 ("net/tap: add remote netdevice traffic capture")

Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
---
 drivers/net/tap/rte_eth_tap.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 26a7f84d4f6b..49549b4f1822 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -705,11 +705,11 @@ tap_allmulti_disable(struct rte_eth_dev *dev)
 		tap_flow_implicit_destroy(pmd, TAP_REMOTE_ALLMULTI);
 }
 
-
 static void
 tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 {
 	struct pmd_internals *pmd = dev->data->dev_private;
+	enum ioctl_mode mode = LOCAL_ONLY;
 	struct ifreq ifr;
 
 	if (is_zero_ether_addr(mac_addr)) {
@@ -718,15 +718,20 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 		return;
 	}
 	/* Check the actual current MAC address on the tap netdevice */
-	if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, LOCAL_ONLY) != 0)
+	if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, LOCAL_ONLY) < 0)
 		return;
 	if (is_same_ether_addr((struct ether_addr *)&ifr.ifr_hwaddr.sa_data,
 			       mac_addr))
 		return;
-
+	/* Check the current MAC address on the remote */
+	if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, REMOTE_ONLY) < 0)
+		return;
+	if (!is_same_ether_addr((struct ether_addr *)&ifr.ifr_hwaddr.sa_data,
+			       mac_addr))
+		mode = LOCAL_AND_REMOTE;
 	ifr.ifr_hwaddr.sa_family = AF_LOCAL;
 	rte_memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, ETHER_ADDR_LEN);
-	if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 1, LOCAL_AND_REMOTE) < 0)
+	if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 1, mode) < 0)
 		return;
 	rte_memcpy(&pmd->eth_addr, mac_addr, ETHER_ADDR_LEN);
 	if (pmd->remote_if_index) {
-- 
2.12.0.306.g4a9b9b3

  parent reply	other threads:[~2017-05-12 13:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-14  9:32 [dpdk-dev] [PATCH 0/5] improve tap behavior Pascal Mazon
2017-04-14  9:32 ` [dpdk-dev] [PATCH 1/5] net/tap: add debug messages Pascal Mazon
2017-04-14  9:32 ` [dpdk-dev] [PATCH 2/5] net/tap: remove unnecessary functions Pascal Mazon
2017-04-14  9:32 ` [dpdk-dev] [PATCH 3/5] net/tap: drop unnecessary nested block Pascal Mazon
2017-04-14  9:32 ` [dpdk-dev] [PATCH 4/5] net/tap: create netdevice during probing Pascal Mazon
2017-04-14  9:32 ` [dpdk-dev] [PATCH 5/5] net/tap: do not set remote MAC if not necessary Pascal Mazon
2017-04-14  9:45 ` [dpdk-dev] [PATCH 0/5] improve tap behavior Ferruh Yigit
2017-04-18  8:17 ` Pascal Mazon
2017-04-18  8:17   ` [dpdk-dev] [PATCH v2 1/5] net/tap: add debug messages Pascal Mazon
2017-04-18  8:17   ` [dpdk-dev] [PATCH v2 2/5] net/tap: remove unnecessary functions Pascal Mazon
2017-04-18  8:17   ` [dpdk-dev] [PATCH v2 3/5] net/tap: drop unnecessary nested block Pascal Mazon
2017-04-18  8:17   ` [dpdk-dev] [PATCH v2 4/5] net/tap: create netdevice during probing Pascal Mazon
2017-04-18  8:17   ` [dpdk-dev] [PATCH v2 5/5] net/tap: do not set remote MAC if not necessary Pascal Mazon
2017-05-12 12:29   ` [dpdk-dev] [PATCH 0/5] improve tap behavior Ferruh Yigit
2017-05-12 13:01   ` [dpdk-dev] [PATCH v3 " Pascal Mazon
2017-05-12 13:01     ` [dpdk-dev] [PATCH v3 1/5] net/tap: add debug messages Pascal Mazon
2017-05-12 13:01     ` [dpdk-dev] [PATCH v3 2/5] net/tap: remove unnecessary functions Pascal Mazon
2017-05-12 13:01     ` [dpdk-dev] [PATCH v3 3/5] net/tap: drop unnecessary nested block Pascal Mazon
2017-05-12 13:01     ` [dpdk-dev] [PATCH v3 4/5] net/tap: create netdevice during probing Pascal Mazon
2017-05-12 13:01     ` Pascal Mazon [this message]
2017-05-12 14:04     ` [dpdk-dev] [PATCH v3 0/5] improve tap behavior 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=45b478b807ab1cd460204237ead62fff1631a49e.1494593926.git.pascal.mazon@6wind.com \
    --to=pascal.mazon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@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).