public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matteo Croce <mcroce@redhat.com>
To: netdev@vger.kernel.org
Cc: Jay Vosburgh <j.vosburgh@gmail.com>,
	Veaceslav Falico <vfalico@gmail.com>,
	Andy Gospodarek <andy@greyhouse.net>,
	"David S . Miller " <davem@davemloft.net>,
	Stanislav Fomichev <sdf@google.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Song Liu <songliubraving@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Paul Blakey <paulb@mellanox.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/4] flow_dissector: add meaningful comments
Date: Mon, 21 Oct 2019 22:09:45 +0200	[thread overview]
Message-ID: <20191021200948.23775-2-mcroce@redhat.com> (raw)
In-Reply-To: <20191021200948.23775-1-mcroce@redhat.com>

Documents two piece of code which can't be understood at a glance.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 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


  reply	other threads:[~2019-10-21 20:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 20:09 [PATCH net-next 0/4] ICMP flow improvements Matteo Croce
2019-10-21 20:09 ` Matteo Croce [this message]
2019-10-23  9:57   ` [PATCH net-next 1/4] flow_dissector: add meaningful comments Simon Horman
2019-10-21 20:09 ` [PATCH net-next 2/4] flow_dissector: skip the ICMP dissector for non ICMP packets Matteo Croce
2019-10-23  9:57   ` Simon Horman
2019-10-21 20:09 ` [PATCH net-next 3/4] flow_dissector: extract more ICMP information Matteo Croce
2019-10-23 10:00   ` Simon Horman
2019-10-23 10:53     ` Matteo Croce
2019-10-23 17:55       ` Simon Horman
2019-10-25  0:27         ` Matteo Croce
2019-10-25  6:28           ` Simon Horman
2019-10-25 18:24             ` Matteo Croce
2019-10-26  7:55               ` Simon Horman
2019-10-21 20:09 ` [PATCH net-next 4/4] bonding: balance ICMP echoes in layer3+4 mode Matteo Croce
2019-10-23 10:01   ` Simon Horman
2019-10-23 16:58     ` Matteo Croce
2019-10-23 18:00       ` Simon Horman
2019-10-24 22:05 ` [PATCH net-next 0/4] ICMP flow improvements David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191021200948.23775-2-mcroce@redhat.com \
    --to=mcroce@redhat.com \
    --cc=andy@greyhouse.net \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=j.vosburgh@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paulb@mellanox.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=vfalico@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox