[Intel-wired-lan] [intel-next PATCH 14/14] ice: call ice_is_malicious_vf() from ice_vc_process_vf_msg()
Szlosek, Marek
marek.szlosek at intel.com
Fri Mar 10 13:19:39 UTC 2023
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces at osuosl.org> On Behalf Of
> Jacob Keller
> Sent: środa, 22 lutego 2023 18:09
> To: Intel Wired LAN <intel-wired-lan at lists.osuosl.org>
> Cc: Nguyen, Anthony L <anthony.l.nguyen at intel.com>; Brandeburg, Jesse
> <jesse.brandeburg at intel.com>
> Subject: [Intel-wired-lan] [intel-next PATCH 14/14] ice: call
> ice_is_malicious_vf() from ice_vc_process_vf_msg()
>
> The main loop in __ice_clean_ctrlq first checks if a VF might be malicious
> before calling ice_vc_process_vf_msg(). This results in duplicate code in both
> functions to obtain a reference to the VF, and exports the
> ice_is_malicious_vf() from ice_virtchnl.c unnecessarily.
>
> Refactor ice_is_malicious_vf() to be a static function that takes a pointer to
> the VF. Call this in ice_vc_process_vf_msg() just after we obtain a reference
> to the VF by calling ice_get_vf_by_id.
>
> Pass the mailbox data from the __ice_clean_ctrlq function into
> ice_vc_process_vf_msg() instead of calling ice_is_malicious_vf().
>
> This reduces the number of exported functions and avoids the need to
> obtain the VF reference twice for every mailbox message.
>
> Note that the state check for ICE_VF_STATE_DIS is kept in
> ice_is_malicious_vf() and we call this before checking that state in
> ice_vc_process_vf_msg. This is intentional, as we stop responding to VF
> messages from a VF once we detect that it may be overflowing the mailbox.
> This ensures that we continue to silently ignore the message as before
> without responding via ice_vc_send_msg_to_vf().
>
> Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski at linux.intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 3 +-
> drivers/net/ethernet/intel/ice/ice_virtchnl.c | 36 ++++++++++---------
> drivers/net/ethernet/intel/ice/ice_virtchnl.h | 17 +++------
> 3 files changed, 24 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c
> b/drivers/net/ethernet/intel/ice/ice_main.c
> index a7e7a186009e..20b3f3e6eda1 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
Tested-by: Marek Szlosek <marek.szlosek at intel.com>
More information about the Intel-wired-lan
mailing list