From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id DE5D3D1F8 for ; Wed, 29 Mar 2017 11:45:12 +0200 (CEST) Received: from 6wind.com (unknown [10.16.0.184]) by proxy.6wind.com (Postfix) with SMTP id CBD1125D63; Wed, 29 Mar 2017 11:45:06 +0200 (CEST) Received: by 6wind.com (sSMTP sendmail emulation); Wed, 29 Mar 2017 11:44:15 +0200 From: Pascal Mazon To: keith.wiles@intel.com Cc: dev@dpdk.org, Pascal Mazon Date: Wed, 29 Mar 2017 11:44:09 +0200 Message-Id: X-Mailer: git-send-email 2.12.0.306.g4a9b9b3 In-Reply-To: <690bb6c2b6e60a10dbd963199cf9368e57ae5f2d.1490780602.git.pascal.mazon@6wind.com> References: <690bb6c2b6e60a10dbd963199cf9368e57ae5f2d.1490780602.git.pascal.mazon@6wind.com> Subject: [dpdk-dev] [PATCH 2/2] net/tap: update redirection rule after MAC change X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Mar 2017 09:45:13 -0000 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 --- 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