diff options
Diffstat (limited to 'net/ipv6/reassembly.c')
-rw-r--r-- | net/ipv6/reassembly.c | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index a60d7d129713..6ab957ec2dd6 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: reassembly.c,v 1.26 2001/03/07 22:00:57 davem Exp $ | ||
9 | * | ||
10 | * Based on: net/ipv4/ip_fragment.c | 8 | * Based on: net/ipv4/ip_fragment.c |
11 | * | 9 | * |
12 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
@@ -634,7 +632,7 @@ static struct inet6_protocol frag_protocol = | |||
634 | }; | 632 | }; |
635 | 633 | ||
636 | #ifdef CONFIG_SYSCTL | 634 | #ifdef CONFIG_SYSCTL |
637 | static struct ctl_table ip6_frags_ctl_table[] = { | 635 | static struct ctl_table ip6_frags_ns_ctl_table[] = { |
638 | { | 636 | { |
639 | .ctl_name = NET_IPV6_IP6FRAG_HIGH_THRESH, | 637 | .ctl_name = NET_IPV6_IP6FRAG_HIGH_THRESH, |
640 | .procname = "ip6frag_high_thresh", | 638 | .procname = "ip6frag_high_thresh", |
@@ -660,6 +658,10 @@ static struct ctl_table ip6_frags_ctl_table[] = { | |||
660 | .proc_handler = &proc_dointvec_jiffies, | 658 | .proc_handler = &proc_dointvec_jiffies, |
661 | .strategy = &sysctl_jiffies, | 659 | .strategy = &sysctl_jiffies, |
662 | }, | 660 | }, |
661 | { } | ||
662 | }; | ||
663 | |||
664 | static struct ctl_table ip6_frags_ctl_table[] = { | ||
663 | { | 665 | { |
664 | .ctl_name = NET_IPV6_IP6FRAG_SECRET_INTERVAL, | 666 | .ctl_name = NET_IPV6_IP6FRAG_SECRET_INTERVAL, |
665 | .procname = "ip6frag_secret_interval", | 667 | .procname = "ip6frag_secret_interval", |
@@ -672,21 +674,20 @@ static struct ctl_table ip6_frags_ctl_table[] = { | |||
672 | { } | 674 | { } |
673 | }; | 675 | }; |
674 | 676 | ||
675 | static int ip6_frags_sysctl_register(struct net *net) | 677 | static int ip6_frags_ns_sysctl_register(struct net *net) |
676 | { | 678 | { |
677 | struct ctl_table *table; | 679 | struct ctl_table *table; |
678 | struct ctl_table_header *hdr; | 680 | struct ctl_table_header *hdr; |
679 | 681 | ||
680 | table = ip6_frags_ctl_table; | 682 | table = ip6_frags_ns_ctl_table; |
681 | if (net != &init_net) { | 683 | if (net != &init_net) { |
682 | table = kmemdup(table, sizeof(ip6_frags_ctl_table), GFP_KERNEL); | 684 | table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL); |
683 | if (table == NULL) | 685 | if (table == NULL) |
684 | goto err_alloc; | 686 | goto err_alloc; |
685 | 687 | ||
686 | table[0].data = &net->ipv6.frags.high_thresh; | 688 | table[0].data = &net->ipv6.frags.high_thresh; |
687 | table[1].data = &net->ipv6.frags.low_thresh; | 689 | table[1].data = &net->ipv6.frags.low_thresh; |
688 | table[2].data = &net->ipv6.frags.timeout; | 690 | table[2].data = &net->ipv6.frags.timeout; |
689 | table[3].mode &= ~0222; | ||
690 | } | 691 | } |
691 | 692 | ||
692 | hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table); | 693 | hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table); |
@@ -703,7 +704,7 @@ err_alloc: | |||
703 | return -ENOMEM; | 704 | return -ENOMEM; |
704 | } | 705 | } |
705 | 706 | ||
706 | static void ip6_frags_sysctl_unregister(struct net *net) | 707 | static void ip6_frags_ns_sysctl_unregister(struct net *net) |
707 | { | 708 | { |
708 | struct ctl_table *table; | 709 | struct ctl_table *table; |
709 | 710 | ||
@@ -711,13 +712,36 @@ static void ip6_frags_sysctl_unregister(struct net *net) | |||
711 | unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr); | 712 | unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr); |
712 | kfree(table); | 713 | kfree(table); |
713 | } | 714 | } |
715 | |||
716 | static struct ctl_table_header *ip6_ctl_header; | ||
717 | |||
718 | static int ip6_frags_sysctl_register(void) | ||
719 | { | ||
720 | ip6_ctl_header = register_net_sysctl_rotable(net_ipv6_ctl_path, | ||
721 | ip6_frags_ctl_table); | ||
722 | return ip6_ctl_header == NULL ? -ENOMEM : 0; | ||
723 | } | ||
724 | |||
725 | static void ip6_frags_sysctl_unregister(void) | ||
726 | { | ||
727 | unregister_net_sysctl_table(ip6_ctl_header); | ||
728 | } | ||
714 | #else | 729 | #else |
715 | static inline int ip6_frags_sysctl_register(struct net *net) | 730 | static inline int ip6_frags_ns_sysctl_register(struct net *net) |
716 | { | 731 | { |
717 | return 0; | 732 | return 0; |
718 | } | 733 | } |
719 | 734 | ||
720 | static inline void ip6_frags_sysctl_unregister(struct net *net) | 735 | static inline void ip6_frags_ns_sysctl_unregister(struct net *net) |
736 | { | ||
737 | } | ||
738 | |||
739 | static inline int ip6_frags_sysctl_register(void) | ||
740 | { | ||
741 | return 0; | ||
742 | } | ||
743 | |||
744 | static inline void ip6_frags_sysctl_unregister(void) | ||
721 | { | 745 | { |
722 | } | 746 | } |
723 | #endif | 747 | #endif |
@@ -730,12 +754,12 @@ static int ipv6_frags_init_net(struct net *net) | |||
730 | 754 | ||
731 | inet_frags_init_net(&net->ipv6.frags); | 755 | inet_frags_init_net(&net->ipv6.frags); |
732 | 756 | ||
733 | return ip6_frags_sysctl_register(net); | 757 | return ip6_frags_ns_sysctl_register(net); |
734 | } | 758 | } |
735 | 759 | ||
736 | static void ipv6_frags_exit_net(struct net *net) | 760 | static void ipv6_frags_exit_net(struct net *net) |
737 | { | 761 | { |
738 | ip6_frags_sysctl_unregister(net); | 762 | ip6_frags_ns_sysctl_unregister(net); |
739 | inet_frags_exit_net(&net->ipv6.frags, &ip6_frags); | 763 | inet_frags_exit_net(&net->ipv6.frags, &ip6_frags); |
740 | } | 764 | } |
741 | 765 | ||
@@ -752,7 +776,13 @@ int __init ipv6_frag_init(void) | |||
752 | if (ret) | 776 | if (ret) |
753 | goto out; | 777 | goto out; |
754 | 778 | ||
755 | register_pernet_subsys(&ip6_frags_ops); | 779 | ret = ip6_frags_sysctl_register(); |
780 | if (ret) | ||
781 | goto err_sysctl; | ||
782 | |||
783 | ret = register_pernet_subsys(&ip6_frags_ops); | ||
784 | if (ret) | ||
785 | goto err_pernet; | ||
756 | 786 | ||
757 | ip6_frags.hashfn = ip6_hashfn; | 787 | ip6_frags.hashfn = ip6_hashfn; |
758 | ip6_frags.constructor = ip6_frag_init; | 788 | ip6_frags.constructor = ip6_frag_init; |
@@ -765,11 +795,18 @@ int __init ipv6_frag_init(void) | |||
765 | inet_frags_init(&ip6_frags); | 795 | inet_frags_init(&ip6_frags); |
766 | out: | 796 | out: |
767 | return ret; | 797 | return ret; |
798 | |||
799 | err_pernet: | ||
800 | ip6_frags_sysctl_unregister(); | ||
801 | err_sysctl: | ||
802 | inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); | ||
803 | goto out; | ||
768 | } | 804 | } |
769 | 805 | ||
770 | void ipv6_frag_exit(void) | 806 | void ipv6_frag_exit(void) |
771 | { | 807 | { |
772 | inet_frags_fini(&ip6_frags); | 808 | inet_frags_fini(&ip6_frags); |
809 | ip6_frags_sysctl_unregister(); | ||
773 | unregister_pernet_subsys(&ip6_frags_ops); | 810 | unregister_pernet_subsys(&ip6_frags_ops); |
774 | inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); | 811 | inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT); |
775 | } | 812 | } |