Skip to content

Commit

Permalink
ecache:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yh793 committed Dec 3, 2020
1 parent 1b26412 commit 27722bc
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions trunk/linux-3.4.x/include/net/netfilter/nf_conntrack_ecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,33 +96,57 @@ 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,
u32 pid,
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 = {
Expand All @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 27722bc

Please sign in to comment.