aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch
blob: b9919ae4754a46447fbd0a0db536be4ff2374c1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From: Felix Fietkau <nbd@nbd.name>
Subject: netfilter: optional tcp window check

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 net/netfilter/nf_conntrack_proto_tcp.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -465,6 +465,9 @@ static bool tcp_in_window(struct nf_conn
 	s32 receiver_offset;
 	bool res, in_recv_win;
 
+	if (net->ct.sysctl_no_window_check)
+		return true;
+
 	/*
 	 * Get the required data from the packet.
 	 */
@@ -1160,7 +1163,7 @@ int nf_conntrack_tcp_packet(struct nf_co
 		 IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED &&
 		 timeouts[new_state] > timeouts[TCP_CONNTRACK_UNACK])
 		timeout = timeouts[TCP_CONNTRACK_UNACK];
-	else if (ct->proto.tcp.last_win == 0 &&
+	else if (!net->ct.sysctl_no_window_check && ct->proto.tcp.last_win == 0 &&
 		 timeouts[new_state] > timeouts[TCP_CONNTRACK_RETRANS])
 		timeout = timeouts[TCP_CONNTRACK_RETRANS];
 	else
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -671,6 +671,7 @@ enum nf_ct_sysctl_index {
 	NF_SYSCTL_CT_LWTUNNEL,
 #endif
 
+	NF_SYSCTL_CT_PROTO_TCP_NO_WINDOW_CHECK,
 	__NF_SYSCTL_CT_LAST_SYSCTL,
 };
 
@@ -1026,6 +1027,13 @@ static struct ctl_table nf_ct_sysctl_tab
 		.proc_handler	= nf_hooks_lwtunnel_sysctl_handler,
 	},
 #endif
+	[NF_SYSCTL_CT_PROTO_TCP_NO_WINDOW_CHECK] = {
+		.procname       = "nf_conntrack_tcp_no_window_check",
+		.data           = &init_net.ct.sysctl_no_window_check,
+		.maxlen         = sizeof(unsigned int),
+		.mode           = 0644,
+		.proc_handler   = proc_dointvec,
+	},
 	{}
 };
 
@@ -1153,6 +1161,7 @@ static int nf_conntrack_standalone_init_
 #ifdef CONFIG_NF_CONNTRACK_EVENTS
 	table[NF_SYSCTL_CT_EVENTS].data = &net->ct.sysctl_events;
 #endif
+	table[NF_SYSCTL_CT_PROTO_TCP_NO_WINDOW_CHECK].data = &net->ct.sysctl_no_window_check;
 #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
 	table[NF_SYSCTL_CT_TIMESTAMP].data = &net->ct.sysctl_tstamp;
 #endif
@@ -1222,6 +1231,7 @@ static int nf_conntrack_pernet_init(stru
 	int ret;
 
 	net->ct.sysctl_checksum = 1;
+	net->ct.sysctl_no_window_check = 1;
 
 	ret = nf_conntrack_standalone_init_sysctl(net);
 	if (ret < 0)
--- a/include/net/netns/conntrack.h
+++ b/include/net/netns/conntrack.h
@@ -109,6 +109,7 @@ struct netns_ct {
 	u8			sysctl_auto_assign_helper;
 	u8			sysctl_tstamp;
 	u8			sysctl_checksum;
+	u8			sysctl_no_window_check;
 
 	struct ct_pcpu __percpu *pcpu_lists;
 	struct ip_conntrack_stat __percpu *stat;