Skip to content

Commit e75a0f6

Browse files
committed
iavf: fix err handling for MAC replace
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-284.30.1.el9_2 commit-author Przemek Kitszel <[email protected]> commit 61f723e Defer removal of current primary MAC until a replacement is successfully added. Previous implementation would left filter list with no primary MAC. This was found while reading the code. The patch takes advantage of the fact that there can only be a single primary MAC filter at any time ([1] by Piotr) Piotr has also applied some review suggestions during our internal patch submittal process. [1] https://lore.kernel.org/netdev/[email protected]/ Reviewed-by: Michal Swiatkowski <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Piotr Gardocki <[email protected]> Signed-off-by: Przemek Kitszel <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> (cherry picked from commit 61f723e) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 9d6a10f commit e75a0f6

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

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

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -992,40 +992,36 @@ int iavf_replace_primary_mac(struct iavf_adapter *adapter,
992992
const u8 *new_mac)
993993
{
994994
struct iavf_hw *hw = &adapter->hw;
995-
struct iavf_mac_filter *f;
995+
struct iavf_mac_filter *new_f;
996+
struct iavf_mac_filter *old_f;
996997

997998
spin_lock_bh(&adapter->mac_vlan_list_lock);
998999

999-
list_for_each_entry(f, &adapter->mac_filter_list, list) {
1000-
f->is_primary = false;
1000+
new_f = iavf_add_filter(adapter, new_mac);
1001+
if (!new_f) {
1002+
spin_unlock_bh(&adapter->mac_vlan_list_lock);
1003+
return -ENOMEM;
10011004
}
10021005

1003-
f = iavf_find_filter(adapter, hw->mac.addr);
1004-
if (f) {
1005-
f->remove = true;
1006+
old_f = iavf_find_filter(adapter, hw->mac.addr);
1007+
if (old_f) {
1008+
old_f->is_primary = false;
1009+
old_f->remove = true;
10061010
adapter->aq_required |= IAVF_FLAG_AQ_DEL_MAC_FILTER;
10071011
}
1008-
1009-
f = iavf_add_filter(adapter, new_mac);
1010-
1011-
if (f) {
1012-
/* Always send the request to add if changing primary MAC
1013-
* even if filter is already present on the list
1014-
*/
1015-
f->is_primary = true;
1016-
f->add = true;
1017-
adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;
1018-
ether_addr_copy(hw->mac.addr, new_mac);
1019-
}
1012+
/* Always send the request to add if changing primary MAC,
1013+
* even if filter is already present on the list
1014+
*/
1015+
new_f->is_primary = true;
1016+
new_f->add = true;
1017+
adapter->aq_required |= IAVF_FLAG_AQ_ADD_MAC_FILTER;
1018+
ether_addr_copy(hw->mac.addr, new_mac);
10201019

10211020
spin_unlock_bh(&adapter->mac_vlan_list_lock);
10221021

10231022
/* schedule the watchdog task to immediately process the request */
1024-
if (f) {
1025-
mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
1026-
return 0;
1027-
}
1028-
return -ENOMEM;
1023+
mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
1024+
return 0;
10291025
}
10301026

10311027
/**

0 commit comments

Comments
 (0)