Commit 7351a22a authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

[NETFILTER]: ip{,6}_queue: convert to seq_file interface

I plan to kill ->get_info which means killing proc_net_create().
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dbeeb816
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
...@@ -607,15 +608,11 @@ static ctl_table ipq_root_table[] = { ...@@ -607,15 +608,11 @@ static ctl_table ipq_root_table[] = {
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
#ifdef CONFIG_PROC_FS static int ip_queue_show(struct seq_file *m, void *v)
static int
ipq_get_info(char *buffer, char **start, off_t offset, int length)
{ {
int len;
read_lock_bh(&queue_lock); read_lock_bh(&queue_lock);
len = sprintf(buffer, seq_printf(m,
"Peer PID : %d\n" "Peer PID : %d\n"
"Copy mode : %hu\n" "Copy mode : %hu\n"
"Copy range : %u\n" "Copy range : %u\n"
...@@ -632,16 +629,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -632,16 +629,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
queue_user_dropped); queue_user_dropped);
read_unlock_bh(&queue_lock); read_unlock_bh(&queue_lock);
return 0;
}
*start = buffer + offset; static int ip_queue_open(struct inode *inode, struct file *file)
len -= offset; {
if (len > length) return single_open(file, ip_queue_show, NULL);
len = length;
else if (len < 0)
len = 0;
return len;
} }
#endif /* CONFIG_PROC_FS */
static const struct file_operations ip_queue_proc_fops = {
.open = ip_queue_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static struct nf_queue_handler nfqh = { static struct nf_queue_handler nfqh = {
.name = "ip_queue", .name = "ip_queue",
...@@ -661,10 +663,11 @@ static int __init ip_queue_init(void) ...@@ -661,10 +663,11 @@ static int __init ip_queue_init(void)
goto cleanup_netlink_notifier; goto cleanup_netlink_notifier;
} }
proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info); proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
if (proc) if (proc) {
proc->owner = THIS_MODULE; proc->owner = THIS_MODULE;
else { proc->proc_fops = &ip_queue_proc_fops;
} else {
printk(KERN_ERR "ip_queue: failed to create proc entry\n"); printk(KERN_ERR "ip_queue: failed to create proc entry\n");
goto cleanup_ipqnl; goto cleanup_ipqnl;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/sock.h> #include <net/sock.h>
...@@ -596,15 +597,11 @@ static ctl_table ipq_root_table[] = { ...@@ -596,15 +597,11 @@ static ctl_table ipq_root_table[] = {
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
#ifdef CONFIG_PROC_FS static int ip6_queue_show(struct seq_file *m, void *v)
static int
ipq_get_info(char *buffer, char **start, off_t offset, int length)
{ {
int len;
read_lock_bh(&queue_lock); read_lock_bh(&queue_lock);
len = sprintf(buffer, seq_printf(m,
"Peer PID : %d\n" "Peer PID : %d\n"
"Copy mode : %hu\n" "Copy mode : %hu\n"
"Copy range : %u\n" "Copy range : %u\n"
...@@ -621,16 +618,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length) ...@@ -621,16 +618,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
queue_user_dropped); queue_user_dropped);
read_unlock_bh(&queue_lock); read_unlock_bh(&queue_lock);
return 0;
}
*start = buffer + offset; static int ip6_queue_open(struct inode *inode, struct file *file)
len -= offset; {
if (len > length) return single_open(file, ip6_queue_show, NULL);
len = length;
else if (len < 0)
len = 0;
return len;
} }
#endif /* CONFIG_PROC_FS */
static const struct file_operations ip6_queue_proc_fops = {
.open = ip6_queue_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};
static struct nf_queue_handler nfqh = { static struct nf_queue_handler nfqh = {
.name = "ip6_queue", .name = "ip6_queue",
...@@ -650,10 +652,11 @@ static int __init ip6_queue_init(void) ...@@ -650,10 +652,11 @@ static int __init ip6_queue_init(void)
goto cleanup_netlink_notifier; goto cleanup_netlink_notifier;
} }
proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info); proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
if (proc) if (proc) {
proc->owner = THIS_MODULE; proc->owner = THIS_MODULE;
else { proc->proc_fops = &ip6_queue_proc_fops;
} else {
printk(KERN_ERR "ip6_queue: failed to create proc entry\n"); printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
goto cleanup_ipqnl; goto cleanup_ipqnl;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment