Skip to contentSkip to conversation

netfilter: ecache: Refine the nf_ct_deliver_cached_events

PATCH Applied [email protected] 2 participants 2 messages Apr 13, 2017 – Apr 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: ecache: Refine the nf_ct_deliver_cached_events

From: Gao Feng <[email protected]>

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.

---
 net/netfilter/nf_conntrack_ecache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conntrack_ecache.c +2 -2
index da9df2d..1e4e257 100644
@@ -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);
Signature · 1 line
1.9.1
maintainer Applied
#1 lore raw
Quoted 12 lines · On Thu, Apr 13, 2017 at 09:35:49AM +0800, [email protected] wrote:

From: Gao Feng <[email protected]>

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.

Quoted 6 lines

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.

Applied, thanks.