On 11/5/2025 3:47 PM, Loktionov, Aleksandr wrote:
                  break;
          case VIRTCHNL_TCP_V6_FLOW:
                  cfilter.n_proto = ETH_P_IPV6;
Good day, Alok

Good catch! This is indeed a bug - a copy-paste error introduced in the 
original implementation.

The condition should check tcf.src_ip[0] when validating source IP, not 
tcf.dst_ip[0]. You can see this is correct in the IPv6 flow handling in the 
same function:

case VIRTCHNL_TCP_V6_FLOW:    ...    if (mask.src_ip[3] & tcf.src_ip[3])  /* 
Correctly uses src_ip */        memcpy(&cfilter.ip.v6.src_ip6, tcf.src_ip,          
     sizeof(cfilter.ip.v6.src_ip6));
The IPv4 code should follow the same pattern. Additionally, using 
ARRAY_SIZE(tcf.src_ip) is more accurate than ARRAY_SIZE(tcf.dst_ip) when 
copying the source IP, even though they're likely the same size.

Your fix looks correct. The same bug also exists in i40e_vc_add_cloud_filter() 
and should be fixed there as well.

This likely went unnoticed because:
  - The else if means this path only executes when dst_ip is not set
  - Most cloud filter use cases primarily filter on destination IP
  - The buggy condition could accidentally succeed in some cases

Thank you
Alex

Thanks Alex for confirmation.

Thanks,
Alok

Reply via email to