Skip to content

Commit 01cbf50

Browse files
mpalczew96anguy11
authored andcommitted
i40e: Fix to not show opcode msg on unsuccessful VF MAC change
Hide i40e opcode information sent during response to VF in case when untrusted VF tried to change MAC on the VF interface. This is implemented by adding an additional parameter 'hide' to the response sent to VF function that hides the display of error information, but forwards the error code to VF. Previously it was not possible to send response with some error code to VF without displaying opcode information. Fixes: 5c3c48a ("i40e: implement virtual device interface") Signed-off-by: Grzegorz Szczurek <[email protected]> Signed-off-by: Mateusz Palczewski <[email protected]> Reviewed-by: Paul M Stillwell Jr <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 6f89ecf commit 01cbf50

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

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

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,17 +1877,19 @@ int i40e_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
18771877
/***********************virtual channel routines******************/
18781878

18791879
/**
1880-
* i40e_vc_send_msg_to_vf
1880+
* i40e_vc_send_msg_to_vf_ex
18811881
* @vf: pointer to the VF info
18821882
* @v_opcode: virtual channel opcode
18831883
* @v_retval: virtual channel return value
18841884
* @msg: pointer to the msg buffer
18851885
* @msglen: msg length
1886+
* @is_quiet: true for not printing unsuccessful return values, false otherwise
18861887
*
18871888
* send msg to VF
18881889
**/
1889-
static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
1890-
u32 v_retval, u8 *msg, u16 msglen)
1890+
static int i40e_vc_send_msg_to_vf_ex(struct i40e_vf *vf, u32 v_opcode,
1891+
u32 v_retval, u8 *msg, u16 msglen,
1892+
bool is_quiet)
18911893
{
18921894
struct i40e_pf *pf;
18931895
struct i40e_hw *hw;
@@ -1903,7 +1905,7 @@ static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
19031905
abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;
19041906

19051907
/* single place to detect unsuccessful return values */
1906-
if (v_retval) {
1908+
if (v_retval && !is_quiet) {
19071909
vf->num_invalid_msgs++;
19081910
dev_info(&pf->pdev->dev, "VF %d failed opcode %d, retval: %d\n",
19091911
vf->vf_id, v_opcode, v_retval);
@@ -1933,6 +1935,23 @@ static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
19331935
return 0;
19341936
}
19351937

1938+
/**
1939+
* i40e_vc_send_msg_to_vf
1940+
* @vf: pointer to the VF info
1941+
* @v_opcode: virtual channel opcode
1942+
* @v_retval: virtual channel return value
1943+
* @msg: pointer to the msg buffer
1944+
* @msglen: msg length
1945+
*
1946+
* send msg to VF
1947+
**/
1948+
static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,
1949+
u32 v_retval, u8 *msg, u16 msglen)
1950+
{
1951+
return i40e_vc_send_msg_to_vf_ex(vf, v_opcode, v_retval,
1952+
msg, msglen, false);
1953+
}
1954+
19361955
/**
19371956
* i40e_vc_send_resp_to_vf
19381957
* @vf: pointer to the VF info
@@ -2695,6 +2714,7 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
26952714
* i40e_check_vf_permission
26962715
* @vf: pointer to the VF info
26972716
* @al: MAC address list from virtchnl
2717+
* @is_quiet: set true for printing msg without opcode info, false otherwise
26982718
*
26992719
* Check that the given list of MAC addresses is allowed. Will return -EPERM
27002720
* if any address in the list is not valid. Checks the following conditions:
@@ -2709,13 +2729,15 @@ static int i40e_vc_get_stats_msg(struct i40e_vf *vf, u8 *msg)
27092729
* addresses might not be accurate.
27102730
**/
27112731
static inline int i40e_check_vf_permission(struct i40e_vf *vf,
2712-
struct virtchnl_ether_addr_list *al)
2732+
struct virtchnl_ether_addr_list *al,
2733+
bool *is_quiet)
27132734
{
27142735
struct i40e_pf *pf = vf->pf;
27152736
struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx];
27162737
int mac2add_cnt = 0;
27172738
int i;
27182739

2740+
*is_quiet = false;
27192741
for (i = 0; i < al->num_elements; i++) {
27202742
struct i40e_mac_filter *f;
27212743
u8 *addr = al->list[i].addr;
@@ -2739,6 +2761,7 @@ static inline int i40e_check_vf_permission(struct i40e_vf *vf,
27392761
!ether_addr_equal(addr, vf->default_lan_addr.addr)) {
27402762
dev_err(&pf->pdev->dev,
27412763
"VF attempting to override administratively set MAC address, bring down and up the VF interface to resume normal operation\n");
2764+
*is_quiet = true;
27422765
return -EPERM;
27432766
}
27442767

@@ -2775,6 +2798,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27752798
(struct virtchnl_ether_addr_list *)msg;
27762799
struct i40e_pf *pf = vf->pf;
27772800
struct i40e_vsi *vsi = NULL;
2801+
bool is_quiet = false;
27782802
i40e_status ret = 0;
27792803
int i;
27802804

@@ -2791,7 +2815,7 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
27912815
*/
27922816
spin_lock_bh(&vsi->mac_filter_hash_lock);
27932817

2794-
ret = i40e_check_vf_permission(vf, al);
2818+
ret = i40e_check_vf_permission(vf, al, &is_quiet);
27952819
if (ret) {
27962820
spin_unlock_bh(&vsi->mac_filter_hash_lock);
27972821
goto error_param;
@@ -2829,8 +2853,8 @@ static int i40e_vc_add_mac_addr_msg(struct i40e_vf *vf, u8 *msg)
28292853

28302854
error_param:
28312855
/* send the response to the VF */
2832-
return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_ETH_ADDR,
2833-
ret);
2856+
return i40e_vc_send_msg_to_vf_ex(vf, VIRTCHNL_OP_ADD_ETH_ADDR,
2857+
ret, NULL, 0, is_quiet);
28342858
}
28352859

28362860
/**

0 commit comments

Comments
 (0)