From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 C33DFCA9EB6 for ; Wed, 23 Oct 2019 09:57:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 998012064A for ; Wed, 23 Oct 2019 09:57:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="M+iC1Qnn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391023AbfJWJ5W (ORCPT ); Wed, 23 Oct 2019 05:57:22 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:39898 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390545AbfJWJ5W (ORCPT ); Wed, 23 Oct 2019 05:57:22 -0400 Received: by mail-ed1-f68.google.com with SMTP id l25so4029001edt.6 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=FiOMVdGFeNaPUbAlF0yIFvxxAkq+8/fhAwH2gj1OZhR4+7FUu6k9mPIK8Et2BgDAnb 8ZZMMJ+kK7XsVFDE79wNi3tBNpUr2w0mIBoGH0qsULkx4It2Ds36g6oHTkVzIcIa1E0W Gl0JbCMFg59nTeCCpGDEArnMXzImmNQHNi51hUInlcNPUsYJOOXyAqhXMN4kSmLlBb6i n/ToojoK4uvv8qypd+HDIZFiBf+q/x1Qnb+d+oN4/g7d0USxaMMrEN6dOGPSTlyXcV8i 90CTigutg9UXvIfOddS8JdyFVw2uhAt/qwXys+YrkUiPVLnct88AYAXg6NPSlkrpLS5G WrEA== X-Gm-Message-State: APjAAAVZOVWt9au80+cDIV96aCCsZRUjB4pfc18PBLXahE+rv+wHqC7X 62kGrHPgUNgssDnguxWTup4IYg== X-Google-Smtp-Source: APXvYqxOeXB5dcGaik2DpU7A8VO5NugXaB6+Iv+ZKZhAoP9s7OBGYf2kw0dFdZ407h4y+Sap+6cS0Q== 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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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 >