Skip to content

Commit

Permalink
[NETNS][RAW]: Create the /proc/net/raw(6) in each namespace.
Browse files Browse the repository at this point in the history
To do so, just register the proper subsystem and create files in
->init callbacks.

No other special per-namespace handling for raw sockets is required.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent e5ba31f commit a308da1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
22 changes: 19 additions & 3 deletions net/ipv4/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,15 +1003,31 @@ static const struct file_operations raw_seq_fops = {
.release = seq_release_net,
};

int __init raw_proc_init(void)
static __net_init int raw_init_net(struct net *net)
{
if (!proc_net_fops_create(&init_net, "raw", S_IRUGO, &raw_seq_fops))
if (!proc_net_fops_create(net, "raw", S_IRUGO, &raw_seq_fops))
return -ENOMEM;

return 0;
}

static __net_exit void raw_exit_net(struct net *net)
{
proc_net_remove(net, "raw");
}

static __net_initdata struct pernet_operations raw_net_ops = {
.init = raw_init_net,
.exit = raw_exit_net,
};

int __init raw_proc_init(void)
{
return register_pernet_subsys(&raw_net_ops);
}

void __init raw_proc_exit(void)
{
proc_net_remove(&init_net, "raw");
unregister_pernet_subsys(&raw_net_ops);
}
#endif /* CONFIG_PROC_FS */
22 changes: 19 additions & 3 deletions net/ipv6/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1270,16 +1270,32 @@ static const struct file_operations raw6_seq_fops = {
.release = seq_release_net,
};

int __init raw6_proc_init(void)
static int raw6_init_net(struct net *net)
{
if (!proc_net_fops_create(&init_net, "raw6", S_IRUGO, &raw6_seq_fops))
if (!proc_net_fops_create(net, "raw6", S_IRUGO, &raw6_seq_fops))
return -ENOMEM;

return 0;
}

static void raw6_exit_net(struct net *net)
{
proc_net_remove(net, "raw6");
}

static struct pernet_operations raw6_net_ops = {
.init = raw6_init_net,
.exit = raw6_exit_net,
};

int __init raw6_proc_init(void)
{
return register_pernet_subsys(&raw6_net_ops);
}

void raw6_proc_exit(void)
{
proc_net_remove(&init_net, "raw6");
unregister_pernet_subsys(&raw6_net_ops);
}
#endif /* CONFIG_PROC_FS */

Expand Down

0 comments on commit a308da1

Please sign in to comment.