Skip to content

Commit 81ffe20

Browse files
ksornekgregkh
authored andcommitted
igb: Fix removal of unicast MAC filters of VFs
[ Upstream commit 584af82 ] Move checking condition of VF MAC filter before clearing or adding MAC filter to VF to prevent potential blackout caused by removal of necessary and working VF's MAC filter. Fixes: 1b8b062 ("igb: add VF trust infrastructure") Signed-off-by: Karen Sornek <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 12dc89c commit 81ffe20

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7641,6 +7641,20 @@ static int igb_set_vf_mac_filter(struct igb_adapter *adapter, const int vf,
76417641
struct vf_mac_filter *entry = NULL;
76427642
int ret = 0;
76437643

7644+
if ((vf_data->flags & IGB_VF_FLAG_PF_SET_MAC) &&
7645+
!vf_data->trusted) {
7646+
dev_warn(&pdev->dev,
7647+
"VF %d requested MAC filter but is administratively denied\n",
7648+
vf);
7649+
return -EINVAL;
7650+
}
7651+
if (!is_valid_ether_addr(addr)) {
7652+
dev_warn(&pdev->dev,
7653+
"VF %d attempted to set invalid MAC filter\n",
7654+
vf);
7655+
return -EINVAL;
7656+
}
7657+
76447658
switch (info) {
76457659
case E1000_VF_MAC_FILTER_CLR:
76467660
/* remove all unicast MAC filters related to the current VF */
@@ -7654,20 +7668,6 @@ static int igb_set_vf_mac_filter(struct igb_adapter *adapter, const int vf,
76547668
}
76557669
break;
76567670
case E1000_VF_MAC_FILTER_ADD:
7657-
if ((vf_data->flags & IGB_VF_FLAG_PF_SET_MAC) &&
7658-
!vf_data->trusted) {
7659-
dev_warn(&pdev->dev,
7660-
"VF %d requested MAC filter but is administratively denied\n",
7661-
vf);
7662-
return -EINVAL;
7663-
}
7664-
if (!is_valid_ether_addr(addr)) {
7665-
dev_warn(&pdev->dev,
7666-
"VF %d attempted to set invalid MAC filter\n",
7667-
vf);
7668-
return -EINVAL;
7669-
}
7670-
76717671
/* try to find empty slot in the list */
76727672
list_for_each(pos, &adapter->vf_macs.l) {
76737673
entry = list_entry(pos, struct vf_mac_filter, l);

0 commit comments

Comments
 (0)