From patchwork Fri Feb 25 18:52:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucian Adrian Grijincu X-Patchwork-Id: 84558 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4C86DB70DE for ; Sat, 26 Feb 2011 05:54:45 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932641Ab1BYSyX (ORCPT ); Fri, 25 Feb 2011 13:54:23 -0500 Received: from mail-ew0-f46.google.com ([209.85.215.46]:41821 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756569Ab1BYSxW (ORCPT ); Fri, 25 Feb 2011 13:53:22 -0500 Received: by mail-ew0-f46.google.com with SMTP id 6so701263ewy.19 for ; Fri, 25 Feb 2011 10:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=9kfpRj2OFXGOyC6eicG6eWgKUXwGogdZxAjRviaZAdQ=; b=fZWQc2sww9boSPX1pQbNpisxlgXZ/eO979QU5MFi7d9OQtOpC7wVvwaDMJfkbpPMq4 k1kNLNsELrNhzEMYXgNjQqchU/O3f5Eczt1+TyR3ePsB6UjWI9Swj3beOXwDCwkGAjiK cGM8lEAgJP7aBs67TPMJ+5Bl2kNXOtfA+iFqE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=gnyzfskKMibGNIGmBn+TmHjIiEWZ/XHiKGHgrEWtayiJK/q4IXWnkTNcD9o2Gu3RNt eNh41wAfXD62HInEGz6FhwleM13racbRAHlAnLNj0tMkG2HJAbTx9OGRtAhv8uFUQmdA rmZv5Pigwd3V6TF0MPjsZJQwIWLHJdnzqfdIA= Received: by 10.213.19.6 with SMTP id y6mr2533658eba.86.1298660001144; Fri, 25 Feb 2011 10:53:21 -0800 (PST) Received: from localhost.localdomain (p22.eregie.pub.ro [141.85.0.122]) by mx.google.com with ESMTPS id b52sm863962eei.1.2011.02.25.10.53.19 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Feb 2011 10:53:20 -0800 (PST) From: Lucian Adrian Grijincu To: "David S. Miller" , Alexey Dobriyan , "Eric W. Biederman" , Octavian Purdila , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lucian Adrian Grijincu Subject: [PATCH 7/9] sysctl: ipv4: share ipv4_net_table between nets Date: Fri, 25 Feb 2011 20:52:39 +0200 Message-Id: <1298659961-23863-8-git-send-email-lucian.grijincu@gmail.com> X-Mailer: git-send-email 1.7.4.rc1.7.g2cf08.dirty In-Reply-To: <1298659961-23863-1-git-send-email-lucian.grijincu@gmail.com> References: <1298659961-23863-1-git-send-email-lucian.grijincu@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Lucian Adrian Grijincu --- net/ipv4/sysctl_net_ipv4.c | 53 +++++++------------------------------------ 1 files changed, 9 insertions(+), 44 deletions(-) diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 1a45665..6fd3279 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -636,49 +636,49 @@ static struct ctl_table ipv4_net_table[] = { .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = (proc_handler *) netns_proc_dointvec }, { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = (proc_handler *) netns_proc_dointvec }, { .procname = "icmp_ignore_bogus_error_responses", .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = (proc_handler *) netns_proc_dointvec }, { .procname = "icmp_errors_use_inbound_ifaddr", .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = (proc_handler *) netns_proc_dointvec }, { .procname = "icmp_ratelimit", .data = &init_net.ipv4.sysctl_icmp_ratelimit, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_ms_jiffies, + .proc_handler = (proc_handler *) netns_proc_dointvec_ms_jiffies, }, { .procname = "icmp_ratemask", .data = &init_net.ipv4.sysctl_icmp_ratemask, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = (proc_handler *) netns_proc_dointvec }, { .procname = "rt_cache_rebuild_count", .data = &init_net.ipv4.sysctl_rt_cache_rebuild_count, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = (proc_handler *) netns_proc_dointvec }, { } }; @@ -692,53 +692,18 @@ EXPORT_SYMBOL_GPL(net_ipv4_ctl_path); static __net_init int ipv4_sysctl_init_net(struct net *net) { - struct ctl_table *table; - - table = ipv4_net_table; - if (!net_eq(net, &init_net)) { - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL); - if (table == NULL) - goto err_alloc; - - table[0].data = - &net->ipv4.sysctl_icmp_echo_ignore_all; - table[1].data = - &net->ipv4.sysctl_icmp_echo_ignore_broadcasts; - table[2].data = - &net->ipv4.sysctl_icmp_ignore_bogus_error_responses; - table[3].data = - &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr; - table[4].data = - &net->ipv4.sysctl_icmp_ratelimit; - table[5].data = - &net->ipv4.sysctl_icmp_ratemask; - table[6].data = - &net->ipv4.sysctl_rt_cache_rebuild_count; - } - net->ipv4.sysctl_rt_cache_rebuild_count = 4; net->ipv4.ipv4_hdr = register_net_sysctl_table(net, - net_ipv4_ctl_path, table); + net_ipv4_ctl_path, ipv4_net_table); if (net->ipv4.ipv4_hdr == NULL) - goto err_reg; - + return -ENOMEM; return 0; - -err_reg: - if (!net_eq(net, &init_net)) - kfree(table); -err_alloc: - return -ENOMEM; } static __net_exit void ipv4_sysctl_exit_net(struct net *net) { - struct ctl_table *table; - - table = net->ipv4.ipv4_hdr->ctl_table_arg; unregister_net_sysctl_table(net->ipv4.ipv4_hdr); - kfree(table); } static __net_initdata struct pernet_operations ipv4_sysctl_ops = {