Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1854790pxk; Tue, 1 Sep 2020 09:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUWTII/Xic7gTuG0bHAKwyXn5c7cnZVL7AARBxWFU0iiCD8d6dT5ll1MTe92S9YARo0OBW X-Received: by 2002:a17:906:2acf:: with SMTP id m15mr2227899eje.257.1598977098089; Tue, 01 Sep 2020 09:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598977098; cv=none; d=google.com; s=arc-20160816; b=poQPA8II98iXePyEZLNc3tisZlEPzwXaGor8TB0//t9fIKZcujgGzCXV9+FSp5h4pk GeW05d4PSti+6xeHUlScuxvSOVNLexAuoiJUxoxZ5hYWNRiy0geUeXuy2eUpG/S/7Yjd z7T/OnYBLjoDCzQ6o/LjsOf148WHifeKrrg+rilbMgsOJhY5Lep+5dF+OYb7Zskgl6QU AS8XprDq6cTJSwCkjsNqh+zR1WLz5bahBGS+QmM555TeQADVVv3kpTpfpQbQahA25SpO iUVzzTZqXB9JnqeXF2MLjF2qdBUVs6+501wCMq6vef4qncfJQa+6cq5rA7YqQuUfdvxx GUOQ== 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=vstCf+2ozyYDDsY1FDuiQNquHfG3neT8y055PmuM2O4=; b=jhE4g9+hnYK/Aq/G3r1/HfnDva27W2/ZG+wi3evCn6trRwknBh1TJHKUb/p/y3wgUP G/GnvY9tz9aXeluRArxxd6ibrwIDM1gIgRcS0qXSrWVOQ+CreZtTcsBdYkknSikh/RRm +26eD3ZMUvRdXtrqgtyC6CAssTWopFgERBdoJbXLYFdnzr9rOCHrDYxkHPBBC85KXD2N Ay0Tuj0pCE4b1/YnOs/XPHYGt6szYnF9m+LR34NC7+I9ehvnrNB2IaR7+Slqcianh2j/ pOSkr8r03ipfsjwtb6dgo2u6vanJfiALOEvdSB9HMWTWpPfxIIdLXV0Y9Np4KdQSvqBq ZfVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DceVnRiq; 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 v23si912853ejf.312.2020.09.01.09.17.55; Tue, 01 Sep 2020 09:18:18 -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=DceVnRiq; 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 S1728140AbgIAPdq (ORCPT + 99 others); Tue, 1 Sep 2020 11:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731182AbgIAPdb (ORCPT ); Tue, 1 Sep 2020 11:33:31 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F0AC061244 for ; Tue, 1 Sep 2020 08:33:30 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id n133so1139855qkn.11 for ; Tue, 01 Sep 2020 08:33:30 -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=vstCf+2ozyYDDsY1FDuiQNquHfG3neT8y055PmuM2O4=; b=DceVnRiqW7Do8b5GQpw52IG+emIOhIDWDAfKAMJ6klO+x06NGJyGGwoGY0WUwCJqih rVmOe/L2DJLdEahYJ7ImE+LSgY0JKIbi8KNV8vJ/vOY5QWgvAlrP0PtbBkEtCdUJfHg+ jz2hObzZMkccKAZcyiNKyw3YQ+ydrrl1QjeRFpYVN7LniPOri8ZG1mysBLLjVXIusm51 Xj4xzhsadjkTVUU1Xg8Gl5/RBfeinJQTmY/HrBos9SSQhPATDNms2/xdHVic/L0TsbFh 3sy7c/fLmvu3aYxN7ULX8nNKD2uMbHdXhZQoSuD84sHUdawNw6gE7gQTaPPvQJGhJxvq YTfQ== 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=vstCf+2ozyYDDsY1FDuiQNquHfG3neT8y055PmuM2O4=; b=UT2ic1eU2zEOzg1LuJV4Egw3yoivB3s9poDL8z9aqHVXP5B1i6Ka2Q5tTMXVx9SL9e EM2CnQcnj+jKzC81Pwz5xVE2SGIv5E70A0V8XxPwzjkcMsoZwc8fvQeJSYV63348rMqy aa2Cxrql7y2DKyucYz/d3tEv1BUxq28RKFKfU42MOF+6e4Vgy30zzeNATITqL5gb32Iv nw6QdlSiBCXTpmDFeWonE9Lbq1I93EMR9tFIrWroxLMBuqVwOzI7f+o08bLq93M2w/nz UIWvPJ9+N/JLs2kdU9/d2uWAuglSLzESNRzqMwQQ7+e5MJocH0cQurGUiZkrdNu2Sflm tVnQ== X-Gm-Message-State: AOAM533p8Q/9Kkk/ubJaAs5CmIqgA2zKidgIhVhRxN0TeqZpvn2Ze3ve XmNcfmrwE+2/vsF7uRGNvWAqPrUw6bWvdsi+q/T9Eg== X-Received: by 2002:a05:620a:815:: with SMTP id s21mr2434910qks.0.1598974409692; Tue, 01 Sep 2020 08:33:29 -0700 (PDT) MIME-Version: 1.0 References: <20200901065758.1141786-1-brianvv@google.com> In-Reply-To: From: Brian Vazquez Date: Tue, 1 Sep 2020 08:33:17 -0700 Message-ID: Subject: Re: [PATCH] net: ipv6: fix __rt6_purge_dflt_routers when forwarding is not set on all ifaces To: Eric Dumazet 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 12:56 AM Eric Dumazet wrote: > > 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() ? Yes, you're right. Although current implementation doesn't hurt because if any of those candidate routes were not deleted means that they have accept_ra == 2 which overrules the router behaviour so we won't clean the SLAAC anyway.