diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2010-02-08 18:19:29 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-10 14:12:08 -0500 |
commit | b7ceabd9b528417973619c5b655bc5b21857ac36 (patch) | |
tree | c253a00794dc2078f03eb2690c0a99e020596395 /net/packet/af_packet.c | |
parent | b999748acce739675a5e9420f21e54b8cbad9d81 (diff) |
net: packet: 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/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 6ecb426bc0cf..10f7295bcefb 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -2510,33 +2510,19 @@ static struct notifier_block packet_netdev_notifier = { | |||
2510 | }; | 2510 | }; |
2511 | 2511 | ||
2512 | #ifdef CONFIG_PROC_FS | 2512 | #ifdef CONFIG_PROC_FS |
2513 | static inline struct sock *packet_seq_idx(struct net *net, loff_t off) | ||
2514 | { | ||
2515 | struct sock *s; | ||
2516 | struct hlist_node *node; | ||
2517 | |||
2518 | sk_for_each(s, node, &net->packet.sklist) { | ||
2519 | if (!off--) | ||
2520 | return s; | ||
2521 | } | ||
2522 | return NULL; | ||
2523 | } | ||
2524 | 2513 | ||
2525 | static void *packet_seq_start(struct seq_file *seq, loff_t *pos) | 2514 | static void *packet_seq_start(struct seq_file *seq, loff_t *pos) |
2526 | __acquires(seq_file_net(seq)->packet.sklist_lock) | 2515 | __acquires(seq_file_net(seq)->packet.sklist_lock) |
2527 | { | 2516 | { |
2528 | struct net *net = seq_file_net(seq); | 2517 | struct net *net = seq_file_net(seq); |
2529 | read_lock(&net->packet.sklist_lock); | 2518 | read_lock(&net->packet.sklist_lock); |
2530 | return *pos ? packet_seq_idx(net, *pos - 1) : SEQ_START_TOKEN; | 2519 | return seq_hlist_start_head(&net->packet.sklist, *pos); |
2531 | } | 2520 | } |
2532 | 2521 | ||
2533 | static void *packet_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2522 | static void *packet_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
2534 | { | 2523 | { |
2535 | struct net *net = seq_file_net(seq); | 2524 | struct net *net = seq_file_net(seq); |
2536 | ++*pos; | 2525 | return seq_hlist_next(v, &net->packet.sklist, pos); |
2537 | return (v == SEQ_START_TOKEN) | ||
2538 | ? sk_head(&net->packet.sklist) | ||
2539 | : sk_next((struct sock *)v) ; | ||
2540 | } | 2526 | } |
2541 | 2527 | ||
2542 | static void packet_seq_stop(struct seq_file *seq, void *v) | 2528 | static void packet_seq_stop(struct seq_file *seq, void *v) |
@@ -2551,7 +2537,7 @@ static int packet_seq_show(struct seq_file *seq, void *v) | |||
2551 | if (v == SEQ_START_TOKEN) | 2537 | if (v == SEQ_START_TOKEN) |
2552 | seq_puts(seq, "sk RefCnt Type Proto Iface R Rmem User Inode\n"); | 2538 | seq_puts(seq, "sk RefCnt Type Proto Iface R Rmem User Inode\n"); |
2553 | else { | 2539 | else { |
2554 | struct sock *s = v; | 2540 | struct sock *s = sk_entry(v); |
2555 | const struct packet_sock *po = pkt_sk(s); | 2541 | const struct packet_sock *po = pkt_sk(s); |
2556 | 2542 | ||
2557 | seq_printf(seq, | 2543 | seq_printf(seq, |