Skip to content

Commit e809085

Browse files
aloktiwaanguy11
authored andcommitted
i40e: fix src IP mask checks and memcpy argument names in cloud filter
Fix following issues in the IPv4 and IPv6 cloud filter handling logic in both the add and delete paths: - The source-IP mask check incorrectly compares mask.src_ip[0] against tcf.dst_ip[0]. Update it to compare against tcf.src_ip[0]. This likely goes unnoticed because the check is in an "else if" path that only executes when dst_ip is not set, most cloud filter use cases focus on destination-IP matching, and the buggy condition can accidentally evaluate true in some cases. - memcpy() for the IPv4 source address incorrectly uses ARRAY_SIZE(tcf.dst_ip) instead of ARRAY_SIZE(tcf.src_ip), although both arrays are the same size. - The IPv4 memcpy operations used ARRAY_SIZE(tcf.dst_ip) and ARRAY_SIZE (tcf.src_ip), Update these to use sizeof(cfilter->ip.v4.dst_ip) and sizeof(cfilter->ip.v4.src_ip) to ensure correct and explicit copy size. - In the IPv6 delete path, memcmp() uses sizeof(src_ip6) when comparing dst_ip6 fields. Replace this with sizeof(dst_ip6) to make the intent explicit, even though both fields are struct in6_addr. Fixes: e284fc2 ("i40e: Add and delete cloud filter") Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent fdadbf6 commit e809085

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,10 +3833,10 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
38333833
cfilter.n_proto = ETH_P_IP;
38343834
if (mask.dst_ip[0] & tcf.dst_ip[0])
38353835
memcpy(&cfilter.ip.v4.dst_ip, tcf.dst_ip,
3836-
ARRAY_SIZE(tcf.dst_ip));
3837-
else if (mask.src_ip[0] & tcf.dst_ip[0])
3836+
sizeof(cfilter.ip.v4.dst_ip));
3837+
else if (mask.src_ip[0] & tcf.src_ip[0])
38383838
memcpy(&cfilter.ip.v4.src_ip, tcf.src_ip,
3839-
ARRAY_SIZE(tcf.dst_ip));
3839+
sizeof(cfilter.ip.v4.src_ip));
38403840
break;
38413841
case VIRTCHNL_TCP_V6_FLOW:
38423842
cfilter.n_proto = ETH_P_IPV6;
@@ -3891,7 +3891,7 @@ static int i40e_vc_del_cloud_filter(struct i40e_vf *vf, u8 *msg)
38913891
/* for ipv6, mask is set for all sixteen bytes (4 words) */
38923892
if (cfilter.n_proto == ETH_P_IPV6 && mask.dst_ip[3])
38933893
if (memcmp(&cfilter.ip.v6.dst_ip6, &cf->ip.v6.dst_ip6,
3894-
sizeof(cfilter.ip.v6.src_ip6)))
3894+
sizeof(cfilter.ip.v6.dst_ip6)))
38953895
continue;
38963896
if (mask.vlan_id)
38973897
if (cfilter.vlan_id != cf->vlan_id)
@@ -3979,10 +3979,10 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg)
39793979
cfilter->n_proto = ETH_P_IP;
39803980
if (mask.dst_ip[0] & tcf.dst_ip[0])
39813981
memcpy(&cfilter->ip.v4.dst_ip, tcf.dst_ip,
3982-
ARRAY_SIZE(tcf.dst_ip));
3983-
else if (mask.src_ip[0] & tcf.dst_ip[0])
3982+
sizeof(cfilter->ip.v4.dst_ip));
3983+
else if (mask.src_ip[0] & tcf.src_ip[0])
39843984
memcpy(&cfilter->ip.v4.src_ip, tcf.src_ip,
3985-
ARRAY_SIZE(tcf.dst_ip));
3985+
sizeof(cfilter->ip.v4.src_ip));
39863986
break;
39873987
case VIRTCHNL_TCP_V6_FLOW:
39883988
cfilter->n_proto = ETH_P_IPV6;

0 commit comments

Comments
 (0)