diff options
Diffstat (limited to 'net/key')
-rw-r--r-- | net/key/af_key.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c index 45c3c27d279a..162fcea3324c 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -3782,6 +3782,29 @@ done: | |||
3782 | 3782 | ||
3783 | return len; | 3783 | return len; |
3784 | } | 3784 | } |
3785 | |||
3786 | static int pfkey_init_proc(void) | ||
3787 | { | ||
3788 | if (create_proc_read_entry("pfkey", 0, init_net.proc_net, | ||
3789 | pfkey_read_proc, NULL) == NULL) | ||
3790 | return -ENOMEM; | ||
3791 | else | ||
3792 | return 0; | ||
3793 | } | ||
3794 | |||
3795 | static void pfkey_exit_proc(void) | ||
3796 | { | ||
3797 | remove_proc_entry("net/pfkey", NULL); | ||
3798 | } | ||
3799 | #else | ||
3800 | static inline int pfkey_init_proc(void) | ||
3801 | { | ||
3802 | return 0; | ||
3803 | } | ||
3804 | |||
3805 | static inline void pfkey_exit_proc(void) | ||
3806 | { | ||
3807 | } | ||
3785 | #endif | 3808 | #endif |
3786 | 3809 | ||
3787 | static struct xfrm_mgr pfkeyv2_mgr = | 3810 | static struct xfrm_mgr pfkeyv2_mgr = |
@@ -3798,7 +3821,7 @@ static struct xfrm_mgr pfkeyv2_mgr = | |||
3798 | static void __exit ipsec_pfkey_exit(void) | 3821 | static void __exit ipsec_pfkey_exit(void) |
3799 | { | 3822 | { |
3800 | xfrm_unregister_km(&pfkeyv2_mgr); | 3823 | xfrm_unregister_km(&pfkeyv2_mgr); |
3801 | remove_proc_entry("pfkey", init_net.proc_net); | 3824 | pfkey_exit_proc(); |
3802 | sock_unregister(PF_KEY); | 3825 | sock_unregister(PF_KEY); |
3803 | proto_unregister(&key_proto); | 3826 | proto_unregister(&key_proto); |
3804 | } | 3827 | } |
@@ -3813,21 +3836,17 @@ static int __init ipsec_pfkey_init(void) | |||
3813 | err = sock_register(&pfkey_family_ops); | 3836 | err = sock_register(&pfkey_family_ops); |
3814 | if (err != 0) | 3837 | if (err != 0) |
3815 | goto out_unregister_key_proto; | 3838 | goto out_unregister_key_proto; |
3816 | #ifdef CONFIG_PROC_FS | 3839 | err = pfkey_init_proc(); |
3817 | err = -ENOMEM; | 3840 | if (err != 0) |
3818 | if (create_proc_read_entry("pfkey", 0, init_net.proc_net, pfkey_read_proc, NULL) == NULL) | ||
3819 | goto out_sock_unregister; | 3841 | goto out_sock_unregister; |
3820 | #endif | ||
3821 | err = xfrm_register_km(&pfkeyv2_mgr); | 3842 | err = xfrm_register_km(&pfkeyv2_mgr); |
3822 | if (err != 0) | 3843 | if (err != 0) |
3823 | goto out_remove_proc_entry; | 3844 | goto out_remove_proc_entry; |
3824 | out: | 3845 | out: |
3825 | return err; | 3846 | return err; |
3826 | out_remove_proc_entry: | 3847 | out_remove_proc_entry: |
3827 | #ifdef CONFIG_PROC_FS | 3848 | pfkey_exit_proc(); |
3828 | remove_proc_entry("net/pfkey", NULL); | ||
3829 | out_sock_unregister: | 3849 | out_sock_unregister: |
3830 | #endif | ||
3831 | sock_unregister(PF_KEY); | 3850 | sock_unregister(PF_KEY); |
3832 | out_unregister_key_proto: | 3851 | out_unregister_key_proto: |
3833 | proto_unregister(&key_proto); | 3852 | proto_unregister(&key_proto); |