Received: by 10.223.176.5 with SMTP id f5csp702522wra; Fri, 9 Feb 2018 05:58:04 -0800 (PST) X-Google-Smtp-Source: AH8x227wfYn+2FtWKsG/QfR2u4SOwP9Wj5nVbkn+qSuvZHa2un7dhKth9RvwCT4fCUVmCg6+896Z X-Received: by 10.101.101.84 with SMTP id a20mr2472961pgw.163.1518184684077; Fri, 09 Feb 2018 05:58:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518184684; cv=none; d=google.com; s=arc-20160816; b=x7O7cZRB171ezEi+xriC8dQRUlltFOIGTQOi1DZ6SXbEFC06mBqMlE1QQdiIkSqsq5 aTWb0fAJ3TDGIjR+yYS/Ibge13aVX2rp6pukAE3hEXEWfUZHjkrfmuPrxtfM9YOVcO7j ej6vdoahJDJJO2tI9O8ZZyyHDndm0bNKQScdoyy+s5kollzT1rptcYzK9fgmgSJ3vH/D 8zvnvajhisFQwzKsg7mH3dRO3aE/wdS4oeyGMtxTH5dbzc5XJ/rwirQhJXEk9xoyD/4F TuJD6f8051yPOBLnDftWB4GnFcddM19ybSm1Wg61L1vAPrxEnHxFjJX5PLBIaH5l72Us RiYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hpR/APSAOPDHtagdRkAOR7XTPTVr5a9h60MamciQCYs=; b=NsoiIgB47Wk6eGjpJQ0nz+PO9vk9bfZgQ7N88dwVM8rPmtZT6qLSO6cmjA2PsqHuvZ JJzizKMUzeHaQ1rAVAwVVAm59vrhUikfj+SUs8WVtDKviVSwMU8c2v/0ZvZa9V52ub0p RQlTEMlQVjqWvMi+B+1x9jUf0Bj5JAY+eAwOfzKFxt2zxhN5/1nUq4uxjb5ElHyB7Yhk N7Wt//bHKU23IMAlOpzJ8n0CQap29WOspXQC4cNj8iRjR8IPJBwpbuLMCqGp/KjxOhMh BAGx8KXFxA9LFBxzGq9r4XPoHsbhy5CgGNp/2ycksnTd397QxMPGx6ebl3Zdryrq7t7t n/Gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x19si1416819pge.2.2018.02.09.05.57.50; Fri, 09 Feb 2018 05:58:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753573AbeBINpK (ORCPT + 99 others); Fri, 9 Feb 2018 08:45:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51718 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753550AbeBINpH (ORCPT ); Fri, 9 Feb 2018 08:45:07 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 47B88FF5; Fri, 9 Feb 2018 13:45:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vivek Venkatraman , David Ahern , "David S. Miller" Subject: [PATCH 4.14 12/22] net: ipv6: send unsolicited NA after DAD Date: Fri, 9 Feb 2018 14:40:01 +0100 Message-Id: <20180209133934.958616989@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133934.024795822@linuxfoundation.org> References: <20180209133934.024795822@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Ahern [ Upstream commit c76fe2d98c726224a975a0d0198c3fb50406d325 ] Unsolicited IPv6 neighbor advertisements should be sent after DAD completes. Update ndisc_send_unsol_na to skip tentative, non-optimistic addresses and have those sent by addrconf_dad_completed after DAD. Fixes: 4a6e3c5def13c ("net: ipv6: send unsolicited NA on admin up") Reported-by: Vivek Venkatraman Signed-off-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/addrconf.c | 30 ++++++++++++++++++++++++++---- net/ipv6/ndisc.c | 5 +++++ 2 files changed, 31 insertions(+), 4 deletions(-) --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -184,7 +184,8 @@ static struct rt6_info *addrconf_get_pre static void addrconf_dad_start(struct inet6_ifaddr *ifp); static void addrconf_dad_work(struct work_struct *w); -static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id); +static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id, + bool send_na); static void addrconf_dad_run(struct inet6_dev *idev); static void addrconf_rs_timer(unsigned long data); static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifa); @@ -3825,12 +3826,17 @@ static void addrconf_dad_begin(struct in idev->cnf.accept_dad < 1) || !(ifp->flags&IFA_F_TENTATIVE) || ifp->flags & IFA_F_NODAD) { + bool send_na = false; + + if (ifp->flags & IFA_F_TENTATIVE && + !(ifp->flags & IFA_F_OPTIMISTIC)) + send_na = true; bump_id = ifp->flags & IFA_F_TENTATIVE; ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); spin_unlock(&ifp->lock); read_unlock_bh(&idev->lock); - addrconf_dad_completed(ifp, bump_id); + addrconf_dad_completed(ifp, bump_id, send_na); return; } @@ -3959,16 +3965,21 @@ static void addrconf_dad_work(struct wor } if (ifp->dad_probes == 0) { + bool send_na = false; + /* * DAD was successful */ + if (ifp->flags & IFA_F_TENTATIVE && + !(ifp->flags & IFA_F_OPTIMISTIC)) + send_na = true; bump_id = ifp->flags & IFA_F_TENTATIVE; ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); spin_unlock(&ifp->lock); write_unlock_bh(&idev->lock); - addrconf_dad_completed(ifp, bump_id); + addrconf_dad_completed(ifp, bump_id, send_na); goto out; } @@ -4006,7 +4017,8 @@ static bool ipv6_lonely_lladdr(struct in return true; } -static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id) +static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id, + bool send_na) { struct net_device *dev = ifp->idev->dev; struct in6_addr lladdr; @@ -4038,6 +4050,16 @@ static void addrconf_dad_completed(struc if (send_mld) ipv6_mc_dad_complete(ifp->idev); + /* send unsolicited NA if enabled */ + if (send_na && + (ifp->idev->cnf.ndisc_notify || + dev_net(dev)->ipv6.devconf_all->ndisc_notify)) { + ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifp->addr, + /*router=*/ !!ifp->idev->cnf.forwarding, + /*solicited=*/ false, /*override=*/ true, + /*inc_opt=*/ true); + } + if (send_rs) { /* * If a host as already performed a random delay --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -558,6 +558,11 @@ static void ndisc_send_unsol_na(struct n read_lock_bh(&idev->lock); list_for_each_entry(ifa, &idev->addr_list, if_list) { + /* skip tentative addresses until dad completes */ + if (ifa->flags & IFA_F_TENTATIVE && + !(ifa->flags & IFA_F_OPTIMISTIC)) + continue; + ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifa->addr, /*router=*/ !!idev->cnf.forwarding, /*solicited=*/ false, /*override=*/ true,