Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B43EC10F11 for ; Wed, 10 Apr 2019 18:45:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3211E2070D for ; Wed, 10 Apr 2019 18:45:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hRSj8WhH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731651AbfDJSpI (ORCPT ); Wed, 10 Apr 2019 14:45:08 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43402 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727881AbfDJSpI (ORCPT ); Wed, 10 Apr 2019 14:45:08 -0400 Received: by mail-pg1-f195.google.com with SMTP id z9so2063748pgu.10 for ; Wed, 10 Apr 2019 11:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=L4G620Z6w+lzG7El0ppNuhtbJhBGWc9MmGtsmFJRyB4=; b=hRSj8WhHa8G45qEZy1UKneZw3pQa1Tnvg0JhDvdGCK7GWT7k18tJuBHkFYFWnTr7BA BSO5UybUuU9C1XKwdV+nTGKZRPZh7UM4FGfkRhM/aa5TRXw9ydPcKCdx7h85ev5s75Mj kPbg8EiWNqT0Lvvw+BSPuMSND1U6WulgtCYy4nQ+ERrkEuJjNtmYt/d2jxWO4vC2/M50 ScnJCU5t8dGlGwyVuFHvcDsXNtawnkqrvnZUIL8MD1d5TN+pdQucrM0N0K7vTZ0TfTR5 HBm3VmVMKORF6M36JfG5dpBBBL5e4WnGhdzOe74aGavfSiffsqq3rJE4VtOeRnZm+oqA 0Riw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=L4G620Z6w+lzG7El0ppNuhtbJhBGWc9MmGtsmFJRyB4=; b=K2RBoQzTCR0zpn9uRwyneB4yMq3EW2Zn0/+nsThWFj3anAmXWuRkIinTf6oIYbp6DB rtBn2MF8rUK10QW0BHhyGbNTMSabOCBBMQngO+IusKotZHeBYuk+xzyPsltimni3LgnO Ps7dgXXi41xpPw+6e9/grfAz1fRuwmFm6fstZJbPspAHhuKDbYuI+baqrvFdpbQpwXMr hE9aLbCH0szQMUWBq4zQcifM4IoWEY1Ti02edcXHhZf3OjJpOWDZW6TM6BG2dNTCEhNu IcQBZMgFUdyOrXYCHRbsc8HpFB3WJ91haBllHp/YqLvsq1CtaZt9P3fTOyAFx6FVWIBX auQQ== X-Gm-Message-State: APjAAAVC28UBYynGhpjPJOY7HTg4GME5HooI066sna967EFAjoyJ9ND2 ne2hrCWTW/L3JoUXWw9SmA0= X-Google-Smtp-Source: APXvYqw0MQYzLISkxK/uoVIpq4cbHGQzGYsFvu4moNy+ToSDTS1AbFT3orVJ+TyXtRap++sJEZ7MOA== X-Received: by 2002:a63:c61:: with SMTP id 33mr39223435pgm.293.1554921907442; Wed, 10 Apr 2019 11:45:07 -0700 (PDT) Received: from [10.40.10.244] (fw.cumulusnetworks.com. [216.129.126.126]) by smtp.googlemail.com with ESMTPSA id g4sm52572432pfo.38.2019.04.10.11.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 11:45:06 -0700 (PDT) Subject: Re: [PATCH net-next 10/10] ipv6: Refactor __ip6_route_redirect To: Martin Lau , David Ahern Cc: "davem@davemloft.net" , "netdev@vger.kernel.org" , "idosch@mellanox.com" References: <20190409214119.15258-1-dsahern@kernel.org> <20190409214119.15258-11-dsahern@kernel.org> <20190410173616.fzj5mkm5yq4nio67@kafai-mbp.dhcp.thefacebook.com> From: David Ahern Message-ID: Date: Wed, 10 Apr 2019 11:45:04 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190410173616.fzj5mkm5yq4nio67@kafai-mbp.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 4/10/19 10:36 AM, Martin Lau wrote: >> diff --git a/net/ipv6/route.c b/net/ipv6/route.c >> index 0e8becb1e455..d555edaaff13 100644 >> --- a/net/ipv6/route.c >> +++ b/net/ipv6/route.c >> @@ -2407,6 +2407,35 @@ void ip6_sk_dst_store_flow(struct sock *sk, struct dst_entry *dst, >> NULL); >> } >> >> +static bool ip6_redirect_nh_match(struct fib6_info *f6i, >> + struct fib6_nh *nh, > Why both "struct fib6_info" and "struct fib6_nh" are needed? Because of rt6_find_cached_rt. At the moment it needs 2 entries from the fib6_info. Patches in follow on sets affect rt6_find_cached_rt in 2 ways: 1. Exceptions and cached routes are moved to per-fib6_nh similar to what is done for IPv4 in which case the need for fib6_info reduces to just the fib6_src.plen 2. fib6_result is introduced and passed to rt6_find_cached_rt instead of fib6_info and fib6_nh. It satisfies the need for fib6_src.plen from the fib entry and the fib6_nh for everything else. Something has to come first and in my experience with this overall change, I feel this order has the least duplicity in changes. > I assume nh cannot be obtained from f6i in the later patch > when nh is decoupled from f6i? correct > >> + struct flowi6 *fl6, >> + const struct in6_addr *gw, >> + struct rt6_info **ret) >> +{ >> + if (nh->fib_nh_flags & RTNH_F_DEAD || !nh->fib_nh_gw_family || >> + fl6->flowi6_oif != nh->fib_nh_dev->ifindex) >> + return false; >> + >> + /* rt_cache's gateway might be different from its 'parent' >> + * in the case of an ip redirect. >> + * So we keep searching in the exception table if the gateway >> + * is different. >> + */ >> + if (!ipv6_addr_equal(gw, &nh->fib_nh_gw6)) { >> + struct rt6_info *rt_cache; >> + >> + rt_cache = rt6_find_cached_rt(f6i, &fl6->daddr, &fl6->saddr); >> + if (rt_cache && >> + ipv6_addr_equal(gw, &rt_cache->rt6i_gateway)) { >> + *ret = rt_cache; >> + return true; >> + } >> + return false; >> + } >> + return true; >> +} >> + >> /* Handle redirects */ >> struct ip6rd_flowi { >> struct flowi6 fl6; >> @@ -2420,7 +2449,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net, >> int flags) >> { >> struct ip6rd_flowi *rdfl = (struct ip6rd_flowi *)fl6; >> - struct rt6_info *ret = NULL, *rt_cache; >> + struct rt6_info *ret = NULL; >> struct fib6_info *rt; > The "rt" naming is becoming hard to review. > It is fortunate that the type context is kept in this diff. > > In this local case, the s/rt/f6i/ rename is quite doable? I looked into it and I feel such a mass rename just causes noise: $ egrep -r 'fib6_info \*rt[,;]' net | wc -l 50 so that's 50 functions that need to be updated and then all rt references within the functions. A lot of noise which is why I have not sent a name change patch. > It can be the first clean-up step. > >> struct fib6_node *fn; >> >> @@ -2438,34 +2467,15 @@ static struct rt6_info *__ip6_route_redirect(struct net *net, >> fn = fib6_node_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); >> restart: >> for_each_fib6_node_rt_rcu(fn) { >> - if (rt->fib6_nh.fib_nh_flags & RTNH_F_DEAD) >> - continue; >> if (fib6_check_expired(rt)) >> continue; >> if (rt->fib6_flags & RTF_REJECT) >> break; >> - if (!rt->fib6_nh.fib_nh_gw_family) >> - continue; >> if (fl6->flowi6_oif != rt->fib6_nh.fib_nh_dev->ifindex) > This check is also copied to the new ip6_redirect_nh_match. > Should this one be removed from here? good catch. It should be removed.