diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2007-11-05 23:33:46 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-11-07 07:08:20 -0500 |
commit | 7351a22a3ae005422488139365e9a80f560c80b9 (patch) | |
tree | 566d9ccf3f7c6b0ecbb4bed84482e8511786d9c7 /net/ipv4 | |
parent | dbeeb816e805091e7cfc03baf36dc40b4adb2bbd (diff) |
[NETFILTER]: ip{,6}_queue: convert to seq_file interface
I plan to kill ->get_info which means killing proc_net_create().
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/netfilter/ip_queue.c | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index 10a2ce09fd8e..14d64a383db1 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
23 | #include <linux/sysctl.h> | 23 | #include <linux/sysctl.h> |
24 | #include <linux/proc_fs.h> | 24 | #include <linux/proc_fs.h> |
25 | #include <linux/seq_file.h> | ||
25 | #include <linux/security.h> | 26 | #include <linux/security.h> |
26 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
27 | #include <net/net_namespace.h> | 28 | #include <net/net_namespace.h> |
@@ -607,15 +608,11 @@ static ctl_table ipq_root_table[] = { | |||
607 | { .ctl_name = 0 } | 608 | { .ctl_name = 0 } |
608 | }; | 609 | }; |
609 | 610 | ||
610 | #ifdef CONFIG_PROC_FS | 611 | static int ip_queue_show(struct seq_file *m, void *v) |
611 | static int | ||
612 | ipq_get_info(char *buffer, char **start, off_t offset, int length) | ||
613 | { | 612 | { |
614 | int len; | ||
615 | |||
616 | read_lock_bh(&queue_lock); | 613 | read_lock_bh(&queue_lock); |
617 | 614 | ||
618 | len = sprintf(buffer, | 615 | seq_printf(m, |
619 | "Peer PID : %d\n" | 616 | "Peer PID : %d\n" |
620 | "Copy mode : %hu\n" | 617 | "Copy mode : %hu\n" |
621 | "Copy range : %u\n" | 618 | "Copy range : %u\n" |
@@ -632,16 +629,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length) | |||
632 | queue_user_dropped); | 629 | queue_user_dropped); |
633 | 630 | ||
634 | read_unlock_bh(&queue_lock); | 631 | read_unlock_bh(&queue_lock); |
632 | return 0; | ||
633 | } | ||
635 | 634 | ||
636 | *start = buffer + offset; | 635 | static int ip_queue_open(struct inode *inode, struct file *file) |
637 | len -= offset; | 636 | { |
638 | if (len > length) | 637 | return single_open(file, ip_queue_show, NULL); |
639 | len = length; | ||
640 | else if (len < 0) | ||
641 | len = 0; | ||
642 | return len; | ||
643 | } | 638 | } |
644 | #endif /* CONFIG_PROC_FS */ | 639 | |
640 | static const struct file_operations ip_queue_proc_fops = { | ||
641 | .open = ip_queue_open, | ||
642 | .read = seq_read, | ||
643 | .llseek = seq_lseek, | ||
644 | .release = single_release, | ||
645 | .owner = THIS_MODULE, | ||
646 | }; | ||
645 | 647 | ||
646 | static struct nf_queue_handler nfqh = { | 648 | static struct nf_queue_handler nfqh = { |
647 | .name = "ip_queue", | 649 | .name = "ip_queue", |
@@ -661,10 +663,11 @@ static int __init ip_queue_init(void) | |||
661 | goto cleanup_netlink_notifier; | 663 | goto cleanup_netlink_notifier; |
662 | } | 664 | } |
663 | 665 | ||
664 | proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info); | 666 | proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net); |
665 | if (proc) | 667 | if (proc) { |
666 | proc->owner = THIS_MODULE; | 668 | proc->owner = THIS_MODULE; |
667 | else { | 669 | proc->proc_fops = &ip_queue_proc_fops; |
670 | } else { | ||
668 | printk(KERN_ERR "ip_queue: failed to create proc entry\n"); | 671 | printk(KERN_ERR "ip_queue: failed to create proc entry\n"); |
669 | goto cleanup_ipqnl; | 672 | goto cleanup_ipqnl; |
670 | } | 673 | } |