kernel: bump 5.10 to 5.10.116
[openwrt/openwrt.git] / target / linux / generic / backport-5.10 / 610-v5.13-00-netfilter-flowtable-add-hash-offset-field-to-tuple.patch
1 From: Pablo Neira Ayuso <pablo@netfilter.org>
2 Date: Fri, 20 Nov 2020 13:49:13 +0100
3 Subject: [PATCH] netfilter: flowtable: add hash offset field to tuple
4
5 Add a placeholder field to calculate hash tuple offset. Similar to
6 2c407aca6497 ("netfilter: conntrack: avoid gcc-10 zero-length-bounds
7 warning").
8
9 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
10 ---
11
12 --- a/include/net/netfilter/nf_flow_table.h
13 +++ b/include/net/netfilter/nf_flow_table.h
14 @@ -107,6 +107,10 @@ struct flow_offload_tuple {
15
16 u8 l3proto;
17 u8 l4proto;
18 +
19 + /* All members above are keys for lookups, see flow_offload_hash(). */
20 + struct { } __hash;
21 +
22 u8 dir;
23
24 u16 mtu;
25 --- a/net/netfilter/nf_flow_table_core.c
26 +++ b/net/netfilter/nf_flow_table_core.c
27 @@ -191,14 +191,14 @@ static u32 flow_offload_hash(const void
28 {
29 const struct flow_offload_tuple *tuple = data;
30
31 - return jhash(tuple, offsetof(struct flow_offload_tuple, dir), seed);
32 + return jhash(tuple, offsetof(struct flow_offload_tuple, __hash), seed);
33 }
34
35 static u32 flow_offload_hash_obj(const void *data, u32 len, u32 seed)
36 {
37 const struct flow_offload_tuple_rhash *tuplehash = data;
38
39 - return jhash(&tuplehash->tuple, offsetof(struct flow_offload_tuple, dir), seed);
40 + return jhash(&tuplehash->tuple, offsetof(struct flow_offload_tuple, __hash), seed);
41 }
42
43 static int flow_offload_hash_cmp(struct rhashtable_compare_arg *arg,
44 @@ -207,7 +207,7 @@ static int flow_offload_hash_cmp(struct
45 const struct flow_offload_tuple *tuple = arg->key;
46 const struct flow_offload_tuple_rhash *x = ptr;
47
48 - if (memcmp(&x->tuple, tuple, offsetof(struct flow_offload_tuple, dir)))
49 + if (memcmp(&x->tuple, tuple, offsetof(struct flow_offload_tuple, __hash)))
50 return 1;
51
52 return 0;