From patchwork Mon Apr 18 14:23:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Manning X-Patchwork-Id: 611753 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 3qpVkK3Y0dz9t3x for ; Tue, 19 Apr 2016 00:23:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751622AbcDROXf (ORCPT ); Mon, 18 Apr 2016 10:23:35 -0400 Received: from mx0b-000f0801.pphosted.com ([67.231.152.113]:9697 "EHLO mx0b-000f0801.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750717AbcDROXe (ORCPT ); Mon, 18 Apr 2016 10:23:34 -0400 Received: from pps.filterd (m0048192.ppops.net [127.0.0.1]) by mx0b-000f0801.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u3IEAeFh023908 for ; Mon, 18 Apr 2016 07:23:33 -0700 Received: from brmwp-exmb11.corp.brocade.com ([208.47.132.227]) by mx0b-000f0801.pphosted.com with ESMTP id 22bmp4uyd6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 18 Apr 2016 07:23:33 -0700 Received: from EMEAWP-EXMB12.corp.brocade.com (172.29.11.86) by BRMWP-EXMB11.corp.brocade.com (172.16.59.77) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Mon, 18 Apr 2016 08:23:31 -0600 Received: from [10.252.49.9] (10.252.49.9) by EMEAWP-EXMB12.corp.brocade.com (172.29.11.86) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Mon, 18 Apr 2016 16:23:28 +0200 Subject: [PATCH] net: ipv6: Do not fix up linklocal and loopback addresses References: <5711ADD1.2030904@brocade.com> From: Mike Manning To: X-Forwarded-Message-Id: <5711ADD1.2030904@brocade.com> Message-ID: <5714EDDB.8080306@brocade.com> Date: Mon, 18 Apr 2016 15:23:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 In-Reply-To: <5711ADD1.2030904@brocade.com> X-Originating-IP: [10.252.49.9] X-ClientProxiedBy: hq1wp-excas11.corp.brocade.com (10.70.36.102) To EMEAWP-EXMB12.corp.brocade.com (172.29.11.86) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-04-18_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1604180178 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org f1705ec197e7 "Make address flushing on ifdown optional" added the option to retain user configured addresses on an admin down. A comment to one of the later revisions suggested using the IFA_F_PERMANENT flag rather than adding a user_managed boolean to the ifaddr struct. A side effect of this change is that link local and loopback addresses were also retained which was not part of the objective of the original changes. The fix 70af921db6f8 "Do not keep linklocal and loopback addresses" ensures that these are no longer kept. Similarly, the present fix ensures that these addresses are not fixed up either, otherwise the incorrect fixup triggers a crash in fib6. Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional") Signed-off-by: Mike Manning Acked-by: David Ahern --- net/ipv6/addrconf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 23cec53..cba4e10 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -3200,6 +3200,12 @@ static void l3mdev_check_host_rt(struct inet6_dev *idev, } #endif +static bool addr_is_local(const struct in6_addr *addr) +{ + return ipv6_addr_type(addr) & + (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); +} + static int fixup_permanent_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp) { @@ -3238,6 +3244,7 @@ static void addrconf_permanent_addr(struct net_device *dev) list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) { if ((ifp->flags & IFA_F_PERMANENT) && + !addr_is_local(&ifp->addr) && fixup_permanent_addr(idev, ifp) < 0) { write_unlock_bh(&idev->lock); ipv6_del_addr(ifp); @@ -3448,12 +3455,6 @@ static void addrconf_type_change(struct net_device *dev, unsigned long event) ipv6_mc_unmap(idev); } -static bool addr_is_local(const struct in6_addr *addr) -{ - return ipv6_addr_type(addr) & - (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); -} - static int addrconf_ifdown(struct net_device *dev, int how) { struct net *net = dev_net(dev);