[openwrt/openwrt] generic: 5.15: standardize tcp_no_window_check pending patch

LEDE Commits lede-commits at lists.infradead.org
Sat Mar 26 21:19:43 PDT 2022


dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/92fb51bc98814958f4c4d69b6a397a17c83d62c6

commit 92fb51bc98814958f4c4d69b6a397a17c83d62c6
Author: Ansuel Smith <ansuelsmth at gmail.com>
AuthorDate: Sun Nov 7 22:33:21 2021 +0100

    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 <ansuelsmth at gmail.com>
---
 .../613-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 284ec073ef..c7978e5881 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 <nbd at nbd.name>
 
 --- a/net/netfilter/nf_conntrack_proto_tcp.c
 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
-@@ -31,6 +31,9 @@
- #include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
- #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
- 
-+/* 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 <nbd at nbd.name>
  		 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 <net/netfilter/nf_conntrack_timestamp.h>
- #include <linux/rculist_nulls.h>
- 
-+/* 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 <nbd at nbd.name>
  #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 <nbd at nbd.name>
  	{}
  };
  
+@@ -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;




More information about the lede-commits mailing list