generic: 5.15: standardize tcp_no_window_check pending patch
authorAnsuel Smith <ansuelsmth@gmail.com>
Sun, 7 Nov 2021 21:33:21 +0000 (22:33 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 27 Mar 2022 00:07:34 +0000 (00:07 +0000)
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@gmail.com>
target/linux/generic/pending-5.15/613-netfilter_optional_tcp_window_check.patch

index 284ec073efba77fd7900edd79b6b0f6b74f7f0c6..c7978e5881e7ce19b0bab21a39ad467d1a53cc1b 100644 (file)
@@ -8,21 +8,11 @@ Signed-off-by: Felix Fietkau <nbd@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@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@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@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;