Skip to contentSkip to conversation

: Don't increase master refcount on expectations

PATCH In review Patrick McHardy 1 participant 1 message Sep 6, 2005

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

PATCH 6/8 : Don't increase master refcount on expectations

[NETFILTER]: Don't increase master refcount on expectations

As it's been discussed [1][2]. We shouldn't increase the master conntrack refcount for non-fulfilled conntracks. During the conntrack destruction, the expectations are always killed before the conntrack itself, this guarantees that there won't be any orphan expectation.

[1]https://lists.netfilter.org/pipermail/netfilter-devel/2005-August/020783.html [2]https://lists.netfilter.org/pipermail/netfilter-devel/2005-August/020904.html

---
commit 0cec535bc739cac6e928db1c5e178b6a3f72f241
tree 12979d31aecd39078a0c707cf810e15f7d87f222
parent 917240fdfb4a326d7488803be075e60e9fda6a3e
author Pablo Neira Ayuso <[email protected]> Sun, 04 Sep 2005 19:46:35 +0200 committer Patrick McHardy <[email protected]> Sun, 04 Sep 2005 19:46:35 +0200

 net/ipv4/netfilter/ip_conntrack_core.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
net/ipv4/netfilter/ip_conntrack_core.c +4 -4
@@ -938,6 +938,9 @@ void ip_conntrack_unexpect_related(struc
 	write_unlock_bh(&ip_conntrack_lock);
 }
 
+/* We don't increase the master conntrack refcount for non-fulfilled
+ * conntracks. During the conntrack destruction, the expectations are 
+ * always killed before the conntrack itself */
 struct ip_conntrack_expect *ip_conntrack_expect_alloc(struct ip_conntrack *me)
 {
 	struct ip_conntrack_expect *new;
@@ -948,17 +951,14 @@ struct ip_conntrack_expect *ip_conntrack
 		return NULL;
 	}
 	new->master = me;
-	atomic_inc(&new->master->ct_general.use);
 	atomic_set(&new->use, 1);
 	return new;
 }
 
 void ip_conntrack_expect_put(struct ip_conntrack_expect *exp)
 {
-	if (atomic_dec_and_test(&exp->use)) {
-		ip_conntrack_put(exp->master);
+	if (atomic_dec_and_test(&exp->use))
 		kmem_cache_free(ip_conntrack_expect_cachep, exp);
-	}
 }
 
 static void ip_conntrack_expect_insert(struct ip_conntrack_expect *exp)