Loading include/net/netfilter/nf_conntrack.h +1 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,7 @@ 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; extern unsigned int nf_conntrack_pkt_threshold; /* must be called with rcu read lock held */ static inline void Loading include/uapi/linux/netfilter/nf_conntrack_common.h +3 −0 Original line number Diff line number Diff line Loading @@ -113,8 +113,11 @@ enum ip_conntrack_events { IPCT_NATSEQADJ = IPCT_SEQADJ, IPCT_SECMARK, /* new security mark has been set */ IPCT_LABEL, /* new connlabel has been set */ IPCT_COUNTER, /* Packet counters have matched. */ }; #define IPCT_COUNTER IPCT_COUNTER enum ip_conntrack_expect_events { IPEXP_NEW, /* new expectation */ IPEXP_DESTROY, /* destroyed expectation */ Loading net/netfilter/nf_conntrack_core.c +27 −2 Original line number Diff line number Diff line Loading @@ -181,6 +181,9 @@ EXPORT_SYMBOL_GPL(nf_conntrack_htable_size); unsigned int nf_conntrack_max __read_mostly; seqcount_t nf_conntrack_generation __read_mostly; unsigned int nf_conntrack_pkt_threshold __read_mostly; EXPORT_SYMBOL(nf_conntrack_pkt_threshold); DEFINE_PER_CPU(struct nf_conn, nf_conntrack_untracked); EXPORT_PER_CPU_SYMBOL(nf_conntrack_untracked); Loading Loading @@ -1434,6 +1437,9 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, unsigned long extra_jiffies, int do_acct) { struct nf_conn_acct *acct; u64 pkts; NF_CT_ASSERT(skb); /* Only update if this is not a fixed timeout */ Loading @@ -1446,8 +1452,27 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, ct->timeout = extra_jiffies; acct: if (do_acct) nf_ct_acct_update(ct, ctinfo, skb->len); 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); } } } } EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct); Loading net/netfilter/nf_conntrack_netlink.c +4 −0 Original line number Diff line number Diff line Loading @@ -729,6 +729,10 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item) if (events & (1 << IPCT_SEQADJ) && ctnetlink_dump_ct_seq_adj(skb, ct) < 0) goto nla_put_failure; if (events & (1 << IPCT_COUNTER) && ctnetlink_dump_acct(skb, ct, 0) < 0) goto nla_put_failure; } #ifdef CONFIG_NF_CONNTRACK_MARK Loading net/netfilter/nf_conntrack_standalone.c +8 −0 Original line number Diff line number Diff line Loading @@ -517,6 +517,14 @@ static struct ctl_table nf_ct_sysctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "nf_conntrack_pkt_threshold", .data = &nf_conntrack_pkt_threshold, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { } }; Loading Loading
include/net/netfilter/nf_conntrack.h +1 −0 Original line number Diff line number Diff line Loading @@ -314,6 +314,7 @@ 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; extern unsigned int nf_conntrack_pkt_threshold; /* must be called with rcu read lock held */ static inline void Loading
include/uapi/linux/netfilter/nf_conntrack_common.h +3 −0 Original line number Diff line number Diff line Loading @@ -113,8 +113,11 @@ enum ip_conntrack_events { IPCT_NATSEQADJ = IPCT_SEQADJ, IPCT_SECMARK, /* new security mark has been set */ IPCT_LABEL, /* new connlabel has been set */ IPCT_COUNTER, /* Packet counters have matched. */ }; #define IPCT_COUNTER IPCT_COUNTER enum ip_conntrack_expect_events { IPEXP_NEW, /* new expectation */ IPEXP_DESTROY, /* destroyed expectation */ Loading
net/netfilter/nf_conntrack_core.c +27 −2 Original line number Diff line number Diff line Loading @@ -181,6 +181,9 @@ EXPORT_SYMBOL_GPL(nf_conntrack_htable_size); unsigned int nf_conntrack_max __read_mostly; seqcount_t nf_conntrack_generation __read_mostly; unsigned int nf_conntrack_pkt_threshold __read_mostly; EXPORT_SYMBOL(nf_conntrack_pkt_threshold); DEFINE_PER_CPU(struct nf_conn, nf_conntrack_untracked); EXPORT_PER_CPU_SYMBOL(nf_conntrack_untracked); Loading Loading @@ -1434,6 +1437,9 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, unsigned long extra_jiffies, int do_acct) { struct nf_conn_acct *acct; u64 pkts; NF_CT_ASSERT(skb); /* Only update if this is not a fixed timeout */ Loading @@ -1446,8 +1452,27 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, ct->timeout = extra_jiffies; acct: if (do_acct) nf_ct_acct_update(ct, ctinfo, skb->len); 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); } } } } EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct); Loading
net/netfilter/nf_conntrack_netlink.c +4 −0 Original line number Diff line number Diff line Loading @@ -729,6 +729,10 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item) if (events & (1 << IPCT_SEQADJ) && ctnetlink_dump_ct_seq_adj(skb, ct) < 0) goto nla_put_failure; if (events & (1 << IPCT_COUNTER) && ctnetlink_dump_acct(skb, ct, 0) < 0) goto nla_put_failure; } #ifdef CONFIG_NF_CONNTRACK_MARK Loading
net/netfilter/nf_conntrack_standalone.c +8 −0 Original line number Diff line number Diff line Loading @@ -517,6 +517,14 @@ static struct ctl_table nf_ct_sysctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, { .procname = "nf_conntrack_pkt_threshold", .data = &nf_conntrack_pkt_threshold, .maxlen = sizeof(int), .mode = 0644, .proc_handler = proc_dointvec, }, { } }; Loading