Blob Blame History Raw
From: Matteo Croce <mcroce@redhat.com>
Date: Tue, 29 Oct 2019 14:50:50 +0100
Subject: flow_dissector: add meaningful comments
Patch-mainline: v5.5-rc1
Git-commit: 98298e6ca6d5908f96e529e70a254a4d5bf754e7
References: bsc#1154353

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

Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 include/net/flow_dissector.h |    1 +
 net/core/flow_dissector.c    |    6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

--- a/include/net/flow_dissector.h
+++ b/include/net/flow_dissector.h
@@ -283,6 +283,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;
 };
 
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -1399,8 +1399,7 @@ static const void *flow_keys_hash_start(
 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(offsetof(typeof(*flow), addrs) !=
-		     sizeof(*flow) - sizeof(flow->addrs));
+	BUILD_BUG_ON((sizeof(*flow) - FLOW_KEYS_HASH_OFFSET) % sizeof(u32));
 
 	switch (flow->control.addr_type) {
 	case FLOW_DISSECTOR_KEY_IPV4_ADDRS:
@@ -1446,6 +1445,9 @@ __be32 flow_get_u32_dst(const struct flo
 }
 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;