]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
netfilter: ecache: Refine the nf_ct_deliver_cached_events
authorGao Feng <fgao@ikuai8.com>
Thu, 13 Apr 2017 01:35:49 +0000 (09:35 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 15 Apr 2017 09:43:49 +0000 (11:43 +0200)
1. Remove single !events condition check to deliver the missed event
even though there is no new event happened.

Consider this case:
1) nf_ct_deliver_cached_events is invoked at the first time, the
event is failed to deliver, then the missed is set.
2) nf_ct_deliver_cached_events is invoked again, but there is no
any new event happened.
The missed event is lost really.

It would try to send the missed event again after remove this check.
And it is ok if there is no missed event because the latter check
!((events | missed) & e->ctmask) could avoid it.

2. Correct the return value check of notify->fcn.
When send the event successfully, it returns 0, not postive value.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_ecache.c

index 22fc32143e9c4ae17bc48edc68eb0decf11d931c..6161e92d29805fadd39be22389d3702d23e2e17d 100644 (file)
@@ -195,7 +195,7 @@ void nf_ct_deliver_cached_events(struct nf_conn *ct)
 
        events = xchg(&e->cache, 0);
 
-       if (!nf_ct_is_confirmed(ct) || nf_ct_is_dying(ct) || !events)
+       if (!nf_ct_is_confirmed(ct) || nf_ct_is_dying(ct))
                goto out_unlock;
 
        /* We make a copy of the missed event cache without taking
@@ -212,7 +212,7 @@ void nf_ct_deliver_cached_events(struct nf_conn *ct)
 
        ret = notify->fcn(events | missed, &item);
 
-       if (likely(ret >= 0 && !missed))
+       if (likely(ret == 0 && !missed))
                goto out_unlock;
 
        spin_lock_bh(&ct->lock);