Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e95d9f1 authored by Mohammed Javid's avatar Mohammed Javid Committed by Gerrit - the friendly Code Review server
Browse files

msm: net: Add support to packet threshold events.



Add support to send conntrack event when
configured packet threshold is met.

Change-Id: I11fe78a74512d901d260deead3354461fc4990ab
Acked-by: default avatarChaitanya Pratapa <cpratapa@qti.qualcomm.com>
Signed-off-by: default avatarMohammed Javid <mjavid@codeaurora.org>
parent 4fc723f7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -297,6 +297,9 @@ extern struct hlist_nulls_head *nf_conntrack_hash;
extern unsigned int nf_conntrack_htable_size;
extern seqcount_t nf_conntrack_generation;
extern unsigned int nf_conntrack_max;
#ifdef CONFIG_ENABLE_SFE
extern unsigned int nf_conntrack_pkt_threshold;
#endif

/* must be called with rcu read lock held */
static inline void
+3 −0
Original line number Diff line number Diff line
@@ -131,10 +131,13 @@ enum ip_conntrack_events {
	IPCT_LABEL,		/* new connlabel has been set */
	IPCT_SYNPROXY,		/* synproxy has been set */
#ifdef __KERNEL__
	IPCT_COUNTER,		/* Packet counters have matched. */
	__IPCT_MAX
#endif
};

#define IPCT_COUNTER IPCT_COUNTER

enum ip_conntrack_expect_events {
	IPEXP_NEW,		/* new expectation */
	IPEXP_DESTROY,		/* destroyed expectation */
+36 −0
Original line number Diff line number Diff line
@@ -185,6 +185,12 @@ EXPORT_SYMBOL_GPL(nf_conntrack_htable_size);
unsigned int nf_conntrack_max __read_mostly;
EXPORT_SYMBOL_GPL(nf_conntrack_max);
seqcount_t nf_conntrack_generation __read_mostly;

#ifdef CONFIG_ENABLE_SFE
unsigned int nf_conntrack_pkt_threshold __read_mostly;
EXPORT_SYMBOL(nf_conntrack_pkt_threshold);
#endif

static unsigned int nf_conntrack_hash_rnd __read_mostly;

static u32 hash_conntrack_raw(const struct nf_conntrack_tuple *tuple,
@@ -1797,12 +1803,18 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
			  u32 extra_jiffies,
			  bool do_acct)
{

#if defined(CONFIG_IP_NF_TARGET_NATTYPE_MODULE)
	bool (*nattype_ref_timer)
		(unsigned long nattype,
		unsigned long timeout_value);
#endif

#ifdef CONFIG_ENABLE_SFE
	struct nf_conn_acct *acct;
	u64 pkts;
#endif

	/* Only update if this is not a fixed timeout */
	if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status))
		goto acct;
@@ -1822,8 +1834,32 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
#endif

acct:
#ifdef CONFIG_ENABLE_SFE
	if (do_acct) {
		acct = nf_conn_acct_find(ct);
		if (acct) {
			struct nf_conn_counter *counter = acct->counter;

			atomic64_inc(&counter[CTINFO2DIR(ctinfo)].packets);
			atomic64_add(skb->len, &counter
					[CTINFO2DIR(ctinfo)].bytes);

			pkts =
			atomic64_read(&counter[CTINFO2DIR(ctinfo)].packets) +
			atomic64_read(&counter[!CTINFO2DIR(ctinfo)].packets);
			/* Report if the packet threshold is reached. */
			if (nf_conntrack_pkt_threshold > 0 &&
			    pkts == nf_conntrack_pkt_threshold) {
				nf_conntrack_event_cache(IPCT_COUNTER, ct);
				nf_conntrack_event_cache(IPCT_PROTOINFO, ct);
				nf_ct_deliver_cached_events(ct);
			}
		}
	}
#else
	if (do_acct)
		nf_ct_acct_update(ct, ctinfo, skb->len);
#endif
}
EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);

+5 −0
Original line number Diff line number Diff line
@@ -788,6 +788,11 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item)

		if (events & (1 << IPCT_SYNPROXY) &&
		    ctnetlink_dump_ct_synproxy(skb, ct) < 0)

#ifdef CONFIG_ENABLE_SFE
		if (events & (1 << IPCT_COUNTER) &&
		    ctnetlink_dump_acct(skb, ct, 0) < 0)
#endif
			goto nla_put_failure;
	}

+13 −0
Original line number Diff line number Diff line
@@ -544,6 +544,9 @@ enum nf_ct_sysctl_index {
	NF_SYSCTL_CT_EXPECT_MAX,
	NF_SYSCTL_CT_ACCT,
	NF_SYSCTL_CT_HELPER,
#ifdef CONFIG_ENABLE_SFE
	NF_SYSCTL_CT_PKT_THRESHOLD,
#endif
#ifdef CONFIG_NF_CONNTRACK_EVENTS
	NF_SYSCTL_CT_EVENTS,
#endif
@@ -664,6 +667,16 @@ static struct ctl_table nf_ct_sysctl_table[] = {
		.extra1 	= SYSCTL_ZERO,
		.extra2 	= SYSCTL_ONE,
	},
#ifdef CONFIG_ENABLE_SFE
	[NF_SYSCTL_CT_PKT_THRESHOLD] = {
		.procname	= "nf_conntrack_pkt_threshold",
		.data		= &nf_conntrack_pkt_threshold,
		.maxlen		= sizeof(int),
		.mode		= 0644,
		.proc_handler	= proc_dointvec,
	},
#endif

#ifdef CONFIG_NF_CONNTRACK_EVENTS
	[NF_SYSCTL_CT_EVENTS] = {
		.procname	= "nf_conntrack_events",