[NETFILTER]: {nf_netlink,ip,ip6}_queue: use list_for_each_entry
authorPatrick McHardy <kaber@trash.net>
Wed, 5 Dec 2007 09:25:03 +0000 (01:25 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:56:11 +0000 (14:56 -0800)
Use list_add_tail/list_for_each_entry instead of list_add and
list_for_each_prev as a preparation for switching to RCU.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/netfilter/ip_queue.c
net/ipv6/netfilter/ip6_queue.c
net/netfilter/nfnetlink_queue.c

index 2966fbddce8be951b59454df5c99ee256523299e..9e72246ede25b4e5be1668bfa6384b80172d93a6 100644 (file)
@@ -73,7 +73,7 @@ ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
 static inline void
 __ipq_enqueue_entry(struct ipq_queue_entry *entry)
 {
-       list_add(&entry->list, &queue_list);
+       list_add_tail(&entry->list, &queue_list);
        queue_total++;
 }
 
@@ -84,11 +84,9 @@ __ipq_enqueue_entry(struct ipq_queue_entry *entry)
 static inline struct ipq_queue_entry *
 __ipq_find_entry(ipq_cmpfn cmpfn, unsigned long data)
 {
-       struct list_head *p;
-
-       list_for_each_prev(p, &queue_list) {
-               struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p;
+       struct ipq_queue_entry *entry;
 
+       list_for_each_entry(entry, &queue_list, list) {
                if (!cmpfn || cmpfn(entry, data))
                        return entry;
        }
index 7ff9915750a3265d56b5df4bdfe5a75801acc8f1..243a00bcd3df7866f3587cd1df9ffa93ec8e3041 100644 (file)
@@ -71,7 +71,7 @@ ipq_issue_verdict(struct ipq_queue_entry *entry, int verdict)
 static inline void
 __ipq_enqueue_entry(struct ipq_queue_entry *entry)
 {
-       list_add(&entry->list, &queue_list);
+       list_add_tail(&entry->list, &queue_list);
        queue_total++;
 }
 
@@ -82,11 +82,9 @@ __ipq_enqueue_entry(struct ipq_queue_entry *entry)
 static inline struct ipq_queue_entry *
 __ipq_find_entry(ipq_cmpfn cmpfn, unsigned long data)
 {
-       struct list_head *p;
-
-       list_for_each_prev(p, &queue_list) {
-               struct ipq_queue_entry *entry = (struct ipq_queue_entry *)p;
+       struct ipq_queue_entry *entry;
 
+       list_for_each_entry(entry, &queue_list, list) {
                if (!cmpfn || cmpfn(entry, data))
                        return entry;
        }
index 3a09f021065ad7ff38301f00acac767f9c6a728e..74d5ed9490a9814bd8b14ebcb391361e2c822ef0 100644 (file)
@@ -231,7 +231,7 @@ static inline void
 __enqueue_entry(struct nfqnl_instance *queue,
                      struct nfqnl_queue_entry *entry)
 {
-       list_add(&entry->list, &queue->queue_list);
+       list_add_tail(&entry->list, &queue->queue_list);
        queue->queue_total++;
 }
 
@@ -243,11 +243,9 @@ static inline struct nfqnl_queue_entry *
 __find_entry(struct nfqnl_instance *queue, nfqnl_cmpfn cmpfn,
                   unsigned long data)
 {
-       struct list_head *p;
-
-       list_for_each_prev(p, &queue->queue_list) {
-               struct nfqnl_queue_entry *entry = (struct nfqnl_queue_entry *)p;
+       struct nfqnl_queue_entry *entry;
 
+       list_for_each_entry(entry, &queue->queue_list, list) {
                if (!cmpfn || cmpfn(entry, data))
                        return entry;
        }