Skip to content

Commit 98298e6

Browse files
teknoraverdavem330
authored andcommitted
flow_dissector: add meaningful comments
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>
1 parent c4917bf commit 98298e6

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎include/net/flow_dissector.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ struct flow_keys {
282282
struct flow_dissector_key_vlan cvlan;
283283
struct flow_dissector_key_keyid keyid;
284284
struct flow_dissector_key_ports ports;
285+
/* 'addrs' must be the last member */
285286
struct flow_dissector_key_addrs addrs;
286287
};
287288

‎net/core/flow_dissector.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,9 @@ static inline size_t flow_keys_hash_length(const struct flow_keys *flow)
14081408
{
14091409
size_t diff = FLOW_KEYS_HASH_OFFSET + sizeof(flow->addrs);
14101410
BUILD_BUG_ON((sizeof(*flow) - FLOW_KEYS_HASH_OFFSET) % sizeof(u32));
1411+
/* flow.addrs MUST be the last member in struct flow_keys because
1412+
* different L3 protocols have different address length
1413+
*/
14111414
BUILD_BUG_ON(offsetof(typeof(*flow), addrs) !=
14121415
sizeof(*flow) - sizeof(flow->addrs));
14131416

@@ -1455,6 +1458,9 @@ __be32 flow_get_u32_dst(const struct flow_keys *flow)
14551458
}
14561459
EXPORT_SYMBOL(flow_get_u32_dst);
14571460

1461+
/* Sort the source and destination IP (and the ports if the IP are the same),
1462+
* to have consistent hash within the two directions
1463+
*/
14581464
static inline void __flow_hash_consistentify(struct flow_keys *keys)
14591465
{
14601466
int addr_diff, i;

0 commit comments

Comments
 (0)