From: Pascal Mazon Date: Fri, 12 May 2017 13:01:40 +0000 (+0200) Subject: net/tap: do not set remote MAC if not necessary X-Git-Tag: spdx-start~3168 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=460bf26fd8904f985698d0c7d01c74b4053359c9;p=dpdk.git net/tap: do not set remote MAC if not necessary 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 --- diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 26a7f84d4f..49549b4f18 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) {