mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-13 11:51:32 +00:00
proc: introduce proc_create_net_single
Variant of proc_create_data that directly take a seq_file show callback and deals with network namespaces in ->open and ->release. All callers of proc_create + single_open_net converted over, and single_{open,release}_net are removed entirely. Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
c350637227
commit
3617d9496c
@ -93,37 +93,50 @@ struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(proc_create_net_data);
|
EXPORT_SYMBOL_GPL(proc_create_net_data);
|
||||||
|
|
||||||
int single_open_net(struct inode *inode, struct file *file,
|
static int single_open_net(struct inode *inode, struct file *file)
|
||||||
int (*show)(struct seq_file *, void *))
|
|
||||||
{
|
{
|
||||||
int err;
|
struct proc_dir_entry *de = PDE(inode);
|
||||||
struct net *net;
|
struct net *net;
|
||||||
|
int err;
|
||||||
|
|
||||||
err = -ENXIO;
|
|
||||||
net = get_proc_net(inode);
|
net = get_proc_net(inode);
|
||||||
if (net == NULL)
|
if (!net)
|
||||||
goto err_net;
|
return -ENXIO;
|
||||||
|
|
||||||
err = single_open(file, show, net);
|
err = single_open(file, de->single_show, net);
|
||||||
if (err < 0)
|
if (err)
|
||||||
goto err_open;
|
put_net(net);
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_open:
|
|
||||||
put_net(net);
|
|
||||||
err_net:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(single_open_net);
|
|
||||||
|
|
||||||
int single_release_net(struct inode *ino, struct file *f)
|
static int single_release_net(struct inode *ino, struct file *f)
|
||||||
{
|
{
|
||||||
struct seq_file *seq = f->private_data;
|
struct seq_file *seq = f->private_data;
|
||||||
put_net(seq->private);
|
put_net(seq->private);
|
||||||
return single_release(ino, f);
|
return single_release(ino, f);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(single_release_net);
|
|
||||||
|
static const struct file_operations proc_net_single_fops = {
|
||||||
|
.open = single_open_net,
|
||||||
|
.read = seq_read,
|
||||||
|
.llseek = seq_lseek,
|
||||||
|
.release = single_release_net,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
|
||||||
|
struct proc_dir_entry *parent,
|
||||||
|
int (*show)(struct seq_file *, void *), void *data)
|
||||||
|
{
|
||||||
|
struct proc_dir_entry *p;
|
||||||
|
|
||||||
|
p = proc_create_reg(name, mode, &parent, data);
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
p->proc_fops = &proc_net_single_fops;
|
||||||
|
p->single_show = show;
|
||||||
|
return proc_register(parent, p);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(proc_create_net_single);
|
||||||
|
|
||||||
static struct net *get_proc_task_net(struct inode *dir)
|
static struct net *get_proc_task_net(struct inode *dir)
|
||||||
{
|
{
|
||||||
|
@ -58,6 +58,9 @@ struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
|
|||||||
unsigned int state_size, void *data);
|
unsigned int state_size, void *data);
|
||||||
#define proc_create_net(name, mode, parent, state_size, ops) \
|
#define proc_create_net(name, mode, parent, state_size, ops) \
|
||||||
proc_create_net_data(name, mode, parent, state_size, ops, NULL)
|
proc_create_net_data(name, mode, parent, state_size, ops, NULL)
|
||||||
|
struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
|
||||||
|
struct proc_dir_entry *parent,
|
||||||
|
int (*show)(struct seq_file *, void *), void *data);
|
||||||
|
|
||||||
#else /* CONFIG_PROC_FS */
|
#else /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
@ -97,6 +100,7 @@ static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *p
|
|||||||
|
|
||||||
#define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;})
|
#define proc_create_net_data(name, mode, parent, ops, state_size, data) ({NULL;})
|
||||||
#define proc_create_net(name, mode, parent, state_size, ops) ({NULL;})
|
#define proc_create_net(name, mode, parent, state_size, ops) ({NULL;})
|
||||||
|
#define proc_create_net_single(name, mode, parent, show, data) ({NULL;})
|
||||||
|
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
|
@ -13,9 +13,6 @@ struct seq_net_private {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int single_open_net(struct inode *, struct file *file,
|
|
||||||
int (*show)(struct seq_file *, void *));
|
|
||||||
int single_release_net(struct inode *, struct file *);
|
|
||||||
static inline struct net *seq_file_net(struct seq_file *seq)
|
static inline struct net *seq_file_net(struct seq_file *seq)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_NS
|
#ifdef CONFIG_NET_NS
|
||||||
@ -26,8 +23,8 @@ static inline struct net *seq_file_net(struct seq_file *seq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This one is needed for single_open_net since net is stored directly in
|
* This one is needed for proc_create_net_single since net is stored directly
|
||||||
* private not as a struct i.e. seq_file_net can't be used.
|
* in private not as a struct i.e. seq_file_net can't be used.
|
||||||
*/
|
*/
|
||||||
static inline struct net *seq_file_single_net(struct seq_file *seq)
|
static inline struct net *seq_file_single_net(struct seq_file *seq)
|
||||||
{
|
{
|
||||||
|
@ -239,18 +239,6 @@ static int bcm_proc_show(struct seq_file *m, void *v)
|
|||||||
seq_putc(m, '\n');
|
seq_putc(m, '\n');
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, bcm_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations bcm_proc_fops = {
|
|
||||||
.open = bcm_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1606,9 +1594,9 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
|
|||||||
if (net->can.bcmproc_dir) {
|
if (net->can.bcmproc_dir) {
|
||||||
/* unique socket address as filename */
|
/* unique socket address as filename */
|
||||||
sprintf(bo->procname, "%lu", sock_i_ino(sk));
|
sprintf(bo->procname, "%lu", sock_i_ino(sk));
|
||||||
bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
|
bo->bcm_proc_read = proc_create_net_single(bo->procname, 0644,
|
||||||
net->can.bcmproc_dir,
|
net->can.bcmproc_dir,
|
||||||
&bcm_proc_fops, sk);
|
bcm_proc_show, sk);
|
||||||
if (!bo->bcm_proc_read) {
|
if (!bo->bcm_proc_read) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
127
net/can/proc.c
127
net/can/proc.c
@ -270,18 +270,6 @@ static int can_stats_proc_show(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_stats_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, can_stats_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations can_stats_proc_fops = {
|
|
||||||
.open = can_stats_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int can_reset_stats_proc_show(struct seq_file *m, void *v)
|
static int can_reset_stats_proc_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
struct net *net = m->private;
|
struct net *net = m->private;
|
||||||
@ -303,36 +291,12 @@ static int can_reset_stats_proc_show(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_reset_stats_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, can_reset_stats_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations can_reset_stats_proc_fops = {
|
|
||||||
.open = can_reset_stats_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int can_version_proc_show(struct seq_file *m, void *v)
|
static int can_version_proc_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
seq_printf(m, "%s\n", CAN_VERSION_STRING);
|
seq_printf(m, "%s\n", CAN_VERSION_STRING);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_version_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, can_version_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations can_version_proc_fops = {
|
|
||||||
.open = can_version_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline void can_rcvlist_proc_show_one(struct seq_file *m, int idx,
|
static inline void can_rcvlist_proc_show_one(struct seq_file *m, int idx,
|
||||||
struct net_device *dev,
|
struct net_device *dev,
|
||||||
struct can_dev_rcv_lists *d)
|
struct can_dev_rcv_lists *d)
|
||||||
@ -373,18 +337,6 @@ static int can_rcvlist_proc_show(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_rcvlist_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, can_rcvlist_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations can_rcvlist_proc_fops = {
|
|
||||||
.open = can_rcvlist_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release,
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline void can_rcvlist_proc_show_array(struct seq_file *m,
|
static inline void can_rcvlist_proc_show_array(struct seq_file *m,
|
||||||
struct net_device *dev,
|
struct net_device *dev,
|
||||||
struct hlist_head *rcv_array,
|
struct hlist_head *rcv_array,
|
||||||
@ -440,19 +392,6 @@ static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_rcvlist_sff_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, can_rcvlist_sff_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations can_rcvlist_sff_proc_fops = {
|
|
||||||
.open = can_rcvlist_sff_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v)
|
static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
@ -483,18 +422,6 @@ static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_rcvlist_eff_proc_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, can_rcvlist_eff_proc_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations can_rcvlist_eff_proc_fops = {
|
|
||||||
.open = can_rcvlist_eff_proc_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* can_init_proc - create main CAN proc directory and procfs entries
|
* can_init_proc - create main CAN proc directory and procfs entries
|
||||||
*/
|
*/
|
||||||
@ -510,37 +437,29 @@ void can_init_proc(struct net *net)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* own procfs entries from the AF_CAN core */
|
/* own procfs entries from the AF_CAN core */
|
||||||
net->can.pde_version = proc_create(CAN_PROC_VERSION, 0644,
|
net->can.pde_version = proc_create_net_single(CAN_PROC_VERSION, 0644,
|
||||||
net->can.proc_dir,
|
net->can.proc_dir, can_version_proc_show, NULL);
|
||||||
&can_version_proc_fops);
|
net->can.pde_stats = proc_create_net_single(CAN_PROC_STATS, 0644,
|
||||||
net->can.pde_stats = proc_create(CAN_PROC_STATS, 0644,
|
net->can.proc_dir, can_stats_proc_show, NULL);
|
||||||
net->can.proc_dir,
|
net->can.pde_reset_stats = proc_create_net_single(CAN_PROC_RESET_STATS,
|
||||||
&can_stats_proc_fops);
|
0644, net->can.proc_dir, can_reset_stats_proc_show,
|
||||||
net->can.pde_reset_stats = proc_create(CAN_PROC_RESET_STATS, 0644,
|
NULL);
|
||||||
net->can.proc_dir,
|
net->can.pde_rcvlist_err = proc_create_net_single(CAN_PROC_RCVLIST_ERR,
|
||||||
&can_reset_stats_proc_fops);
|
0644, net->can.proc_dir, can_rcvlist_proc_show,
|
||||||
net->can.pde_rcvlist_err = proc_create_data(CAN_PROC_RCVLIST_ERR, 0644,
|
(void *)RX_ERR);
|
||||||
net->can.proc_dir,
|
net->can.pde_rcvlist_all = proc_create_net_single(CAN_PROC_RCVLIST_ALL,
|
||||||
&can_rcvlist_proc_fops,
|
0644, net->can.proc_dir, can_rcvlist_proc_show,
|
||||||
(void *)RX_ERR);
|
(void *)RX_ALL);
|
||||||
net->can.pde_rcvlist_all = proc_create_data(CAN_PROC_RCVLIST_ALL, 0644,
|
net->can.pde_rcvlist_fil = proc_create_net_single(CAN_PROC_RCVLIST_FIL,
|
||||||
net->can.proc_dir,
|
0644, net->can.proc_dir, can_rcvlist_proc_show,
|
||||||
&can_rcvlist_proc_fops,
|
(void *)RX_FIL);
|
||||||
(void *)RX_ALL);
|
net->can.pde_rcvlist_inv = proc_create_net_single(CAN_PROC_RCVLIST_INV,
|
||||||
net->can.pde_rcvlist_fil = proc_create_data(CAN_PROC_RCVLIST_FIL, 0644,
|
0644, net->can.proc_dir, can_rcvlist_proc_show,
|
||||||
net->can.proc_dir,
|
(void *)RX_INV);
|
||||||
&can_rcvlist_proc_fops,
|
net->can.pde_rcvlist_eff = proc_create_net_single(CAN_PROC_RCVLIST_EFF,
|
||||||
(void *)RX_FIL);
|
0644, net->can.proc_dir, can_rcvlist_eff_proc_show, NULL);
|
||||||
net->can.pde_rcvlist_inv = proc_create_data(CAN_PROC_RCVLIST_INV, 0644,
|
net->can.pde_rcvlist_sff = proc_create_net_single(CAN_PROC_RCVLIST_SFF,
|
||||||
net->can.proc_dir,
|
0644, net->can.proc_dir, can_rcvlist_sff_proc_show, NULL);
|
||||||
&can_rcvlist_proc_fops,
|
|
||||||
(void *)RX_INV);
|
|
||||||
net->can.pde_rcvlist_eff = proc_create(CAN_PROC_RCVLIST_EFF, 0644,
|
|
||||||
net->can.proc_dir,
|
|
||||||
&can_rcvlist_eff_proc_fops);
|
|
||||||
net->can.pde_rcvlist_sff = proc_create(CAN_PROC_RCVLIST_SFF, 0644,
|
|
||||||
net->can.proc_dir,
|
|
||||||
&can_rcvlist_sff_proc_fops);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2348,18 +2348,6 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fib_triestat_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, fib_triestat_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations fib_triestat_fops = {
|
|
||||||
.open = fib_triestat_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct key_vector *fib_trie_get_idx(struct seq_file *seq, loff_t pos)
|
static struct key_vector *fib_trie_get_idx(struct seq_file *seq, loff_t pos)
|
||||||
{
|
{
|
||||||
struct fib_trie_iter *iter = seq->private;
|
struct fib_trie_iter *iter = seq->private;
|
||||||
@ -2719,8 +2707,8 @@ int __net_init fib_proc_init(struct net *net)
|
|||||||
sizeof(struct fib_trie_iter)))
|
sizeof(struct fib_trie_iter)))
|
||||||
goto out1;
|
goto out1;
|
||||||
|
|
||||||
if (!proc_create("fib_triestat", 0444, net->proc_net,
|
if (!proc_create_net_single("fib_triestat", 0444, net->proc_net,
|
||||||
&fib_triestat_fops))
|
fib_triestat_seq_show, NULL))
|
||||||
goto out2;
|
goto out2;
|
||||||
|
|
||||||
if (!proc_create_net("route", 0444, net->proc_net, &fib_route_seq_ops,
|
if (!proc_create_net("route", 0444, net->proc_net, &fib_route_seq_ops,
|
||||||
|
@ -77,18 +77,6 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sockstat_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, sockstat_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations sockstat_seq_fops = {
|
|
||||||
.open = sockstat_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* snmp items */
|
/* snmp items */
|
||||||
static const struct snmp_mib snmp4_ipstats_list[] = {
|
static const struct snmp_mib snmp4_ipstats_list[] = {
|
||||||
SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INPKTS),
|
SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INPKTS),
|
||||||
@ -460,20 +448,6 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snmp_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, snmp_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations snmp_seq_fops = {
|
|
||||||
.open = snmp_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output /proc/net/netstat
|
* Output /proc/net/netstat
|
||||||
*/
|
*/
|
||||||
@ -507,26 +481,16 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int netstat_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, netstat_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations netstat_seq_fops = {
|
|
||||||
.open = netstat_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static __net_init int ip_proc_init_net(struct net *net)
|
static __net_init int ip_proc_init_net(struct net *net)
|
||||||
{
|
{
|
||||||
if (!proc_create("sockstat", 0444, net->proc_net,
|
if (!proc_create_net_single("sockstat", 0444, net->proc_net,
|
||||||
&sockstat_seq_fops))
|
sockstat_seq_show, NULL))
|
||||||
goto out_sockstat;
|
goto out_sockstat;
|
||||||
if (!proc_create("netstat", 0444, net->proc_net, &netstat_seq_fops))
|
if (!proc_create_net_single("netstat", 0444, net->proc_net,
|
||||||
|
netstat_seq_show, NULL))
|
||||||
goto out_netstat;
|
goto out_netstat;
|
||||||
if (!proc_create("snmp", 0444, net->proc_net, &snmp_seq_fops))
|
if (!proc_create_net_single("snmp", 0444, net->proc_net, snmp_seq_show,
|
||||||
|
NULL))
|
||||||
goto out_snmp;
|
goto out_snmp;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -53,18 +53,6 @@ static int sockstat6_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sockstat6_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, sockstat6_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations sockstat6_seq_fops = {
|
|
||||||
.open = sockstat6_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct snmp_mib snmp6_ipstats_list[] = {
|
static const struct snmp_mib snmp6_ipstats_list[] = {
|
||||||
/* ipv6 mib according to RFC 2465 */
|
/* ipv6 mib according to RFC 2465 */
|
||||||
SNMP_MIB_ITEM("Ip6InReceives", IPSTATS_MIB_INPKTS),
|
SNMP_MIB_ITEM("Ip6InReceives", IPSTATS_MIB_INPKTS),
|
||||||
@ -242,18 +230,6 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snmp6_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, snmp6_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations snmp6_seq_fops = {
|
|
||||||
.open = snmp6_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int snmp6_dev_seq_show(struct seq_file *seq, void *v)
|
static int snmp6_dev_seq_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
struct inet6_dev *idev = (struct inet6_dev *)seq->private;
|
struct inet6_dev *idev = (struct inet6_dev *)seq->private;
|
||||||
@ -302,11 +278,12 @@ int snmp6_unregister_dev(struct inet6_dev *idev)
|
|||||||
|
|
||||||
static int __net_init ipv6_proc_init_net(struct net *net)
|
static int __net_init ipv6_proc_init_net(struct net *net)
|
||||||
{
|
{
|
||||||
if (!proc_create("sockstat6", 0444, net->proc_net,
|
if (!proc_create_net_single("sockstat6", 0444, net->proc_net,
|
||||||
&sockstat6_seq_fops))
|
sockstat6_seq_show, NULL))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (!proc_create("snmp6", 0444, net->proc_net, &snmp6_seq_fops))
|
if (!proc_create_net_single("snmp6", 0444, net->proc_net,
|
||||||
|
snmp6_seq_show, NULL))
|
||||||
goto proc_snmp6_fail;
|
goto proc_snmp6_fail;
|
||||||
|
|
||||||
net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
|
net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net);
|
||||||
|
@ -4876,18 +4876,6 @@ static int rt6_stats_seq_show(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rt6_stats_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, rt6_stats_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations rt6_stats_seq_fops = {
|
|
||||||
.open = rt6_stats_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL
|
#ifdef CONFIG_SYSCTL
|
||||||
@ -5094,7 +5082,8 @@ static int __net_init ip6_route_net_init_late(struct net *net)
|
|||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
proc_create_net("ipv6_route", 0, net->proc_net, &ipv6_route_seq_ops,
|
proc_create_net("ipv6_route", 0, net->proc_net, &ipv6_route_seq_ops,
|
||||||
sizeof(struct ipv6_route_iter));
|
sizeof(struct ipv6_route_iter));
|
||||||
proc_create("rt6_stats", 0444, net->proc_net, &rt6_stats_seq_fops);
|
proc_create_net_single("rt6_stats", 0444, net->proc_net,
|
||||||
|
rt6_stats_seq_show, NULL);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -345,22 +345,10 @@ static int kcm_stats_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int kcm_stats_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, kcm_stats_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations kcm_stats_seq_fops = {
|
|
||||||
.open = kcm_stats_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int kcm_proc_init_net(struct net *net)
|
static int kcm_proc_init_net(struct net *net)
|
||||||
{
|
{
|
||||||
if (!proc_create("kcm_stats", 0444, net->proc_net,
|
if (!proc_create_net_single("kcm_stats", 0444, net->proc_net,
|
||||||
&kcm_stats_seq_fops))
|
kcm_stats_seq_show, NULL))
|
||||||
goto out_kcm_stats;
|
goto out_kcm_stats;
|
||||||
|
|
||||||
if (!proc_create_net("kcm", 0444, net->proc_net, &kcm_seq_ops,
|
if (!proc_create_net("kcm", 0444, net->proc_net, &kcm_seq_ops,
|
||||||
|
@ -2141,18 +2141,6 @@ static int ip_vs_stats_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ip_vs_stats_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, ip_vs_stats_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ip_vs_stats_fops = {
|
|
||||||
.open = ip_vs_stats_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
|
static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
struct net *net = seq_file_single_net(seq);
|
struct net *net = seq_file_single_net(seq);
|
||||||
@ -2208,18 +2196,6 @@ static int ip_vs_stats_percpu_show(struct seq_file *seq, void *v)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ip_vs_stats_percpu_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, ip_vs_stats_percpu_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations ip_vs_stats_percpu_fops = {
|
|
||||||
.open = ip_vs_stats_percpu_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -4019,9 +3995,10 @@ int __net_init ip_vs_control_net_init(struct netns_ipvs *ipvs)
|
|||||||
|
|
||||||
proc_create_net("ip_vs", 0, ipvs->net->proc_net, &ip_vs_info_seq_ops,
|
proc_create_net("ip_vs", 0, ipvs->net->proc_net, &ip_vs_info_seq_ops,
|
||||||
sizeof(struct ip_vs_iter));
|
sizeof(struct ip_vs_iter));
|
||||||
proc_create("ip_vs_stats", 0, ipvs->net->proc_net, &ip_vs_stats_fops);
|
proc_create_net_single("ip_vs_stats", 0, ipvs->net->proc_net,
|
||||||
proc_create("ip_vs_stats_percpu", 0, ipvs->net->proc_net,
|
ip_vs_stats_show, NULL);
|
||||||
&ip_vs_stats_percpu_fops);
|
proc_create_net_single("ip_vs_stats_percpu", 0, ipvs->net->proc_net,
|
||||||
|
ip_vs_stats_percpu_show, NULL);
|
||||||
|
|
||||||
if (ip_vs_control_net_init_sysctl(ipvs))
|
if (ip_vs_control_net_init_sysctl(ipvs))
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -88,19 +88,6 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the seq file operations for 'snmp' object. */
|
|
||||||
static int sctp_snmp_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, sctp_snmp_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations sctp_snmp_seq_fops = {
|
|
||||||
.open = sctp_snmp_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Dump local addresses of an association/endpoint. */
|
/* Dump local addresses of an association/endpoint. */
|
||||||
static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb)
|
static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb)
|
||||||
{
|
{
|
||||||
@ -408,8 +395,8 @@ int __net_init sctp_proc_init(struct net *net)
|
|||||||
net->sctp.proc_net_sctp = proc_net_mkdir(net, "sctp", net->proc_net);
|
net->sctp.proc_net_sctp = proc_net_mkdir(net, "sctp", net->proc_net);
|
||||||
if (!net->sctp.proc_net_sctp)
|
if (!net->sctp.proc_net_sctp)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
if (!proc_create("snmp", 0444, net->sctp.proc_net_sctp,
|
if (!proc_create_net_single("snmp", 0444, net->sctp.proc_net_sctp,
|
||||||
&sctp_snmp_seq_fops))
|
sctp_snmp_seq_show, NULL))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (!proc_create_net("eps", 0444, net->sctp.proc_net_sctp,
|
if (!proc_create_net("eps", 0444, net->sctp.proc_net_sctp,
|
||||||
&sctp_eps_ops, sizeof(struct seq_net_private)))
|
&sctp_eps_ops, sizeof(struct seq_net_private)))
|
||||||
|
@ -65,22 +65,10 @@ static int xfrm_statistics_seq_show(struct seq_file *seq, void *v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xfrm_statistics_seq_open(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
return single_open_net(inode, file, xfrm_statistics_seq_show);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct file_operations xfrm_statistics_seq_fops = {
|
|
||||||
.open = xfrm_statistics_seq_open,
|
|
||||||
.read = seq_read,
|
|
||||||
.llseek = seq_lseek,
|
|
||||||
.release = single_release_net,
|
|
||||||
};
|
|
||||||
|
|
||||||
int __net_init xfrm_proc_init(struct net *net)
|
int __net_init xfrm_proc_init(struct net *net)
|
||||||
{
|
{
|
||||||
if (!proc_create("xfrm_stat", 0444, net->proc_net,
|
if (!proc_create_net_single("xfrm_stat", 0444, net->proc_net,
|
||||||
&xfrm_statistics_seq_fops))
|
xfrm_statistics_seq_show, NULL))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user