Commit dbc859d9 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: flowtable: add hash offset field to tuple

Add a placeholder field to calculate hash tuple offset. Similar to
2c407aca ("netfilter: conntrack: avoid gcc-10 zero-length-bounds
warning").
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 012da53d
...@@ -107,6 +107,10 @@ struct flow_offload_tuple { ...@@ -107,6 +107,10 @@ struct flow_offload_tuple {
u8 l3proto; u8 l3proto;
u8 l4proto; u8 l4proto;
/* All members above are keys for lookups, see flow_offload_hash(). */
struct { } __hash;
u8 dir; u8 dir;
u16 mtu; u16 mtu;
......
...@@ -191,14 +191,14 @@ static u32 flow_offload_hash(const void *data, u32 len, u32 seed) ...@@ -191,14 +191,14 @@ static u32 flow_offload_hash(const void *data, u32 len, u32 seed)
{ {
const struct flow_offload_tuple *tuple = data; const struct flow_offload_tuple *tuple = data;
return jhash(tuple, offsetof(struct flow_offload_tuple, dir), seed); return jhash(tuple, offsetof(struct flow_offload_tuple, __hash), seed);
} }
static u32 flow_offload_hash_obj(const void *data, u32 len, u32 seed) static u32 flow_offload_hash_obj(const void *data, u32 len, u32 seed)
{ {
const struct flow_offload_tuple_rhash *tuplehash = data; const struct flow_offload_tuple_rhash *tuplehash = data;
return jhash(&tuplehash->tuple, offsetof(struct flow_offload_tuple, dir), seed); return jhash(&tuplehash->tuple, offsetof(struct flow_offload_tuple, __hash), seed);
} }
static int flow_offload_hash_cmp(struct rhashtable_compare_arg *arg, static int flow_offload_hash_cmp(struct rhashtable_compare_arg *arg,
...@@ -207,7 +207,7 @@ static int flow_offload_hash_cmp(struct rhashtable_compare_arg *arg, ...@@ -207,7 +207,7 @@ static int flow_offload_hash_cmp(struct rhashtable_compare_arg *arg,
const struct flow_offload_tuple *tuple = arg->key; const struct flow_offload_tuple *tuple = arg->key;
const struct flow_offload_tuple_rhash *x = ptr; const struct flow_offload_tuple_rhash *x = ptr;
if (memcmp(&x->tuple, tuple, offsetof(struct flow_offload_tuple, dir))) if (memcmp(&x->tuple, tuple, offsetof(struct flow_offload_tuple, __hash)))
return 1; return 1;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment