ixgbevf: use ether_addr_copy instead of memcpy
Subsystems (2)
PATCH 1/2 ixgbevf: use ether_addr_copy instead of memcpy
replace some instances of memcpy for setting up the mac address with ether_addr_copy()
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +6 -8
@@ -2260,10 +2260,8 @@ void ixgbevf_reset(struct ixgbevf_adapter *adapter) }if (is_valid_ether_addr (adapter->hw.mac.addr)) { -memcpy (netdev->dev_addr, adapter->hw.mac.addr, - netdev->addr_len); -memcpy (netdev->perm_addr, adapter->hw.mac.addr, - netdev->addr_len); +ether_addr_copy (netdev->dev_addr, adapter->hw.mac.addr); +ether_addr_copy (netdev->perm_addr, adapter->hw.mac.addr); } adapter->last_reset = jiffies;
@@ -2662,13 +2660,13 @@ static int ixgbevf_sw_init(struct ixgbevf_adapter *adapter)else if (is_zero_ether_addr (adapter->hw.mac.addr))dev_info (&pdev->dev,"MAC address not assigned by administrator.\n" ); -memcpy (netdev->dev_addr, hw->mac.addr, netdev->addr_len); +ether_addr_copy (netdev->dev_addr, hw->mac.addr); }if (!is_valid_ether_addr (netdev->dev_addr)) {dev_info (&pdev->dev,"Assigning random MAC address\n" );eth_hw_addr_random (netdev); -memcpy (hw->mac.addr, netdev->dev_addr, netdev->addr_len); +ether_addr_copy (hw->mac.addr, netdev->dev_addr); }/* Enable dynamic interrupt throttling rates */
@@ -3698,8 +3696,8 @@ static int ixgbevf_set_mac(struct net_device *netdev, void *p)if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; -memcpy (netdev->dev_addr, addr->sa_data, netdev->addr_len); -memcpy (hw->mac.addr, addr->sa_data, netdev->addr_len); +ether_addr_copy (netdev->dev_addr, addr->sa_data); +ether_addr_copy (hw->mac.addr, addr->sa_data);spin_lock_bh (&adapter->mbx_lock);
PATCH 2/2 ixgbevf: fix spoofed packets with random MAC
If ixgbevf is loaded while the corresponding PF interface is down and the driver assigns a random MAC address, that address can be overwritten with the value of hw->mac.perm_addr, which would be 0 at that point.
To avoid this case we init hw->mac.perm_addr to the randomly generated address and do not set it unless we receive ACK from ixgbe.
--- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 1 + drivers/net/ethernet/intel/ixgbevf/vf.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +1 -0
@@ -2667,6 +2667,7 @@ static int ixgbevf_sw_init(struct ixgbevf_adapter *adapter)dev_info (&pdev->dev,"Assigning random MAC address\n" );eth_hw_addr_random (netdev);ether_addr_copy (hw->mac.addr, netdev->dev_addr); +ether_addr_copy (hw->mac.perm_addr, netdev->dev_addr); }/* Enable dynamic interrupt throttling rates */
drivers/net/ethernet/intel/ixgbevf/vf.c +3 -1
@@ -117,7 +117,9 @@ static s32 ixgbevf_reset_hw_vf(struct ixgbe_hw *hw) msgbuf[0] != (IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_NACK))return IXGBE_ERR_INVALID_MAC_ADDR ; -ether_addr_copy (hw->mac.perm_addr, addr); +if (msgbuf[0 ] == (IXGBE_VF_RESET |IXGBE_VT_MSGTYPE_ACK )) +ether_addr_copy (hw->mac.perm_addr, addr); + hw->mac.mc_filter_type = msgbuf[IXGBE_VF_MC_TYPE_WORD ];return 0 ;
Singh
PATCH 2/2 ixgbevf: fix spoofed packets with random MAC
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Emil Tantilov
Sent: Monday, October 12, 2015 10:56 AM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH 2/2] ixgbevf: fix spoofed packets with random MAC
If ixgbevf is loaded while the corresponding PF interface is down and the driver assigns a random MAC address, that address can be overwritten with the value of hw->mac.perm_addr, which would be 0 at that point.
To avoid this case we init hw->mac.perm_addr to the randomly generated address and do not set it unless we receive ACK from ixgbe.
---