From 874883d5b5fcd0ce0a8ce926cdbbd8618b2802b0 Mon Sep 17 00:00:00 2001 From: Himanshu Agarwal Date: Mon, 1 Aug 2016 18:04:26 +0530 Subject: qcacld-2.0: Add ipv4 and ipv6 packet checks Presently in updating wma_wow_wake_up_stats, icmpv4 and icmpv6 counts are increased just by checking ICMP protocol offset byte and ICMPV6 protocol offset byte without checking for whether it is a IPV4 or IPV6 packet. So it is possible that for ICMPV6 packet, the IPV4 protol offset byte is equal to ICMP protocol or for some ICMP packet, the IPV6 protocol byte is equal to ICMPV6 protocol and thus both the icmpv4 and icmpv6 counts will get increased for that packet. Add ipv4 and ipv6 packet checks as well in addition to the present checks to avoid wrong increment in the counts. Change-Id: I2d6e5d095d2f4b2dd474b9338bfc830b04bfa533 CRs-fixed: 1048651 --- CORE/SERVICES/WMA/wma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c index c66ddff4cc1e..de672deea676 100644 --- a/CORE/SERVICES/WMA/wma.c +++ b/CORE/SERVICES/WMA/wma.c @@ -20930,9 +20930,11 @@ static void wma_wow_wake_up_stats(tp_wma_handle wma, uint8_t *data, case WOW_REASON_PATTERN_MATCH_FOUND: if (WMA_BCAST_MAC_ADDR == *data) { wma->wow_bcast_wake_up_count++; - if (WMA_ICMP_PROTOCOL == *(data + WMA_IPV4_PROTOCOL)) + if (adf_nbuf_data_is_ipv4_pkt(data) && + (WMA_ICMP_PROTOCOL == *(data + WMA_IPV4_PROTOCOL))) wma->wow_icmpv4_count++; - if ((len > WMA_ICMP_V6_TYPE_OFFSET) && + else if (adf_nbuf_data_is_ipv6_pkt(data) && + (len > WMA_ICMP_V6_TYPE_OFFSET) && (WMA_ICMP_V6_HEADER_TYPE == *(data + WMA_ICMP_V6_HEADER_OFFSET))) wma->wow_icmpv6_uc_bc_count++; @@ -20948,9 +20950,11 @@ static void wma_wow_wake_up_stats(tp_wma_handle wma, uint8_t *data, WMA_LOGA("ICMP_V6 data len %d", len); } else { wma->wow_ucast_wake_up_count++; - if (WMA_ICMP_PROTOCOL == *(data + WMA_IPV4_PROTOCOL)) + if (adf_nbuf_data_is_ipv4_pkt(data) && + (WMA_ICMP_PROTOCOL == *(data + WMA_IPV4_PROTOCOL))) wma->wow_icmpv4_count++; - if ((len > WMA_ICMP_V6_TYPE_OFFSET) && + else if (adf_nbuf_data_is_ipv6_pkt(data) && + (len > WMA_ICMP_V6_TYPE_OFFSET) && (WMA_ICMP_V6_HEADER_TYPE == *(data + WMA_ICMP_V6_HEADER_OFFSET))) wma->wow_icmpv6_uc_bc_count++; -- cgit v1.2.3