From 92fb51bc98814958f4c4d69b6a397a17c83d62c6 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sun, 7 Nov 2021 22:33:21 +0100 Subject: [PATCH] generic: 5.15: standardize tcp_no_window_check pending patch Standardize pending patch tcp_no_window_check patch as with new kernel they added a check for global variables. The 2 new condition are that they must be read-only or the data pointer should not point to kernel/module global data. Remove the global variable and move it to a standard place following other variables logic. Signed-off-by: Ansuel Smith --- ...-netfilter_optional_tcp_window_check.patch | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch b/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch index 284ec073efb..c7978e5881e 100644 --- a/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch +++ b/target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch @@ -8,21 +8,11 @@ Signed-off-by: Felix Fietkau --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c -@@ -31,6 +31,9 @@ - #include - #include - -+/* Do not check the TCP window for incoming packets */ -+static int nf_ct_tcp_no_window_check __read_mostly = 1; -+ - /* FIXME: Examine ipfilter's timeouts and conntrack transitions more - closely. They're more complex. --RR */ - @@ -476,6 +479,9 @@ static bool tcp_in_window(const struct n s32 receiver_offset; bool res, in_recv_win; -+ if (nf_ct_tcp_no_window_check) ++ if (net->ct.sysctl_no_window_check) + return true; + /* @@ -33,22 +23,12 @@ Signed-off-by: Felix Fietkau timeouts[new_state] > timeouts[TCP_CONNTRACK_UNACK]) timeout = timeouts[TCP_CONNTRACK_UNACK]; - else if (ct->proto.tcp.last_win == 0 && -+ else if (!nf_ct_tcp_no_window_check && 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 -@@ -25,6 +25,9 @@ - #include - #include - -+/* Do not check the TCP window for incoming packets */ -+static int nf_ct_tcp_no_window_check __read_mostly = 1; -+ - static bool enable_hooks __read_mostly; - MODULE_PARM_DESC(enable_hooks, "Always enable conntrack hooks"); - module_param(enable_hooks, bool, 0000); @@ -660,6 +663,7 @@ enum nf_ct_sysctl_index { NF_SYSCTL_CT_PROTO_TIMEOUT_GRE_STREAM, #endif @@ -63,7 +43,7 @@ Signed-off-by: Felix Fietkau #endif + [NF_SYSCTL_CT_PROTO_TCP_NO_WINDOW_CHECK] = { + .procname = "nf_conntrack_tcp_no_window_check", -+ .data = &nf_ct_tcp_no_window_check, ++ .data = &init_net.ct.sysctl_no_window_check, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = proc_dointvec, @@ -71,3 +51,29 @@ Signed-off-by: Felix Fietkau {} }; +@@ -1164,6 +1164,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) + #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 +@@ -1220,6 +1220,7 @@ + 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; -- 2.30.2