Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp772348ybg; Wed, 23 Oct 2019 05:45:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiBjVc4vn7r+OJu5hnubBNkLadZFqk0pG1qHcJnYnqnJFgjzjlfzbi/rTpJRFo+bfHkD7j X-Received: by 2002:a50:f058:: with SMTP id u24mr2829122edl.288.1571834704310; Wed, 23 Oct 2019 05:45:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571834704; cv=none; d=google.com; s=arc-20160816; b=R8YbYWbcPt/EQHdSolcBEc+fbYf37E8K+keclezJ+RLr9HzeGSh2as0zStJrUuqkjZ iPsTYXgrzv9Fsfn+fpFIhBgCtraINy5e5yl7Sq6hi+wjhB5am+ErKOG5W7629Hi5byz5 XhFjCf3dOZAdU3oZ21EUD1peliw1Feb5MVADAN10hkKlqx3HOhAD+DG+Yv0Nb/r7OxfM xjaHhCFAjLhDeetRL6DGi0BjS7aiUKC6qrLk4wA9XzUTrrE0Sdc4lqAPGX/AmatkFg0x Iy7kQKWma1OlpZd0VE6nYdSw4CVLMjs1EKZD71LyoLvcgGyRhpct8zSB7LB+fdU55I1+ 3qcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/NsmOCl0y6Xsu2o/7hjfK3x4RxKT1/LHqLenfxqsBu4=; b=CWIug0Qtrh5LdLQYiMBSZIJ7Y9X+djI0Xi3uLNRYH4IHlI3ZkBzYKYPaPfdzQigu7s BzGYB3FpktiNZIPL04pPULmQkQENWOaRcThxtOKaGXST1dAKrONX3XegXEgIOqLNZJmA CTPEwLMNYwgkTZetjvwZ0Ur1HaOf+qFFOcnHW64O1CPWSnnYI8+0G5KxItZPE4/yVVBc G9yRUx7XBu0R1M21WUoGoyUBdnlZDggvhXzc580+SsCR/v4Ht/sAN1vRdM/SJOga41wh AwX3H17nBHa0u00XgtXh7rwhk2gFRsQoLkIGicdFVqlN/fwpSxaSlzdsablj/NYDVcgx DvmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=M+iC1Qnn; 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 jx20si12640249ejb.291.2019.10.23.05.44.40; Wed, 23 Oct 2019 05:45:04 -0700 (PDT) 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; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=M+iC1Qnn; 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 S2391026AbfJWJ5W (ORCPT + 99 others); Wed, 23 Oct 2019 05:57:22 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:44822 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390880AbfJWJ5W (ORCPT ); Wed, 23 Oct 2019 05:57:22 -0400 Received: by mail-ed1-f68.google.com with SMTP id r16so15251832edq.11 for ; Wed, 23 Oct 2019 02:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=/NsmOCl0y6Xsu2o/7hjfK3x4RxKT1/LHqLenfxqsBu4=; b=M+iC1Qnn0TshdtMKZlRUc9MwyHpOanqAsn4vIwnb0kzaLjvPhHuuUhiLQrCRWK9P4l hqDMurj8khv4+wIgJCCykcJIKG1+3vlczvZ2fOKKLV+GIHdTgiSKjJuLYkf28WsnvV4H Pw01NYEroGCPQYXskYPLxVxY+hQgYI17PkbmPD0aU3DRunvINBQMAJPMMCTTNrw6Zsj8 BIaxRkuNbhA9CZKe6KLs5nA5dhUW1JevILfFZmu6crtPAFEV+GKL4D03im42FJbGY/+m RckSW7rYczSX5kAfMfvC1mIqioPokfEcvFqBWC3R1FTn9xvzotr1F9sWPYEWAuKHfwyY rPpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=/NsmOCl0y6Xsu2o/7hjfK3x4RxKT1/LHqLenfxqsBu4=; b=ZMV5tUplE/S9mgSW4Bb7ZBBjILIvyBWQ5BW9VzolQVu0ZxFYCkDdm6Vbbqwl759yCO IcrPLd1jLQjTm/d+poYnIJxpGDupZwMP73VABai1OHyaK8ZWD2i+FEuYCmXsw6PP8PbJ vuLYffzkUvv8TLmkP8YWwNd4XROpIN4ZH5gmPOORtmX4Gq827PDHHdngf0MOvJZzTf5U 3l+p+gWTDqsoC13dck88gc2mtBg0cbnR4pCSUuAWs429u5JCfDcsoSjYrO81w8N5FHDs QannTQIlqhbxEs3B3+/+zS2L5uY/b+c7VLcSD38+mKuz0S5iz9lwES/tdGkVOd5PT5+q CVSg== X-Gm-Message-State: APjAAAVk34J/D2fcE51wQGDfn8JBj86rXac4kUgefbZ1rAWBEA9losVE 20GUVQ0160N6SDPaDk8TOoE04A== X-Received: by 2002:a17:906:254e:: with SMTP id j14mr6727439ejb.150.1571824640463; Wed, 23 Oct 2019 02:57:20 -0700 (PDT) Received: from netronome.com ([62.119.166.9]) by smtp.gmail.com with ESMTPSA id b53sm783428ede.96.2019.10.23.02.57.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 02:57:19 -0700 (PDT) Date: Wed, 23 Oct 2019 11:57:15 +0200 From: Simon Horman To: Matteo Croce Cc: netdev@vger.kernel.org, Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S . Miller " , Stanislav Fomichev , Daniel Borkmann , Song Liu , Alexei Starovoitov , Paul Blakey , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next 1/4] flow_dissector: add meaningful comments Message-ID: <20191023095712.GA8732@netronome.com> References: <20191021200948.23775-1-mcroce@redhat.com> <20191021200948.23775-2-mcroce@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021200948.23775-2-mcroce@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 10:09:45PM +0200, Matteo Croce wrote: > Documents two piece of code which can't be understood at a glance. > > Signed-off-by: Matteo Croce Reviewed-by: Simon Horman > --- > include/net/flow_dissector.h | 1 + > net/core/flow_dissector.c | 6 ++++++ > 2 files changed, 7 insertions(+) > > diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h > index 90bd210be060..7747af3cc500 100644 > --- a/include/net/flow_dissector.h > +++ b/include/net/flow_dissector.h > @@ -282,6 +282,7 @@ struct flow_keys { > struct flow_dissector_key_vlan cvlan; > struct flow_dissector_key_keyid keyid; > struct flow_dissector_key_ports ports; > + /* 'addrs' must be the last member */ > struct flow_dissector_key_addrs addrs; > }; > > diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c > index 7c09d87d3269..affde70dad47 100644 > --- a/net/core/flow_dissector.c > +++ b/net/core/flow_dissector.c > @@ -1374,6 +1374,9 @@ static inline size_t flow_keys_hash_length(const struct flow_keys *flow) > { > size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs); > BUILD_BUG_ON((sizeof(*flow) - FLOW_KEYS_HASH_OFFSET) % sizeof(u32)); > + /* flow.addrs MUST be the last member in struct flow_keys because > + * different L3 protocols have different address length > + */ > BUILD_BUG_ON(offsetof(typeof(*flow), addrs) != > sizeof(*flow) - sizeof(flow->addrs)); > > @@ -1421,6 +1424,9 @@ __be32 flow_get_u32_dst(const struct flow_keys *flow) > } > EXPORT_SYMBOL(flow_get_u32_dst); > > +/* Sort the source and destination IP (and the ports if the IP are the same), > + * to have consistent hash within the two directions > + */ > static inline void __flow_hash_consistentify(struct flow_keys *keys) > { > int addr_diff, i; > -- > 2.21.0 >