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 2/2] net/tap: update redirection rule after MAC change
Date: Wed, 29 Mar 2017 11:44:09 +0200	[thread overview]
Message-ID: <eb463571ff1a69117cb4c71478cf41d7cc311010.1490780602.git.pascal.mazon@6wind.com> (raw)
In-Reply-To: <690bb6c2b6e60a10dbd963199cf9368e57ae5f2d.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 make the change only if the requested MAC address is different from
the current 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 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 6567bba75b47..069200199573 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -772,6 +772,8 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 	struct pmd_internals *pmd = dev->data->dev_private;
 	struct ifreq ifr;
 
+	if (is_same_ether_addr(mac_addr, &pmd->eth_addr))
+		return;
 	if (is_zero_ether_addr(mac_addr)) {
 		RTE_LOG(ERR, PMD, "%s: can't set an empty MAC address\n",
 			dev->data->name);
@@ -783,6 +785,19 @@ tap_mac_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr)
 	if (tap_ioctl(pmd, SIOCSIFHWADDR, &ifr, 1) < 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",
+				pmd->remote_iface);
+			return;
+		}
+		if (tap_flow_implicit_create(pmd, TAP_REMOTE_LOCAL_MAC) < 0)
+			RTE_LOG(ERR, PMD,
+				"%s: Couldn't add MAC redirection rule\n",
+				pmd->remote_iface);
+	}
 }
 
 static int
-- 
2.12.0.306.g4a9b9b3

  reply	other threads:[~2017-03-29  9:45 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 ` Pascal Mazon [this message]
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   ` [dpdk-dev] [PATCH v2 2/2] net/tap: fix redirection rule after MAC change Pascal Mazon

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=eb463571ff1a69117cb4c71478cf41d7cc311010.1490780602.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).