From 65a49ebd1bd12b9952dfa214de0a2da43ba2abed Mon Sep 17 00:00:00 2001 From: Bhaskar Valaboju Date: Tue, 13 Aug 2019 14:21:03 +0530 Subject: [qca-nss-ecm]: Access global ipv4/ipv6 accelerated count under lock Flow accelerated count maintained as global variables are accessed in multiple kernel contexts. These counters are updated under lock, but read without lock. Read is in kernel thread context (workqueue) and sometimes it is taking stale entry (0) and doesn't change. Lock is added to read correct value. Change-Id: I74cf27fe5097c6ae7dfcc06319762a8a322d79a3 Signed-off-by: Bhaskar Valaboju --- frontends/nss/ecm_nss_ipv4.c | 3 +++ frontends/nss/ecm_nss_ipv6.c | 3 +++ 2 files changed, 6 insertions(+) (limited to 'frontends') diff --git a/frontends/nss/ecm_nss_ipv4.c b/frontends/nss/ecm_nss_ipv4.c index afd660e..4e66cdf 100644 --- a/frontends/nss/ecm_nss_ipv4.c +++ b/frontends/nss/ecm_nss_ipv4.c @@ -2288,10 +2288,13 @@ static void ecm_nss_ipv4_stats_sync_req_work(struct work_struct *work) int retry = 3; unsigned long int current_jiffies; + spin_lock_bh(&ecm_nss_ipv4_lock); if (ecm_nss_ipv4_accelerated_count == 0) { + spin_unlock_bh(&ecm_nss_ipv4_lock); DEBUG_TRACE("There is no accelerated IPv4 connection\n"); goto reschedule; } + spin_unlock_bh(&ecm_nss_ipv4_lock); usleep_range(ECM_NSS_IPV4_STATS_SYNC_UDELAY - 100, ECM_NSS_IPV4_STATS_SYNC_UDELAY); diff --git a/frontends/nss/ecm_nss_ipv6.c b/frontends/nss/ecm_nss_ipv6.c index 1f7f51e..55849e7 100644 --- a/frontends/nss/ecm_nss_ipv6.c +++ b/frontends/nss/ecm_nss_ipv6.c @@ -1998,10 +1998,13 @@ static void ecm_nss_ipv6_stats_sync_req_work(struct work_struct *work) int retry = 3; unsigned long int current_jiffies; + spin_lock_bh(&ecm_nss_ipv6_lock); if (ecm_nss_ipv6_accelerated_count == 0) { + spin_unlock_bh(&ecm_nss_ipv6_lock); DEBUG_TRACE("There is no accelerated IPv6 connection\n"); goto reschedule; } + spin_unlock_bh(&ecm_nss_ipv6_lock); usleep_range(ECM_NSS_IPV6_STATS_SYNC_UDELAY - 100, ECM_NSS_IPV6_STATS_SYNC_UDELAY); -- cgit v1.1