From 27722bc9aa3ff5b42d2603fdd1b5f8b6ccac8967 Mon Sep 17 00:00:00 2001 From: Yh793 Date: Fri, 4 Dec 2020 00:07:45 +0800 Subject: [PATCH] ecache:fix --- .../net/netfilter/nf_conntrack_ecache.h | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/trunk/linux-3.4.x/include/net/netfilter/nf_conntrack_ecache.h b/trunk/linux-3.4.x/include/net/netfilter/nf_conntrack_ecache.h index a697f90cb80..eb0fe31bf44 100644 --- a/trunk/linux-3.4.x/include/net/netfilter/nf_conntrack_ecache.h +++ b/trunk/linux-3.4.x/include/net/netfilter/nf_conntrack_ecache.h @@ -96,6 +96,7 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) set_bit(event, &e->cache); } +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS static inline int nf_conntrack_eventmask_report(unsigned int eventmask, struct nf_conn *ct, @@ -103,26 +104,49 @@ nf_conntrack_eventmask_report(unsigned int eventmask, int report) { struct nf_conntrack_ecache *e; -#ifndef CONFIG_NF_CONNTRACK_CHAIN_EVENTS + struct net *net = nf_ct_net(ct); + + e = nf_ct_ecache_find(ct); + if (e == NULL) + return 0; + + if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { + struct nf_ct_event item = { + .ct = ct, + .pid = e->pid ? e->pid : pid, + .report = report + }; + /* This is a resent of a destroy event? If so, skip missed */ + unsigned long missed = e->pid ? 0 : e->missed; + + if (!((eventmask | missed) & e->ctmask)) + return 0; + + atomic_notifier_call_chain(&net->ct.nf_conntrack_chain, eventmask | missed, &item); + } + + return 0; +} +#else +static inline int +nf_conntrack_eventmask_report(unsigned int eventmask, + struct nf_conn *ct, + u32 pid, + int report) +{ int ret = 0; struct net *net = nf_ct_net(ct); struct nf_ct_event_notifier *notify; + struct nf_conntrack_ecache *e; rcu_read_lock(); notify = rcu_dereference(net->ct.nf_conntrack_event_cb); if (notify == NULL) goto out_unlock; -#else - struct net *net = nf_ct_net(ct); -#endif e = nf_ct_ecache_find(ct); if (e == NULL) -#ifndef CONFIG_NF_CONNTRACK_CHAIN_EVENTS goto out_unlock; -#else - return 0; -#endif if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { struct nf_ct_event item = { @@ -134,7 +158,6 @@ nf_conntrack_eventmask_report(unsigned int eventmask, unsigned long missed = e->pid ? 0 : e->missed; if (!((eventmask | missed) & e->ctmask)) -#ifndef CONFIG_NF_CONNTRACK_CHAIN_EVENTS goto out_unlock; ret = notify->fcn(eventmask | missed, &item); @@ -157,13 +180,8 @@ nf_conntrack_eventmask_report(unsigned int eventmask, out_unlock: rcu_read_unlock(); return ret; -#else - return 0; - atomic_notifier_call_chain(&net->ct.nf_conntrack_chain, eventmask | missed, &item); - } - return 0; -#endif } +#endif static inline int nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct,