1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Sun, 25 Feb 2018 15:41:11 +0100
3 Subject: [PATCH] netfilter: nf_flow_table: add support for sending flows
6 Reset the timeout. For TCP, also set the state to indicate to use the
7 next incoming packets to reset window tracking.
8 This allows the slow path to take over again once the offload state has
11 Signed-off-by: Felix Fietkau <nbd@nbd.name>
14 --- a/net/netfilter/nf_flow_table_core.c
15 +++ b/net/netfilter/nf_flow_table_core.c
16 @@ -100,6 +100,36 @@ err_ct_refcnt:
18 EXPORT_SYMBOL_GPL(flow_offload_alloc);
20 +static void flow_offload_fixup_ct_state(struct nf_conn *ct)
22 + const struct nf_conntrack_l4proto *l4proto;
23 + struct net *net = nf_ct_net(ct);
24 + unsigned int *timeouts;
25 + unsigned int timeout;
28 + l4num = nf_ct_protonum(ct);
29 + l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), l4num);
33 + timeouts = l4proto->get_timeouts(net);
37 + if (l4num == IPPROTO_TCP) {
38 + timeout = timeouts[TCP_CONNTRACK_ESTABLISHED];
39 + ct->proto.tcp.state = TCP_CONNTRACK_IGNORE;
40 + } else if (l4num == IPPROTO_UDP) {
41 + timeout = timeouts[UDP_CT_REPLIED];
46 + ct->timeout = nfct_time_stamp + timeout;
47 + clear_bit(IPS_OFFLOAD_BIT, &ct->status);
50 void flow_offload_free(struct flow_offload *flow)
52 struct flow_offload_entry *e;
53 @@ -107,7 +137,10 @@ void flow_offload_free(struct flow_offlo
54 dst_release(flow->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.dst_cache);
55 dst_release(flow->tuplehash[FLOW_OFFLOAD_DIR_REPLY].tuple.dst_cache);
56 e = container_of(flow, struct flow_offload_entry, flow);
57 - nf_ct_delete(e->ct, 0, 0);
58 + if (flow->flags & FLOW_OFFLOAD_DYING)
59 + nf_ct_delete(e->ct, 0, 0);
61 + flow_offload_fixup_ct_state(e->ct);
63 kfree_rcu(e, rcu_head);