From patchwork Tue Apr 1 09:30:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Yanjun X-Patchwork-Id: 335727 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 CF87714009D for ; Tue, 1 Apr 2014 20:30:54 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751450AbaDAJa3 (ORCPT ); Tue, 1 Apr 2014 05:30:29 -0400 Received: from mail-qc0-f175.google.com ([209.85.216.175]:46514 "EHLO mail-qc0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751089AbaDAJa1 (ORCPT ); Tue, 1 Apr 2014 05:30:27 -0400 Received: by mail-qc0-f175.google.com with SMTP id e16so10177473qcx.6 for ; Tue, 01 Apr 2014 02:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type; bh=Sd9sE51b+QidjLM8loMu4MrBEjlv1kbh/GyxqyFH7eE=; b=v1yhDJKabkzlwwNcqypuDvJwbS1C9UZT+NGOUcLF54a9opw1cb4Zun27WbV38rR/WL pJaHpw5PpVjqWqxtf5CUbo0VHUDcZAHlo/yJf6IHX0BOdVEbCh3yP0LJ1RJyy1KAPjX6 TFKj2hi2f4Ahhf560VAqqfkQTfx9qVOOI1Tb7xI9D1K4yZPbaOHfd8XRYqM7IKRZFTrN sHIuQ5jHOA5AEJRZWOPW0pLtOgWq/+0UTFBP0ex2eK29rLDxpOEKDPQWHjgPEX8prj7Q JX3OUm75+YKEdO1eIlb7Uc5eCsMO7Fys3QE0DL/VUolE7XTdd25RmEv7lCzMBK4dhotl 9SoA== X-Received: by 10.140.16.198 with SMTP id 64mr31978311qgb.10.1396344626662; Tue, 01 Apr 2014 02:30:26 -0700 (PDT) Received: from [128.224.162.224] ([1.202.252.122]) by mx.google.com with ESMTPSA id x8sm33756425qat.36.2014.04.01.02.30.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 01 Apr 2014 02:30:25 -0700 (PDT) Message-ID: <533A8737.8050108@gmail.com> Date: Tue, 01 Apr 2014 17:30:31 +0800 From: zhuyj User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Paul Gortmaker CC: zhuyj , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: ipv6:remove ipv6 global address after the interface is down Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi, Paul With kernel 2.6.34.x, the following problem will appear. TargetA ------------------------- TargetB 3000::1/64 3000::2/64 TargetA - bring the interface down by doing an "ifconfig eth1 down" - bring the interface back up by doing an "ifconfig eth1 up" TargetB - ping6 3000::1 ping6 succeeds the first time - after bringing the interface on TargetA down and then back up, ping6 to the interface fails. With the latest mainline kernel(3.4+), this problem is resolved. When eth1 is down, ipv6 address and route item are removed. But with kernel 2.6.34.x, when eth1 is down, ipv6 address remains while route item is removed. So when eth1 is up and assign the previous ipv6 address, with 2.6.34.x, some errors will appear. But with latest mainline kernel, it can work well. So I made a patch to fix this problem in kernel 2.6.34.x. Please merge this to kernel2.6.34.x. Thanks a lot. Zhu Yanjun From 4eb7dd9180bcbd7b8196f9e5e6f5db638de799e7 Mon Sep 17 00:00:00 2001 From: yanjun.zhu Date: Tue, 1 Apr 2014 17:09:11 +0800 Subject: [PATCH 1/1] ipv6:remove ipv6 global address after the interface is down 2.6.34.x kernels require a similar logic change as commit 73a8bd74 [ipv6:Revert 'administrative down' address handling changes] introduces for newer kernels. In 2.6.34.x kernels, when an interface with ipv6 global address is restarted, the ipv6 route item disappear, but ipv6 global address still remains. Compared with kernel versions 3.4+, the ipv6 global address and route item should both disappear. To be consistent with kernel versions 3.4+, we remove ipv6 address from the interface that is shutdown. Signed-off-by: yanjun.zhu --- net/ipv6/addrconf.c | 39 ++++----------------------------------- 1 files changed, 4 insertions(+), 35 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 2b82070..6fd29fb 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -2624,7 +2624,7 @@ static void addrconf_bonding_change(struct net_device *dev, unsigned long event) static int addrconf_ifdown(struct net_device *dev, int how) { struct inet6_dev *idev; - struct inet6_ifaddr *ifa, *keep_list, **bifa; + struct inet6_ifaddr *ifa, **bifa; struct net *net = dev_net(dev); int i; @@ -2657,9 +2657,7 @@ static int addrconf_ifdown(struct net_device *dev, int how) write_lock_bh(&addrconf_hash_lock); while ((ifa = *bifa) != NULL) { - if (ifa->idev == idev && - (how || !(ifa->flags&IFA_F_PERMANENT) || - ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) { + if (ifa->idev == idev){ *bifa = ifa->lst_next; ifa->lst_next = NULL; __in6_ifa_put(ifa); @@ -2698,40 +2696,12 @@ static int addrconf_ifdown(struct net_device *dev, int how) write_lock_bh(&idev->lock); } #endif - keep_list = NULL; - bifa = &keep_list; while ((ifa = idev->addr_list) != NULL) { idev->addr_list = ifa->if_next; ifa->if_next = NULL; addrconf_del_timer(ifa); - - /* If just doing link down, and address is permanent - and not link-local, then retain it. */ - if (how == 0 && - (ifa->flags&IFA_F_PERMANENT) && - !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) { - - /* Move to holding list */ - *bifa = ifa; - bifa = &ifa->if_next; - - /* If not doing DAD on this address, just keep it. */ - if ((dev->flags&(IFF_NOARP|IFF_LOOPBACK)) || - idev->cnf.accept_dad <= 0 || - (ifa->flags & IFA_F_NODAD)) - continue; - - /* If it was tentative already, no need to notify */ - if (ifa->flags & IFA_F_TENTATIVE) - continue; - - /* Flag it for later restoration when link comes up */ - ifa->flags |= IFA_F_TENTATIVE; - in6_ifa_hold(ifa); - } else { - ifa->dead = 1; - } + ifa->dead = 1; write_unlock_bh(&idev->lock); __ipv6_ifa_notify(RTM_DELADDR, ifa); @@ -2743,8 +2713,7 @@ static int addrconf_ifdown(struct net_device *dev, int how) write_lock_bh(&idev->lock); } - idev->addr_list = keep_list; - + idev->addr_list = NULL; write_unlock_bh(&idev->lock); /* Step 5: Discard multicast list */ -- 1.7.3.5