diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-02-08 18:20:29 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-10 14:12:10 -0500 |
commit | 27b5b8657a2aa761f76e45fa60c20b7bafc249dc (patch) | |
tree | 562e9272445433242b1d4f165311df231d85d72c /net/key | |
parent | efaffb78d875a155b9f327532c2ddccf28c592b4 (diff) |
net: af_key: use seq_hlist_foo() helpers
Simplify seq_file code.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/key')
-rw-r--r-- | net/key/af_key.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index 41dd2cb07ef3..79d2c0f3c334 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -3654,9 +3654,8 @@ static const struct net_proto_family pfkey_family_ops = { | |||
3654 | #ifdef CONFIG_PROC_FS | 3654 | #ifdef CONFIG_PROC_FS |
3655 | static int pfkey_seq_show(struct seq_file *f, void *v) | 3655 | static int pfkey_seq_show(struct seq_file *f, void *v) |
3656 | { | 3656 | { |
3657 | struct sock *s; | 3657 | struct sock *s = sk_entry(v); |
3658 | 3658 | ||
3659 | s = (struct sock *)v; | ||
3660 | if (v == SEQ_START_TOKEN) | 3659 | if (v == SEQ_START_TOKEN) |
3661 | seq_printf(f ,"sk RefCnt Rmem Wmem User Inode\n"); | 3660 | seq_printf(f ,"sk RefCnt Rmem Wmem User Inode\n"); |
3662 | else | 3661 | else |
@@ -3675,19 +3674,9 @@ static void *pfkey_seq_start(struct seq_file *f, loff_t *ppos) | |||
3675 | { | 3674 | { |
3676 | struct net *net = seq_file_net(f); | 3675 | struct net *net = seq_file_net(f); |
3677 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 3676 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
3678 | struct sock *s; | ||
3679 | struct hlist_node *node; | ||
3680 | loff_t pos = *ppos; | ||
3681 | 3677 | ||
3682 | read_lock(&pfkey_table_lock); | 3678 | read_lock(&pfkey_table_lock); |
3683 | if (pos == 0) | 3679 | return seq_hlist_start_head(&net_pfkey->table, *ppos); |
3684 | return SEQ_START_TOKEN; | ||
3685 | |||
3686 | sk_for_each(s, node, &net_pfkey->table) | ||
3687 | if (pos-- == 1) | ||
3688 | return s; | ||
3689 | |||
3690 | return NULL; | ||
3691 | } | 3680 | } |
3692 | 3681 | ||
3693 | static void *pfkey_seq_next(struct seq_file *f, void *v, loff_t *ppos) | 3682 | static void *pfkey_seq_next(struct seq_file *f, void *v, loff_t *ppos) |
@@ -3695,10 +3684,7 @@ static void *pfkey_seq_next(struct seq_file *f, void *v, loff_t *ppos) | |||
3695 | struct net *net = seq_file_net(f); | 3684 | struct net *net = seq_file_net(f); |
3696 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 3685 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
3697 | 3686 | ||
3698 | ++*ppos; | 3687 | return seq_hlist_next(v, &net_pfkey->table, ppos); |
3699 | return (v == SEQ_START_TOKEN) ? | ||
3700 | sk_head(&net_pfkey->table) : | ||
3701 | sk_next((struct sock *)v); | ||
3702 | } | 3688 | } |
3703 | 3689 | ||
3704 | static void pfkey_seq_stop(struct seq_file *f, void *v) | 3690 | static void pfkey_seq_stop(struct seq_file *f, void *v) |