Commit 7091e728 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

netns: igmp: make /proc/net/{igmp,mcfilter} per netns

This patch makes the followinf proc entries per-netns:
/proc/net/igmp
/proc/net/mcfilter
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Acked-by: default avatarDaniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: default avatarBenjamin Thery <benjamin.thery@bull.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b4ee07df
...@@ -2275,6 +2275,7 @@ int ip_check_mc(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u16 p ...@@ -2275,6 +2275,7 @@ int ip_check_mc(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u16 p
#if defined(CONFIG_PROC_FS) #if defined(CONFIG_PROC_FS)
struct igmp_mc_iter_state { struct igmp_mc_iter_state {
struct seq_net_private p;
struct net_device *dev; struct net_device *dev;
struct in_device *in_dev; struct in_device *in_dev;
}; };
...@@ -2283,11 +2284,12 @@ struct igmp_mc_iter_state { ...@@ -2283,11 +2284,12 @@ struct igmp_mc_iter_state {
static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq) static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
{ {
struct net *net = seq_file_net(seq);
struct ip_mc_list *im = NULL; struct ip_mc_list *im = NULL;
struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
state->in_dev = NULL; state->in_dev = NULL;
for_each_netdev(&init_net, state->dev) { for_each_netdev(net, state->dev) {
struct in_device *in_dev; struct in_device *in_dev;
in_dev = in_dev_get(state->dev); in_dev = in_dev_get(state->dev);
if (!in_dev) if (!in_dev)
...@@ -2408,7 +2410,7 @@ static const struct seq_operations igmp_mc_seq_ops = { ...@@ -2408,7 +2410,7 @@ static const struct seq_operations igmp_mc_seq_ops = {
static int igmp_mc_seq_open(struct inode *inode, struct file *file) static int igmp_mc_seq_open(struct inode *inode, struct file *file)
{ {
return seq_open_private(file, &igmp_mc_seq_ops, return seq_open_net(inode, file, &igmp_mc_seq_ops,
sizeof(struct igmp_mc_iter_state)); sizeof(struct igmp_mc_iter_state));
} }
...@@ -2417,10 +2419,11 @@ static const struct file_operations igmp_mc_seq_fops = { ...@@ -2417,10 +2419,11 @@ static const struct file_operations igmp_mc_seq_fops = {
.open = igmp_mc_seq_open, .open = igmp_mc_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release_private, .release = seq_release_net,
}; };
struct igmp_mcf_iter_state { struct igmp_mcf_iter_state {
struct seq_net_private p;
struct net_device *dev; struct net_device *dev;
struct in_device *idev; struct in_device *idev;
struct ip_mc_list *im; struct ip_mc_list *im;
...@@ -2430,13 +2433,14 @@ struct igmp_mcf_iter_state { ...@@ -2430,13 +2433,14 @@ struct igmp_mcf_iter_state {
static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq) static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
{ {
struct net *net = seq_file_net(seq);
struct ip_sf_list *psf = NULL; struct ip_sf_list *psf = NULL;
struct ip_mc_list *im = NULL; struct ip_mc_list *im = NULL;
struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq); struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
state->idev = NULL; state->idev = NULL;
state->im = NULL; state->im = NULL;
for_each_netdev(&init_net, state->dev) { for_each_netdev(net, state->dev) {
struct in_device *idev; struct in_device *idev;
idev = in_dev_get(state->dev); idev = in_dev_get(state->dev);
if (unlikely(idev == NULL)) if (unlikely(idev == NULL))
...@@ -2567,7 +2571,7 @@ static const struct seq_operations igmp_mcf_seq_ops = { ...@@ -2567,7 +2571,7 @@ static const struct seq_operations igmp_mcf_seq_ops = {
static int igmp_mcf_seq_open(struct inode *inode, struct file *file) static int igmp_mcf_seq_open(struct inode *inode, struct file *file)
{ {
return seq_open_private(file, &igmp_mcf_seq_ops, return seq_open_net(inode, file, &igmp_mcf_seq_ops,
sizeof(struct igmp_mcf_iter_state)); sizeof(struct igmp_mcf_iter_state));
} }
...@@ -2576,14 +2580,41 @@ static const struct file_operations igmp_mcf_seq_fops = { ...@@ -2576,14 +2580,41 @@ static const struct file_operations igmp_mcf_seq_fops = {
.open = igmp_mcf_seq_open, .open = igmp_mcf_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = seq_release_private, .release = seq_release_net,
}; };
int __init igmp_mc_proc_init(void) static int igmp_net_init(struct net *net)
{ {
proc_net_fops_create(&init_net, "igmp", S_IRUGO, &igmp_mc_seq_fops); struct proc_dir_entry *pde;
proc_net_fops_create(&init_net, "mcfilter", S_IRUGO, &igmp_mcf_seq_fops);
pde = proc_net_fops_create(net, "igmp", S_IRUGO, &igmp_mc_seq_fops);
if (!pde)
goto out_igmp;
pde = proc_net_fops_create(net, "mcfilter", S_IRUGO, &igmp_mcf_seq_fops);
if (!pde)
goto out_mcfilter;
return 0; return 0;
out_mcfilter:
proc_net_remove(net, "igmp");
out_igmp:
return -ENOMEM;
}
static void igmp_net_exit(struct net *net)
{
proc_net_remove(net, "mcfilter");
proc_net_remove(net, "igmp");
}
static struct pernet_operations igmp_net_ops = {
.init = igmp_net_init,
.exit = igmp_net_exit,
};
int __init igmp_mc_proc_init(void)
{
return register_pernet_subsys(&igmp_net_ops);
} }
#endif #endif
......
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