Skip to contentSkip to conversation

netfilter: replace list_for_each_continue_rcu with new interface

PATCH Applied Michael Wang 3 participants 3 messages Aug 17, 2012 – Aug 22, 2012 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 3/3 netfilter: replace list_for_each_continue_rcu with new interface

From: Michael Wang <[email protected]>

This patch replaces list_for_each_continue_rcu() with list_for_each_entry_continue_rcu() to allow removing list_for_each_continue_rcu().

---
 net/netfilter/core.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
net/netfilter/core.c +7 -4
index e19f365..50225bd 100644
@@ -131,14 +131,14 @@ unsigned int nf_iterate(struct list_head *head,
 			int hook_thresh)
 {
 	unsigned int verdict;
+	struct nf_hook_ops *elem = list_entry_rcu(*i,
+						struct nf_hook_ops, list);
 
 	/*
 	 * The caller must not block between calls to this
 	 * function because of risk of continuing from deleted element.
 	 */
-	list_for_each_continue_rcu(*i, head) {
-		struct nf_hook_ops *elem = (struct nf_hook_ops *)*i;
-
+	list_for_each_entry_continue_rcu(elem, head, list) {
 		if (hook_thresh > elem->priority)
 			continue;
 
@@ -155,11 +155,14 @@ repeat:
 				continue;
 			}
 #endif
-			if (verdict != NF_REPEAT)
+			if (verdict != NF_REPEAT) {
+				*i = &elem->list;
 				return verdict;
+			}
 			goto repeat;
 		}
 	}
+	*i = &elem->list;
 	return NF_ACCEPT;
 }
 
Signature · 1 line
1.7.4.1
Reviewed-by on v1 3/3
#2 lore raw
Quoted 7 lines · Michael Wang

From: Michael Wang <[email protected]>

This patch replaces list_for_each_continue_rcu() with list_for_each_entry_continue_rcu() to allow removing list_for_each_continue_rcu().

Quoted 46 lines
---
 net/netfilter/core.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)
net/netfilter/core.c +7 -4
index e19f365..50225bd 100644
@@ -131,14 +131,14 @@ unsigned int nf_iterate(struct list_head *head,
 			int hook_thresh)
 {
 	unsigned int verdict;
+	struct nf_hook_ops *elem = list_entry_rcu(*i,
+						struct nf_hook_ops, list);
 
 	/*
 	 * The caller must not block between calls to this
 	 * function because of risk of continuing from deleted element.
 	 */
-	list_for_each_continue_rcu(*i, head) {
-		struct nf_hook_ops *elem = (struct nf_hook_ops *)*i;
-
+	list_for_each_entry_continue_rcu(elem, head, list) {
 		if (hook_thresh > elem->priority)
 			continue;
 
@@ -155,11 +155,14 @@ repeat:
 				continue;
 			}
 #endif
-			if (verdict != NF_REPEAT)
+			if (verdict != NF_REPEAT) {
+				*i = &elem->list;
 				return verdict;
+			}
 			goto repeat;
 		}
 	}
+	*i = &elem->list;
 	return NF_ACCEPT;
 }
 
Signature · 1 line
1.7.4.1