diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index f7fe020e5e2a..c09609339bd2 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -1312,27 +1312,28 @@ void i40e_del_filter(struct i40e_vsi *vsi, const u8 *macaddr, s16 vlan) * @vsi: the VSI to be searched * @macaddr: the mac address to be filtered * - * Goes through all the macvlan filters and adds a - * macvlan filter for each unique vlan that already exists + * Goes through all the macvlan filters and adds a macvlan filter for each + * unique vlan that already exists. If a PVID has been assigned, instead only + * add the macaddr to that VLAN. * - * Returns first filter found on success, else NULL + * Returns last filter added on success, else NULL **/ struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi, const u8 *macaddr) { - struct i40e_mac_filter *f; + struct i40e_mac_filter *f, *add = NULL; + + if (vsi->info.pvid) + return i40e_add_filter(vsi, macaddr, + le16_to_cpu(vsi->info.pvid)); list_for_each_entry(f, &vsi->mac_filter_list, list) { - if (vsi->info.pvid) - f->vlan = le16_to_cpu(vsi->info.pvid); - if (!i40e_find_filter(vsi, macaddr, f->vlan)) { - if (!i40e_add_filter(vsi, macaddr, f->vlan)) - return NULL; - } + add = i40e_add_filter(vsi, macaddr, f->vlan); + if (!add) + return NULL; } - return list_first_entry_or_null(&vsi->mac_filter_list, - struct i40e_mac_filter, list); + return add; } /**