Home » Mailing lists » Devel » [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2)
[PATCH 11/15] Make some netfilter-related proc files use seq_list_xxx helpers [message #13059 is a reply to message #13048] |
Fri, 18 May 2007 09:55   |
xemul
Messages: 248 Registered: November 2005
|
Senior Member |
|
|
This includes /proc/net/ip_conntrack_expect file.
Although struct nf_conntrack_expect has list_head as
the very first element I use list_entry in .show callback
to emphasize the fact that *v is the list_head pointer.
Signed-off-by: Pavel Emelianov <xemul@openvz.org>
---
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
index 89f933e..bec843a 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -208,35 +208,15 @@ static const struct file_operations ct_f
/* expects */
static void *exp_seq_start(struct seq_file *s, loff_t *pos)
{
- struct list_head *e = &nf_conntrack_expect_list;
- loff_t i;
-
/* strange seq_file api calls stop even if we fail,
* thus we need to grab lock since stop unlocks */
read_lock_bh(&nf_conntrack_lock);
-
- if (list_empty(e))
- return NULL;
-
- for (i = 0; i <= *pos; i++) {
- e = e->next;
- if (e == &nf_conntrack_expect_list)
- return NULL;
- }
- return e;
+ return seq_list_start(&nf_conntrack_expect_list, *pos);
}
static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
{
- struct list_head *e = v;
-
- ++*pos;
- e = e->next;
-
- if (e == &nf_conntrack_expect_list)
- return NULL;
-
- return e;
+ return seq_list_next(v, &nf_conntrack_expect_list, pos);
}
static void exp_seq_stop(struct seq_file *s, void *v)
@@ -246,7 +226,8 @@ static void exp_seq_stop(struct seq_file
static int exp_seq_show(struct seq_file *s, void *v)
{
- struct nf_conntrack_expect *exp = v;
+ struct nf_conntrack_expect *exp = list_entry(v,
+ struct nf_conntrack_expect, list);
if (exp->tuple.src.l3num != AF_INET)
return 0;
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 117cbfd..7ea80e4 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -366,35 +366,15 @@ EXPORT_SYMBOL_GPL(nf_conntrack_expect_re
#ifdef CONFIG_PROC_FS
static void *exp_seq_start(struct seq_file *s, loff_t *pos)
{
- struct list_head *e = &nf_conntrack_expect_list;
- loff_t i;
-
/* strange seq_file api calls stop even if we fail,
* thus we need to grab lock since stop unlocks */
read_lock_bh(&nf_conntrack_lock);
-
- if (list_empty(e))
- return NULL;
-
- for (i = 0; i <= *pos; i++) {
- e = e->next;
- if (e == &nf_conntrack_expect_list)
- return NULL;
- }
- return e;
+ return seq_list_start(&nf_conntrack_expect_list, *pos);
}
static void *exp_seq_next(struct seq_file *s, void *v, loff_t *pos)
{
- struct list_head *e = v;
-
- ++*pos;
- e = e->next;
-
- if (e == &nf_conntrack_expect_list)
- return NULL;
-
- return e;
+ return seq_list_next(v, &nf_conntrack_expect_list, pos);
}
static void exp_seq_stop(struct seq_file *s, void *v)
@@ -404,7 +384,8 @@ static void exp_seq_stop(struct seq_file
static int exp_seq_show(struct seq_file *s, void *v)
{
- struct nf_conntrack_expect *expect = v;
+ struct nf_conntrack_expect *expect = list_entry(v,
+ struct nf_conntrack_expect, list);
if (expect->timeout.function)
seq_printf(s, "%ld ", timer_pending(&expect->timeout)
|
|
|
 |
|
[PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2)
By: xemul on Fri, 18 May 2007 09:11
|
 |
|
[PATCH 1/15] The helper functions itselves
By: xemul on Fri, 18 May 2007 09:17
|
 |
|
Re: [PATCH 1/15] The helper functions itselves
|
 |
|
[PATCH 2/15] Make AFS use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:20
|
 |
|
[PATCH 3/15] Make ATM driver use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:23
|
 |
|
[PATCH 4/15] Make block layer /proc files use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:27
|
 |
|
[PATCH 5/15] Make crypto API use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:29
|
 |
|
Re: [PATCH 5/15] Make crypto API use seq_list_xxx helpers
|
 |
|
[PATCH 6/15] Make input layer use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:33
|
 |
|
[PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:36
|
 |
|
Re: [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers
|
 |
|
[PATCH 8/15] Make /proc/misc use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:39
|
 |
|
[PATCH 9/15] Make /proc/modules use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:41
|
 |
|
[PATCH 10/15] Make some network-related proc files use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:48
|
 |
|
Re: [PATCH 10/15] Make some network-related proc files use seq_list_xxx helpers
By: davem on Fri, 18 May 2007 10:24
|
 |
|
[PATCH 11/15] Make some netfilter-related proc files use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 09:55
|
 |
|
[PATCH 12/15] Make NFS client use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:00
|
 |
|
Re: [PATCH 12/15] Make NFS client use seq_list_xxx helpers
|
 |
|
[PATCH 13/15] Make /proc/tty/drivers use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:02
|
 |
|
[PATCH 14/15] Make /proc/slabinfo use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:06
|
 |
|
[PATCH 15/15] Make /proc/self/mounts(tats) use seq_list_xxx helpers
By: xemul on Fri, 18 May 2007 10:10
|
Goto Forum:
Current Time: Sat Sep 06 21:33:52 GMT 2025
Total time taken to generate the page: 0.11525 seconds
|