Skip to contentSkip to conversation

netfilter: cttimeout: Refine cttimeout_del_timeout

PATCH In review [email protected] 2 participants 2 messages Apr 7, 2017 – Apr 13, 2017

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

PATCH 1/1 netfilter: cttimeout: Refine cttimeout_del_timeout

From: Gao Feng <[email protected]>

1. Return one error when try to delete all timeouts and meet one erorr;
2. Delete the condition block when fail to delete specified timeout. It is more clear that it would stop the loop when find one matched timeout.

---
 net/netfilter/nfnetlink_cttimeout.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
net/netfilter/nfnetlink_cttimeout.c +9 -6
index baa75f3..220847a 100644
@@ -361,11 +361,17 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl,
 	char *name;
 
 	if (!cda[CTA_TIMEOUT_NAME]) {
+		int cur_ret;
+
+		ret = 0;
 		list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list,
-					 head)
-			ctnl_timeout_try_del(net, cur);
+					 head) {
+			cur_ret = ctnl_timeout_try_del(net, cur);
+			if (cur_ret && !ret)
+				ret = cur_ret;
+		}
 
-		return 0;
+		return ret;
 	}
 	name = nla_data(cda[CTA_TIMEOUT_NAME]);
 
@@ -374,9 +380,6 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl,
 			continue;
 
 		ret = ctnl_timeout_try_del(net, cur);
-		if (ret < 0)
-			return ret;
-
 		break;
 	}
 	return ret;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 16 lines · On Fri, Apr 07, 2017 at 07:25:36PM +0800, [email protected] wrote:

From: Gao Feng <[email protected]>

1. Return one error when try to delete all timeouts and meet one erorr;
2. Delete the condition block when fail to delete specified timeout. It is more clear that it would stop the loop when find one matched timeout.

---
 net/netfilter/nfnetlink_cttimeout.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
net/netfilter/nfnetlink_cttimeout.c +0 -0
index baa75f3..220847a 100644

net/netfilter/nfnetlink_cttimeout.c static int cttimeout_del_timeout(struct net *net, struct sock *ctnl, · line 366

Quoted 9 lines
net/netfilter/nfnetlink_cttimeout.c +3 -2
@@ -361,11 +361,17 @@ static int cttimeout_del_timeout(struct net *net, struct sock *ctnl,
 	char *name;
 
 	if (!cda[CTA_TIMEOUT_NAME]) {
+		int cur_ret;
+
+		ret = 0;
 		list_for_each_entry_safe(cur, tmp, &net->nfct_timeout_list,
-					 head)
-			ctnl_timeout_try_del(net, cur);

This code ignores ctnl_timeout_try_del() on purpose, to implement the flush operation.