Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1541281pxk; Tue, 1 Sep 2020 00:57:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOkWkA/mfc54spQOW634BMz2QR90eDTT/Ut0HPI51tlnbG0ASb8VOPvequydOoOpG9hMO8 X-Received: by 2002:a17:906:1b:: with SMTP id 27mr371373eja.517.1598947071282; Tue, 01 Sep 2020 00:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598947071; cv=none; d=google.com; s=arc-20160816; b=hVyhte4rNduYiOVus4mlenzwi701ZwNQxarrPPNtjywZU/P0V1CcO95A0NBQHSEb+8 Ub4BArHWa+aTmsvXn0e99QK1sJ+vK5nJJvZEVnR4vOvAZdO9SrrCKBsmV2K4jREna4f4 UDyAGOJI96Dowg5Z13JuAScmYnhb82ENsUUcMl1ljvtDshofgrDthxeK/e8UTH9pSoPy 1pR6nht5SLpvUXYaswpeSIP5MebhSk9ar31x5euBMh0XkiHgML8PqB9MYbJlTb1X+voV AeL0Iq5JdAr7Kh1UYyzCmPi5OGLMkCJxvVeFdD6SaMgy1PN87KzrTB30j+TmZLdfs428 0Frg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TEWosj+T/FRGHSF9tH65GTqlEJ9j3rwP8Dj/lqmsNo8=; b=Z3gQkLEd0cm3Er6pnrNGs9y6kKb/cIxCPjjK29JBfHADK+30ebSc6hO9ocPEz22UtW S/Bvmx2aS/1KoYi9D1oN6vaLEM6ZQ21SPvDYmIYqn+/E7LEH0Nrq2CAOKVVt72icPanQ Ft4Morib20qh9Zcy/H3jWIFebN1U5saha/CyHqcQXOz68EJ7rghO/M/SVKwsEgTd8CAI /dvA5YFBQ5SqnFnYkDQ8ydwZ/y579ai/kCXIk5pJsS0UIfDZblmZ9CwWAoZtSG6SGAzx iKbTQXI808ogSjk4uwRcL0D5sQOSe8mOxd9ELRCnzpExADMwlpUEmpP+9IKMrZ6Z/UEa Rs6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ILDt4bQb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c20si263802ejm.28.2020.09.01.00.57.28; Tue, 01 Sep 2020 00:57:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ILDt4bQb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727924AbgIAH4n (ORCPT + 99 others); Tue, 1 Sep 2020 03:56:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgIAH4l (ORCPT ); Tue, 1 Sep 2020 03:56:41 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6485C061244 for ; Tue, 1 Sep 2020 00:56:40 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id e14so397102ile.6 for ; Tue, 01 Sep 2020 00:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TEWosj+T/FRGHSF9tH65GTqlEJ9j3rwP8Dj/lqmsNo8=; b=ILDt4bQbXAm2fNXcqA27lrOZxCdF/zXdcbjLA74g0gZSpUOh8srrDHs5dzuCQ7hpe+ a6tLJfBYvF97GfS6EwZzZMMSavbQ1TDHuI24//IQx5nRolW+H8zunuG3uAYt51D8KTkX 2bWTazW6q3DUO9ehNgEb3gmWhuNS34HJDqph80nZL5JImd7vgyl4PKlYRkeQ3TRFdIs4 D7sAAdTh2pIFg9shiHyc4n9cjyGqjPX7nTPNt1EpQCSyKi46f3dW+0tH7Dv2ksNKwpBS 7fryGzuHI8VefQ7r+EwAW1hd/jEaXwbSJZ3j4vg6hHL5edpCf0nC5fw17aMwYJtv7NXT Mh1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TEWosj+T/FRGHSF9tH65GTqlEJ9j3rwP8Dj/lqmsNo8=; b=HOMwin+NQFdqiu2RE9MY3ShcmRuqTOLycJmayHpvKK0nK3F3qBkzlImo/zKdPYN7I5 WkKSUAcQFQdOdGSB1gldOY/uoI7o51H0WEj6NJVGqy2Fhew2VGlOQvarD/iYk5K/b9Fe OS9/GUvzd0py9Axx5PJqpKrjFeJFux8IIh2ci+/pxpD+EMUVSAfgbJwk9dq2huorlepA EQ5ug2OoBrLun1jrKfWKSPvzpJO1M+KinGF2WjhjA/Rn4jekVd0iGabxOLNs5PcA5LZ2 0kJGkPVE8xEy2rcdrRKj2KPo7vHtELFTsUF+mG8DgLejt5WPDscAr3/++nLDBgCeNxSG gjDA== X-Gm-Message-State: AOAM530fy+dLy1lVO5z7wiVHsGJC/Y/ZySa/Vqcjqkv1yXwdgqWaFiCw Zr6LlGztZR9lYR//drw4VyO7MM5StzpryZX5xoXgxA== X-Received: by 2002:a92:4001:: with SMTP id n1mr310227ila.69.1598947000122; Tue, 01 Sep 2020 00:56:40 -0700 (PDT) MIME-Version: 1.0 References: <20200901065758.1141786-1-brianvv@google.com> In-Reply-To: <20200901065758.1141786-1-brianvv@google.com> From: Eric Dumazet Date: Tue, 1 Sep 2020 09:56:28 +0200 Message-ID: Subject: Re: [PATCH] net: ipv6: fix __rt6_purge_dflt_routers when forwarding is not set on all ifaces To: Brian Vazquez Cc: Brian Vazquez , "David S . Miller" , LKML , netdev , David Ahern 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 On Tue, Sep 1, 2020 at 8:58 AM Brian Vazquez wrote: > > The problem is exposed when the system has multiple ifaces and > forwarding is enabled on a subset of them, __rt6_purge_dflt_routers will > clean the default route on all the ifaces which is not desired. > > This patches fixes that by cleaning only the routes where the iface has > forwarding enabled. > > Fixes: 830218c1add1 ("net: ipv6: Fix processing of RAs in presence of VRF") > Cc: David Ahern > Signed-off-by: Brian Vazquez > --- > net/ipv6/route.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index 5e7e25e2523a..41181cd489ea 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -4283,6 +4283,7 @@ static void __rt6_purge_dflt_routers(struct net *net, > struct fib6_table *table) > { > struct fib6_info *rt; > + bool deleted = false; > > restart: > rcu_read_lock(); > @@ -4291,16 +4292,19 @@ static void __rt6_purge_dflt_routers(struct net *net, > struct inet6_dev *idev = dev ? __in6_dev_get(dev) : NULL; > > if (rt->fib6_flags & (RTF_DEFAULT | RTF_ADDRCONF) && > - (!idev || idev->cnf.accept_ra != 2) && > + (!idev || (idev->cnf.forwarding == 1 && > + idev->cnf.accept_ra != 2)) && > fib6_info_hold_safe(rt)) { > rcu_read_unlock(); > ip6_del_rt(net, rt, false); > + deleted = true; > goto restart; > } > } > rcu_read_unlock(); > > - table->flags &= ~RT6_TABLE_HAS_DFLT_ROUTER; > + if (deleted) > + table->flags &= ~RT6_TABLE_HAS_DFLT_ROUTER; This seems wrong : We want to keep the flag set if at least one candidate route has not been deleted, so that next time rt6_purge_dflt_routers() is called, we can call __rt6_purge_dflt_routers() ?