lkml.org 
[lkml]   [2021]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.12 480/700] i40e: Fix missing rtnl locking when setting up pf switch
    Date
    From: Jan Sokolowski <jan.sokolowski@intel.com>

    [ Upstream commit 956e759d5f8e0859e86b951a8779c60af633aafd ]

    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: 40a98cb6f01f ("i40e: convert to new udp_tunnel infrastructure")
    Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
    Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
    Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/intel/i40e/i40e_main.c | 15 +++++++++++----
    1 file changed, 11 insertions(+), 4 deletions(-)

    diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
    index 2dbc03cd1769..d5106a6afb45 100644
    --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
    +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
    @@ -31,7 +31,7 @@ static void i40e_vsi_reinit_locked(struct i40e_vsi *vsi);
    static void i40e_handle_reset_warning(struct i40e_pf *pf, bool lock_acquired);
    static int i40e_add_vsi(struct i40e_vsi *vsi);
    static int i40e_add_veb(struct i40e_veb *veb, struct i40e_vsi *vsi);
    -static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit);
    +static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired);
    static int i40e_setup_misc_vector(struct i40e_pf *pf);
    static void i40e_determine_queue_usage(struct i40e_pf *pf);
    static int i40e_setup_pf_filter_control(struct i40e_pf *pf);
    @@ -10570,7 +10570,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
    #endif /* CONFIG_I40E_DCB */
    if (!lock_acquired)
    rtnl_lock();
    - ret = i40e_setup_pf_switch(pf, reinit);
    + ret = i40e_setup_pf_switch(pf, reinit, true);
    if (ret)
    goto end_unlock;

    @@ -14623,10 +14623,11 @@ int i40e_fetch_switch_configuration(struct i40e_pf *pf, bool printconfig)
    * i40e_setup_pf_switch - Setup the HW switch on startup or after reset
    * @pf: board private structure
    * @reinit: if the Main VSI needs to re-initialized.
    + * @lock_acquired: indicates whether or not the lock has been acquired
    *
    * Returns 0 on success, negative value on failure
    **/
    -static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
    +static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit, bool lock_acquired)
    {
    u16 flags = 0;
    int ret;
    @@ -14728,9 +14729,15 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)

    i40e_ptp_init(pf);

    + if (!lock_acquired)
    + rtnl_lock();
    +
    /* repopulate tunnel port filters */
    udp_tunnel_nic_reset_ntf(pf->vsi[pf->lan_vsi]->netdev);

    + if (!lock_acquired)
    + rtnl_unlock();
    +
    return ret;
    }

    @@ -15511,7 +15518,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
    pf->flags |= I40E_FLAG_VEB_MODE_ENABLED;
    }
    #endif
    - err = i40e_setup_pf_switch(pf, false);
    + err = i40e_setup_pf_switch(pf, false, false);
    if (err) {
    dev_info(&pdev->dev, "setup_pf_switch failed: %d\n", err);
    goto err_vsis;
    --
    2.30.2


    \
     
     \ /
      Last update: 2021-07-12 09:55    [W:2.661 / U:0.100 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site