kernel: Copy patches from kernel 4.14 to 4.19
[openwrt/staging/wigyori.git] / target / linux / generic / backport-4.19 / 362-v4.18-netfilter-nf_flow_table-in-flow_offload_lookup-skip-.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sun, 25 Feb 2018 15:39:56 +0100
3 Subject: [PATCH] netfilter: nf_flow_table: in flow_offload_lookup, skip
4 entries being deleted
5
6 Preparation for sending flows back to the slow path
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/netfilter/nf_flow_table_core.c
12 +++ b/net/netfilter/nf_flow_table_core.c
13 @@ -184,8 +184,21 @@ struct flow_offload_tuple_rhash *
14 flow_offload_lookup(struct nf_flowtable *flow_table,
15 struct flow_offload_tuple *tuple)
16 {
17 - return rhashtable_lookup_fast(&flow_table->rhashtable, tuple,
18 - nf_flow_offload_rhash_params);
19 + struct flow_offload_tuple_rhash *tuplehash;
20 + struct flow_offload *flow;
21 + int dir;
22 +
23 + tuplehash = rhashtable_lookup_fast(&flow_table->rhashtable, tuple,
24 + nf_flow_offload_rhash_params);
25 + if (!tuplehash)
26 + return NULL;
27 +
28 + dir = tuplehash->tuple.dir;
29 + flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
30 + if (flow->flags & (FLOW_OFFLOAD_DYING | FLOW_OFFLOAD_TEARDOWN))
31 + return NULL;
32 +
33 + return tuplehash;
34 }
35 EXPORT_SYMBOL_GPL(flow_offload_lookup);
36