Skip to content

Commit 956e759

Browse files
JanJSokolowskianguy11
authored andcommitted
i40e: Fix missing rtnl locking when setting up pf switch
A recent change that made i40e use new udp_tunnel infrastructure uses a method that expects to be called under rtnl lock. However, not all codepaths do the lock prior to calling i40e_setup_pf_switch. Fix that by adding additional rtnl locking and unlocking. Fixes: 40a98cb ("i40e: convert to new udp_tunnel infrastructure") Signed-off-by: Jan Sokolowski <[email protected]> Signed-off-by: Mateusz Palczewski <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 26b0ce8 commit 956e759

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void i40e_vsi_reinit_locked(struct i40e_vsi *vsi);
3232
static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
3333
static int i40e_add_vsi(struct i40e_vsi *vsi);
3434
static int i40e_add_veb(struct i40e_veb *veb, struct i40e_vsi *vsi);
35-
static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit);
35+
static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired);
3636
static int i40e_setup_misc_vector(struct i40e_pf *pf);
3737
static void i40e_determine_queue_usage(struct i40e_pf *pf);
3838
static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
@@ -10571,7 +10571,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
1057110571
#endif /* CONFIG_I40E_DCB */
1057210572
if (!lock_acquired)
1057310573
rtnl_lock();
10574-
ret = i40e_setup_pf_switch(pf, reinit);
10574+
ret = i40e_setup_pf_switch(pf, reinit, true);
1057510575
if (ret)
1057610576
goto end_unlock;
1057710577

@@ -14629,10 +14629,11 @@ int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig)
1462914629
* i40e_setup_pf_switch - Setup the HW switch on startup or after reset
1463014630
* @pf: board private structure
1463114631
* @reinit: if the Main VSI needs to re-initialized.
14632+
* @lock_acquired: indicates whether or not the lock has been acquired
1463214633
*
1463314634
* Returns 0 on success, negative value on failure
1463414635
**/
14635-
static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
14636+
static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired)
1463614637
{
1463714638
u16 flags = 0;
1463814639
int ret;
@@ -14734,9 +14735,15 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
1473414735

1473514736
i40e_ptp_init(pf);
1473614737

14738+
if (!lock_acquired)
14739+
rtnl_lock();
14740+
1473714741
/* repopulate tunnel port filters */
1473814742
udp_tunnel_nic_reset_ntf(pf->vsi[pf->lan_vsi]->netdev);
1473914743

14744+
if (!lock_acquired)
14745+
rtnl_unlock();
14746+
1474014747
return ret;
1474114748
}
1474214749

@@ -15530,7 +15537,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1553015537
pf->flags |= I40E_FLAG_VEB_MODE_ENABLED;
1553115538
}
1553215539
#endif
15533-
err = i40e_setup_pf_switch(pf, false);
15540+
err = i40e_setup_pf_switch(pf, false, false);
1553415541
if (err) {
1553515542
dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err);
1553615543
goto err_vsis;

0 commit comments

Comments
 (0)