aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_fragment.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-01-22 09:08:36 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:10:37 -0500
commite4a2d5c2bccd5bd29de5ae4f14ff4448fac9cfc8 (patch)
treee6ae6835ec20401b1a59de0c8c0f8519fba3a4b4 /net/ipv4/ip_fragment.c
parent6ddc082223ef0f73717b4133fa7e648842bbfd02 (diff)
[NETNS][FRAGS]: Duplicate sysctl tables for new namespaces.
Each namespace has to have own tables to tune their different parameters, so duplicate the tables and register them. All the tables in sub-namespaces are temporarily made read-only. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_fragment.c')
-rw-r--r--net/ipv4/ip_fragment.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 4f013343cef7..c51e1a11dc6b 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -661,17 +661,53 @@ static struct ctl_table ip4_frags_ctl_table[] = {
661 661
662static int ip4_frags_ctl_register(struct net *net) 662static int ip4_frags_ctl_register(struct net *net)
663{ 663{
664 struct ctl_table *table;
664 struct ctl_table_header *hdr; 665 struct ctl_table_header *hdr;
665 666
666 hdr = register_net_sysctl_table(net, net_ipv4_ctl_path, 667 table = ip4_frags_ctl_table;
667 ip4_frags_ctl_table); 668 if (net != &init_net) {
668 return hdr == NULL ? -ENOMEM : 0; 669 table = kmemdup(table, sizeof(ip4_frags_ctl_table), GFP_KERNEL);
670 if (table == NULL)
671 goto err_alloc;
672
673 table[0].mode &= ~0222;
674 table[1].mode &= ~0222;
675 table[2].mode &= ~0222;
676 table[3].mode &= ~0222;
677 table[4].mode &= ~0222;
678 }
679
680 hdr = register_net_sysctl_table(net, net_ipv4_ctl_path, table);
681 if (hdr == NULL)
682 goto err_reg;
683
684 net->ipv4.frags_hdr = hdr;
685 return 0;
686
687err_reg:
688 if (net != &init_net)
689 kfree(table);
690err_alloc:
691 return -ENOMEM;
692}
693
694static void ip4_frags_ctl_unregister(struct net *net)
695{
696 struct ctl_table *table;
697
698 table = net->ipv4.frags_hdr->ctl_table_arg;
699 unregister_net_sysctl_table(net->ipv4.frags_hdr);
700 kfree(table);
669} 701}
670#else 702#else
671static inline int ip4_frags_ctl_register(struct net *net) 703static inline int ip4_frags_ctl_register(struct net *net)
672{ 704{
673 return 0; 705 return 0;
674} 706}
707
708static inline void ip4_frags_ctl_unregister(struct net *net)
709{
710}
675#endif 711#endif
676 712
677static int ipv4_frags_init_net(struct net *net) 713static int ipv4_frags_init_net(struct net *net)