Skip to content

Commit c5c922b

Browse files
sassmannJeff Kirsher
authored andcommitted
iavf: fix MAC address setting for VFs when filter is rejected
Currently iavf unconditionally applies MAC address change requests. This brings the VF in a state where it is no longer able to pass traffic if the PF rejects a MAC filter change for the VF. A typical scenario for a rejected MAC filter is for an untrusted VF to request to change the MAC address when an administratively set MAC is present. To keep iavf working in this scenario the MAC filter handling in iavf needs to act on the PF reply regarding the MAC filter change. In the case of an ack the new MAC address gets set, whereas in the case of a nack the previous MAC address needs to stay in place. Signed-off-by: Stefan Assmann <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 8ad2e29 commit c5c922b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ static int iavf_set_mac(struct net_device *netdev, void *p)
804804

805805
if (f) {
806806
ether_addr_copy(hw->mac.addr, addr->sa_data);
807-
ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
808807
}
809808

810809
return (f == NULL) ? -ENOMEM : 0;

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,8 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
12521252
case VIRTCHNL_OP_ADD_ETH_ADDR:
12531253
dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
12541254
iavf_stat_str(&adapter->hw, v_retval));
1255+
/* restore administratively set MAC address */
1256+
ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
12551257
break;
12561258
case VIRTCHNL_OP_DEL_VLAN:
12571259
dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
@@ -1319,6 +1321,11 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
13191321
}
13201322
}
13211323
switch (v_opcode) {
1324+
case VIRTCHNL_OP_ADD_ETH_ADDR: {
1325+
if (!ether_addr_equal(netdev->dev_addr, adapter->hw.mac.addr))
1326+
ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
1327+
}
1328+
break;
13221329
case VIRTCHNL_OP_GET_STATS: {
13231330
struct iavf_eth_stats *stats =
13241331
(struct iavf_eth_stats *)msg;

0 commit comments

Comments
 (0)