diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2008-11-25 20:59:00 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-25 20:59:00 -0500 |
commit | 7013ec30e0e2bc5b1e602e19a4e0668f9b7c0a72 (patch) | |
tree | 7d46a9330d52d8cd9b4b737ffda7ea291c831446 | |
parent | 07fb0f1799dcb6b3df527909811fd6704278842e (diff) |
netns PF_KEY: per-netns /proc/pfkey
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/key/af_key.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index bb78ef972d1b..f8bd8df5e257 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -3673,7 +3673,7 @@ static int pfkey_seq_show(struct seq_file *f, void *v) | |||
3673 | 3673 | ||
3674 | static void *pfkey_seq_start(struct seq_file *f, loff_t *ppos) | 3674 | static void *pfkey_seq_start(struct seq_file *f, loff_t *ppos) |
3675 | { | 3675 | { |
3676 | struct net *net = &init_net; | 3676 | struct net *net = seq_file_net(f); |
3677 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 3677 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
3678 | struct sock *s; | 3678 | struct sock *s; |
3679 | struct hlist_node *node; | 3679 | struct hlist_node *node; |
@@ -3692,7 +3692,7 @@ static void *pfkey_seq_start(struct seq_file *f, loff_t *ppos) | |||
3692 | 3692 | ||
3693 | static void *pfkey_seq_next(struct seq_file *f, void *v, loff_t *ppos) | 3693 | static void *pfkey_seq_next(struct seq_file *f, void *v, loff_t *ppos) |
3694 | { | 3694 | { |
3695 | struct net *net = &init_net; | 3695 | struct net *net = seq_file_net(f); |
3696 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 3696 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
3697 | 3697 | ||
3698 | ++*ppos; | 3698 | ++*ppos; |
@@ -3715,38 +3715,39 @@ static struct seq_operations pfkey_seq_ops = { | |||
3715 | 3715 | ||
3716 | static int pfkey_seq_open(struct inode *inode, struct file *file) | 3716 | static int pfkey_seq_open(struct inode *inode, struct file *file) |
3717 | { | 3717 | { |
3718 | return seq_open(file, &pfkey_seq_ops); | 3718 | return seq_open_net(inode, file, &pfkey_seq_ops, |
3719 | sizeof(struct seq_net_private)); | ||
3719 | } | 3720 | } |
3720 | 3721 | ||
3721 | static struct file_operations pfkey_proc_ops = { | 3722 | static struct file_operations pfkey_proc_ops = { |
3722 | .open = pfkey_seq_open, | 3723 | .open = pfkey_seq_open, |
3723 | .read = seq_read, | 3724 | .read = seq_read, |
3724 | .llseek = seq_lseek, | 3725 | .llseek = seq_lseek, |
3725 | .release = seq_release, | 3726 | .release = seq_release_net, |
3726 | }; | 3727 | }; |
3727 | 3728 | ||
3728 | static int pfkey_init_proc(void) | 3729 | static int __net_init pfkey_init_proc(struct net *net) |
3729 | { | 3730 | { |
3730 | struct proc_dir_entry *e; | 3731 | struct proc_dir_entry *e; |
3731 | 3732 | ||
3732 | e = proc_net_fops_create(&init_net, "pfkey", 0, &pfkey_proc_ops); | 3733 | e = proc_net_fops_create(net, "pfkey", 0, &pfkey_proc_ops); |
3733 | if (e == NULL) | 3734 | if (e == NULL) |
3734 | return -ENOMEM; | 3735 | return -ENOMEM; |
3735 | 3736 | ||
3736 | return 0; | 3737 | return 0; |
3737 | } | 3738 | } |
3738 | 3739 | ||
3739 | static void pfkey_exit_proc(void) | 3740 | static void pfkey_exit_proc(struct net *net) |
3740 | { | 3741 | { |
3741 | proc_net_remove(&init_net, "pfkey"); | 3742 | proc_net_remove(net, "pfkey"); |
3742 | } | 3743 | } |
3743 | #else | 3744 | #else |
3744 | static inline int pfkey_init_proc(void) | 3745 | static int __net_init pfkey_init_proc(struct net *net) |
3745 | { | 3746 | { |
3746 | return 0; | 3747 | return 0; |
3747 | } | 3748 | } |
3748 | 3749 | ||
3749 | static inline void pfkey_exit_proc(void) | 3750 | static void pfkey_exit_proc(struct net *net) |
3750 | { | 3751 | { |
3751 | } | 3752 | } |
3752 | #endif | 3753 | #endif |
@@ -3777,8 +3778,12 @@ static int __net_init pfkey_net_init(struct net *net) | |||
3777 | rv = net_assign_generic(net, pfkey_net_id, net_pfkey); | 3778 | rv = net_assign_generic(net, pfkey_net_id, net_pfkey); |
3778 | if (rv < 0) | 3779 | if (rv < 0) |
3779 | goto out_assign; | 3780 | goto out_assign; |
3781 | rv = pfkey_init_proc(net); | ||
3782 | if (rv < 0) | ||
3783 | goto out_proc; | ||
3780 | return 0; | 3784 | return 0; |
3781 | 3785 | ||
3786 | out_proc: | ||
3782 | out_assign: | 3787 | out_assign: |
3783 | kfree(net_pfkey); | 3788 | kfree(net_pfkey); |
3784 | out_kmalloc: | 3789 | out_kmalloc: |
@@ -3789,6 +3794,7 @@ static void __net_exit pfkey_net_exit(struct net *net) | |||
3789 | { | 3794 | { |
3790 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); | 3795 | struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id); |
3791 | 3796 | ||
3797 | pfkey_exit_proc(net); | ||
3792 | BUG_ON(!hlist_empty(&net_pfkey->table)); | 3798 | BUG_ON(!hlist_empty(&net_pfkey->table)); |
3793 | kfree(net_pfkey); | 3799 | kfree(net_pfkey); |
3794 | } | 3800 | } |
@@ -3802,7 +3808,6 @@ static void __exit ipsec_pfkey_exit(void) | |||
3802 | { | 3808 | { |
3803 | unregister_pernet_gen_subsys(pfkey_net_id, &pfkey_net_ops); | 3809 | unregister_pernet_gen_subsys(pfkey_net_id, &pfkey_net_ops); |
3804 | xfrm_unregister_km(&pfkeyv2_mgr); | 3810 | xfrm_unregister_km(&pfkeyv2_mgr); |
3805 | pfkey_exit_proc(); | ||
3806 | sock_unregister(PF_KEY); | 3811 | sock_unregister(PF_KEY); |
3807 | proto_unregister(&key_proto); | 3812 | proto_unregister(&key_proto); |
3808 | } | 3813 | } |
@@ -3817,12 +3822,9 @@ static int __init ipsec_pfkey_init(void) | |||
3817 | err = sock_register(&pfkey_family_ops); | 3822 | err = sock_register(&pfkey_family_ops); |
3818 | if (err != 0) | 3823 | if (err != 0) |
3819 | goto out_unregister_key_proto; | 3824 | goto out_unregister_key_proto; |
3820 | err = pfkey_init_proc(); | ||
3821 | if (err != 0) | ||
3822 | goto out_sock_unregister; | ||
3823 | err = xfrm_register_km(&pfkeyv2_mgr); | 3825 | err = xfrm_register_km(&pfkeyv2_mgr); |
3824 | if (err != 0) | 3826 | if (err != 0) |
3825 | goto out_remove_proc_entry; | 3827 | goto out_sock_unregister; |
3826 | err = register_pernet_gen_subsys(&pfkey_net_id, &pfkey_net_ops); | 3828 | err = register_pernet_gen_subsys(&pfkey_net_id, &pfkey_net_ops); |
3827 | if (err != 0) | 3829 | if (err != 0) |
3828 | goto out_xfrm_unregister_km; | 3830 | goto out_xfrm_unregister_km; |
@@ -3830,8 +3832,6 @@ out: | |||
3830 | return err; | 3832 | return err; |
3831 | out_xfrm_unregister_km: | 3833 | out_xfrm_unregister_km: |
3832 | xfrm_unregister_km(&pfkeyv2_mgr); | 3834 | xfrm_unregister_km(&pfkeyv2_mgr); |
3833 | out_remove_proc_entry: | ||
3834 | pfkey_exit_proc(); | ||
3835 | out_sock_unregister: | 3835 | out_sock_unregister: |
3836 | sock_unregister(PF_KEY); | 3836 | sock_unregister(PF_KEY); |
3837 | out_unregister_key_proto: | 3837 | out_unregister_key_proto: |