Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp420189pxb; Wed, 18 Nov 2020 07:52:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxJL8NgbJQ9vgf9nNYkXQOS0mbSI1bq4IILaVMAk0umE4wHDffUmxqE5A3YWjB89HiMq+qk X-Received: by 2002:a17:906:f98d:: with SMTP id li13mr1973251ejb.547.1605714735449; Wed, 18 Nov 2020 07:52:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605714735; cv=none; d=google.com; s=arc-20160816; b=QOmAAk/pqdsQ2bRL3C6GbpjXfIIPzEocNvZarEBCGGRVbd6pZWhEms+49prV3vpoTj M69lQ7kvAqYfKTbr6LSJ1R3xQZfFLPGM5FPqeA+KvaIN5MqT8eMektBFBdiTCpjKFpLW yWFErR2FbxkW7nDJayy7Mii3022wRASH4G2eZoTICCv7LxPtTiFOEEVIId8Fo6qDeerO /TBVlhKetjuEel5/xzO2+5nmoKiqk9eQE86jFjPgONo0vnrhQfuaoUji+mTUfzKEooQ2 2p1ulduMw/LAeXMRQBDRck1M7EQitGJL+TdVZQrPRzSiEPsHPkxxvC6DOdSuhhjCCR3n vtWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=R16fh52oZVL1oeNAVRTDthgfjHljqAh6nx6eun1+V9U=; b=HFe8vl1zDiA+hCML1qoD1Xjij+qjCD6j3aqhF5oPlSPPCJqPZA71sA0StccSeXaIYp ZnnJFg5a1szIhLBjNBjL6uJvPXCaCUVEqO0S9+6iaOKywPUzz6bRnZM3qxf1dRXORPym bTxD4tMhv7hESLgSMoQ7SmfBPYglJQ2MtUnqw5FTUjy0qL+OaVo02pU1k1xagJMmiY4Y U7wT2PlZLwXJgHCiyx5HsrISuAYymN0sJ5axoaeT2lYySo/w2GEpxs+P1yvI28ep/K6O fMbz86KE5PsPUaESu5tL0p3vUeGBXe9Q1f4DMqgPMTN5vXEeshpq4UWntwvJ8uhOgf82 uUrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="VH8oIO/j"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm25si15317131edb.238.2020.11.18.07.51.52; Wed, 18 Nov 2020 07:52:15 -0800 (PST) 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=@kernel.org header.s=default header.b="VH8oIO/j"; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726849AbgKRPua (ORCPT + 99 others); Wed, 18 Nov 2020 10:50:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:50290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgKRPua (ORCPT ); Wed, 18 Nov 2020 10:50:30 -0500 Received: from kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net (unknown [163.114.132.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1296247A7; Wed, 18 Nov 2020 15:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605714629; bh=Yo6sgm3/oVDnxAfTnq6e5gCNuPqh+2emIPWFYlwhGqo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VH8oIO/j4mWTpk4EDah65F4S3YHfWS5i0UHsxNXKM8HSgO8q4OaKUTBepivjyt36W Fyj56OvOuMTaKIqiUMWgsccxZx1PoB8MwbQjMBLb+r3eJ0BWWmhZeuCgwybd1tUlBu H/5y1988557KuNncf6FSOSvgwNdAvTCmjpobasPQ= Date: Wed, 18 Nov 2020 07:50:27 -0800 From: Jakub Kicinski To: Dmytro Shytyi Cc: "kuznet" , "yoshfuji" , "liuhangbin" , "davem" , "netdev" , "linux-kernel" Subject: Re: [PATCH net-next V5] net: Variable SLAAC: SLAAC with prefixes of arbitrary length in PIO Message-ID: <20201118075027.18083d19@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> In-Reply-To: <175db965378.e5454e1c360034.2264030307026794920@shytyi.net> References: <175b3433a4c.aea7c06513321.4158329434310691736@shytyi.net> <202011110944.7zNVZmvB-lkp@intel.com> <175bd218cf4.103c639bc117278.4209371191555514829@shytyi.net> <175bf515624.c67e02e8130655.7824060160954233592@shytyi.net> <175c31c6260.10eef97f6180313.755036504412557273@shytyi.net> <20201117124348.132862b1@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net> <175db965378.e5454e1c360034.2264030307026794920@shytyi.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Nov 2020 14:41:03 +0100 Dmytro Shytyi wrote: > > > @@ -2576,9 +2590,42 @@ int addrconf_prefix_rcv_add_addr(struct > > > u32 addr_flags, bool sllao, bool tokenized, > > > __u32 valid_lft, u32 prefered_lft) > > > { > > > - struct inet6_ifaddr *ifp = ipv6_get_ifaddr(net, addr, dev, 1); > > > + struct inet6_ifaddr *ifp = NULL; > > > int create = 0; > > > > > > + if ((in6_dev->if_flags & IF_RA_VAR_PLEN) == IF_RA_VAR_PLEN && > > > + in6_dev->cnf.addr_gen_mode != IN6_ADDR_GEN_MODE_STABLE_PRIVACY) { > > > + struct inet6_ifaddr *result = NULL; > > > + struct inet6_ifaddr *result_base = NULL; > > > + struct in6_addr curr_net_prfx; > > > + struct in6_addr net_prfx; > > > + bool prfxs_equal; > > > + > > > + result_base = result; > > > + rcu_read_lock(); > > > + list_for_each_entry_rcu(ifp, &in6_dev->addr_list, if_list) { > > > + if (!net_eq(dev_net(ifp->idev->dev), net)) > > > + continue; > > > + ipv6_addr_prefix_copy(&net_prfx, &pinfo->prefix, pinfo->prefix_len); > > > + ipv6_addr_prefix_copy(&curr_net_prfx, &ifp->addr, pinfo->prefix_len); > > > + prfxs_equal = > > > + ipv6_prefix_equal(&net_prfx, &curr_net_prfx, pinfo->prefix_len); > > > + > > > + if (prfxs_equal && pinfo->prefix_len == ifp->prefix_len) { > > > + result = ifp; > > > + in6_ifa_hold(ifp); > > > + break; > > > + } > > > + } > > > + rcu_read_unlock(); > > > + if (result_base != result) > > > + ifp = result; > > > + else > > > + ifp = NULL; > > > > Could this be a helper of its own? > > Explain the thought please. It is not clear for me. At the look of it the code under this if statement looks relatively self-contained, and has quite a few local variables. Rather than making the surrounding function longer would it be possible to factor it out into a helper function?