DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pascal Mazon <pascal.mazon@6wind.com>
To: keith.wiles@intel.com
Cc: dev@dpdk.org, Pascal Mazon <pascal.mazon@6wind.com>
Subject: [dpdk-dev] [PATCH v2 2/2] net/tap: fix redirection rule after MAC change
Date: Fri, 31 Mar 2017 15:02:44 +0200	[thread overview]
Message-ID: <88a052bf2c94fd2fa4fe84d660099de5ce0e48dd.1490965230.git.pascal.mazon@6wind.com> (raw)
In-Reply-To: <eb463571ff1a69117cb4c71478cf41d7cc311010.1490780602.git.pascal.mazon@6wind.com>

This is necessary to ensure packets with the new MAC address as
destination get redirected to the tap device.

Also change the MAC address only if the current one is different from
the requested one.

Fixes: 75b6a1f7f004 ("net/tap: add remote netdevice traffic capture")
Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
---
 drivers/net/tap/rte_eth_tap.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 72897adcce3b..618fd02800d5 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -775,12 +775,35 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 			dev->data->name);
 		return;
 	}
+	/* Check the actual current MAC address on the tap netdevice */
+	if (tap_ioctl(pmd, SIOCGIFHWADDR, &ifr, 0, LOCAL_ONLY) != 0) {
+		RTE_LOG(ERR, PMD,
+			"%s: couldn't check current tap MAC address\n",
+			dev->data->name);
+		return;
+	}
+	if (is_same_ether_addr((struct ether_addr *)&ifr.ifr_hwaddr.sa_data,
+			       mac_addr))
+		return;
 
 	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)
 		return;
 	rte_memcpy(&pmd->eth_addr, mac_addr, ETHER_ADDR_LEN);
+	if (pmd->remote_if_index) {
+		/* Replace MAC redirection rule after a MAC change */
+		if (tap_flow_implicit_destroy(pmd, TAP_REMOTE_LOCAL_MAC) < 0) {
+			RTE_LOG(ERR, PMD,
+				"%s: Couldn't delete MAC redirection rule\n",
+				dev->data->name);
+			return;
+		}
+		if (tap_flow_implicit_create(pmd, TAP_REMOTE_LOCAL_MAC) < 0)
+			RTE_LOG(ERR, PMD,
+				"%s: Couldn't add MAC redirection rule\n",
+				dev->data->name);
+	}
 }
 
 static int
-- 
2.12.0.306.g4a9b9b3

      parent reply	other threads:[~2017-03-31 13:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29  9:44 [dpdk-dev] [PATCH 1/2] net/tap: update netlink error code management Pascal Mazon
2017-03-29  9:44 ` [dpdk-dev] [PATCH 2/2] net/tap: update redirection rule after MAC change Pascal Mazon
2017-03-31 13:02   ` [dpdk-dev] [PATCH v2 1/2] net/tap: fix null MAC address at init Pascal Mazon
2017-03-31 13:54     ` [dpdk-dev] [PATCH v3 0/3] net/tap: netlink and MAC address fixes Pascal Mazon
2017-03-31 13:54       ` [dpdk-dev] [PATCH v3 1/3] net/tap: update netlink error code management Pascal Mazon
2017-03-31 13:54       ` [dpdk-dev] [PATCH v3 2/3] net/tap: fix null MAC address at init Pascal Mazon
2017-03-31 13:54       ` [dpdk-dev] [PATCH v3 3/3] net/tap: fix redirection rule after MAC change Pascal Mazon
2017-04-03 13:11       ` [dpdk-dev] [PATCH v3 0/3] net/tap: netlink and MAC address fixes Ferruh Yigit
2017-03-31 13:02   ` Pascal Mazon [this message]

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=88a052bf2c94fd2fa4fe84d660099de5ce0e48dd.1490965230.git.pascal.mazon@6wind.com \
    --to=pascal.mazon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=keith.wiles@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).