From patchwork Thu Dec 15 22:03:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 131757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id D45171007D6 for ; Fri, 16 Dec 2011 09:04:01 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1RbJP1-00007l-OF; Thu, 15 Dec 2011 22:03:47 +0000 Received: from mail.tpi.com ([70.99.223.143]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1RbJOy-00007g-OV for kernel-team@lists.ubuntu.com; Thu, 15 Dec 2011 22:03:45 +0000 Received: from [10.0.2.5] (host-174-45-40-59.gdj-co.client.bresnan.net [174.45.40.59]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mail.tpi.com (Postfix) with ESMTP id 4BE9E305C89; Thu, 15 Dec 2011 14:03:42 -0800 (PST) Message-ID: <4EEA6EB7.4040103@canonical.com> Date: Thu, 15 Dec 2011 15:03:35 -0700 From: Tim Gardner User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110921 Thunderbird/3.1.15 MIME-Version: 1.0 To: Mathieu Trudel-Lapierre Subject: Re: [PATCH] ipv6: make the net.ipv6.conf.all.use_tempaddr sysctl propagate to interface settings References: <4EEA2C58.2040808@canonical.com> In-Reply-To: Cc: kernel-team@lists.ubuntu.com, Mathieu Trudel-Lapierre X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com On 12/15/2011 12:10 PM, Mathieu Trudel-Lapierre wrote: > On Thu, Dec 15, 2011 at 12:20 PM, Tim Gardner wrote: >> What kernel is this supposed to apply to? > > It was made against 3.2.0-4.10 (using ubuntu-precise.git) and tested > against Linus' linux-2.6.git. Turns out the patch was mangled by my > email client, so I've put it on > http://people.ubuntu.com/~mathieu-tl/0001-ipv6-make-the-net.ipv6.conf.all.use_tempaddr-sysctl-.patch > . > > Mathieu Trudel-Lapierre > Freenode: cyphermox, Jabber: mathieu.tl@gmail.com > 4096R/EE018C93 1967 8F7D 03A1 8F38 732E FF82 C126 33E1 EE01 8C93 How about this? I added a bit of error recovery in addrconf_sysctl_tempaddr() and simplified the logic in addrconf_use_tempaddr(). rtg From 7f40d4617865fdfcbee2894fcf9f06f2eb3b9575 Mon Sep 17 00:00:00 2001 From: Mathieu Trudel-Lapierre Date: Thu, 15 Dec 2011 13:39:03 -0500 Subject: [PATCH] ipv6: make the net.ipv6.conf.all.use_tempaddr sysctl propagate to interface settings The description for IPV6_PRIVACY mentions using .../all/use_tempaddr to enable IPv6 Privacy Extensions, and IP sysctl documentation mentions 'all' as setting all interface-specific settings. We make sure at least use_tempaddr actually works as documented. Signed-off-by: Mathieu Trudel-Lapierre --- net/ipv6/addrconf.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 83 insertions(+), 1 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index cf88df8..77ef901 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -4340,6 +4340,88 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write, return ret; } +#ifdef CONFIG_IPV6_PRIVACY +static void dev_tempaddr_change(struct inet6_dev *idev) +{ + if (!idev || !idev->dev) + return; + + if (idev->cnf.disable_ipv6) + addrconf_notify(NULL, NETDEV_DOWN, idev->dev); + else + addrconf_notify(NULL, NETDEV_UP, idev->dev); +} + +static void addrconf_tempaddr_change(struct net *net, __s32 newf) +{ + struct net_device *dev; + struct inet6_dev *idev; + + rcu_read_lock(); + for_each_netdev_rcu(net, dev) { + idev = __in6_dev_get(dev); + if (idev) { + int changed = (!idev->cnf.use_tempaddr) ^ (!newf); + idev->cnf.use_tempaddr = newf; + if (changed) + dev_tempaddr_change(idev); + } + } + rcu_read_unlock(); +} + +static int addrconf_use_tempaddr(struct ctl_table *table, int *p, int old) +{ + struct net *net; + + net = (struct net *)table->extra2; + + if (!net || p == &net->ipv6.devconf_dflt->use_tempaddr) + return 0; + + if (!rtnl_trylock()) { + /* Restore the original values before restarting */ + *p = old; + return restart_syscall(); + } + + if (p == &net->ipv6.devconf_all->use_tempaddr) { + net->ipv6.devconf_dflt->use_tempaddr = *p; + addrconf_tempaddr_change(net, *p); + } else if (*p != old) + dev_tempaddr_change((struct inet6_dev *)table->extra1); + + rtnl_unlock(); + return 0; +} + +static +int addrconf_sysctl_tempaddr(ctl_table *ctl, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + int *valp = ctl->data; + int old = *valp; + loff_t pos = *ppos; + int ret; + + ret = proc_dointvec(ctl, write, buffer, lenp, ppos); + if (ret) + goto out; + + *valp = !!(*valp); /* 0 or 1 */ + + if (write) + ret = addrconf_use_tempaddr(ctl, valp, old); + +out: + if (ret) { + *valp = old; + *ppos = pos; + } + return ret; +} +#endif + static struct addrconf_sysctl_table { struct ctl_table_header *sysctl_header; @@ -4431,7 +4513,7 @@ static struct addrconf_sysctl_table .data = &ipv6_devconf.use_tempaddr, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = addrconf_sysctl_tempaddr, }, { .procname = "temp_valid_lft", -- 1.7.0.4