Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: flowtable: add hash offset field to tuple

Add a placeholder field to calculate hash tuple offset. Similar to
2c407aca6497 ("netfilter: conntrack: avoid gcc-10 zero-length-bounds
warning").

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

+7 -3
+4
include/net/netfilter/nf_flow_table.h
··· 107 107 108 108 u8 l3proto; 109 109 u8 l4proto; 110 + 111 + /* All members above are keys for lookups, see flow_offload_hash(). */ 112 + struct { } __hash; 113 + 110 114 u8 dir; 111 115 112 116 u16 mtu;
+3 -3
net/netfilter/nf_flow_table_core.c
··· 191 191 { 192 192 const struct flow_offload_tuple *tuple = data; 193 193 194 - return jhash(tuple, offsetof(struct flow_offload_tuple, dir), seed); 194 + return jhash(tuple, offsetof(struct flow_offload_tuple, __hash), seed); 195 195 } 196 196 197 197 static u32 flow_offload_hash_obj(const void *data, u32 len, u32 seed) 198 198 { 199 199 const struct flow_offload_tuple_rhash *tuplehash = data; 200 200 201 - return jhash(&tuplehash->tuple, offsetof(struct flow_offload_tuple, dir), seed); 201 + return jhash(&tuplehash->tuple, offsetof(struct flow_offload_tuple, __hash), seed); 202 202 } 203 203 204 204 static int flow_offload_hash_cmp(struct rhashtable_compare_arg *arg, ··· 207 207 const struct flow_offload_tuple *tuple = arg->key; 208 208 const struct flow_offload_tuple_rhash *x = ptr; 209 209 210 - if (memcmp(&x->tuple, tuple, offsetof(struct flow_offload_tuple, dir))) 210 + if (memcmp(&x->tuple, tuple, offsetof(struct flow_offload_tuple, __hash))) 211 211 return 1; 212 212 213 213 return 0;