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.ma...@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