1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter.git synced 2025-02-15 04:42:02 +00:00
openmptcprouter/6.1/target/linux/generic/hack-6.1/998-ndpi-hook.patch

82 lines
2.9 KiB
Diff
Raw Normal View History

2023-07-31 19:31:34 +00:00
diff -urpN linux-6.1.38.old/include/net/netfilter/nf_conntrack.h linux-6.1.38/include/net/netfilter/nf_conntrack.h
--- linux-6.1.38.old/include/net/netfilter/nf_conntrack.h 2023-07-05 23:27:38.000000000 +0600
+++ linux-6.1.38/include/net/netfilter/nf_conntrack.h 2023-07-14 12:34:56.663750711 +0600
@@ -362,6 +362,11 @@ static inline struct nf_conntrack_net *n
return net_generic(net, nf_conntrack_net_id);
}
2023-12-22 19:23:25 +00:00
+#ifdef CONFIG_NF_CONNTRACK_DESTROY_HOOK
+void register_nf_ct_destroy_hook(void (*hook)(struct nf_conn *));
+void unregister_nf_ct_destroy_hook(void);
2023-07-31 19:31:34 +00:00
+#endif
+
#define NF_CT_STAT_INC(net, count) __this_cpu_inc((net)->ct.stat->count)
#define NF_CT_STAT_INC_ATOMIC(net, count) this_cpu_inc((net)->ct.stat->count)
#define NF_CT_STAT_ADD_ATOMIC(net, count, v) this_cpu_add((net)->ct.stat->count, (v))
diff -urpN linux-6.1.38.old/net/netfilter/Kconfig linux-6.1.38/net/netfilter/Kconfig
--- linux-6.1.38.old/net/netfilter/Kconfig 2023-07-05 23:27:38.000000000 +0600
+++ linux-6.1.38/net/netfilter/Kconfig 2023-07-14 12:34:11.966879899 +0600
@@ -76,11 +76,15 @@ config NETFILTER_NETLINK_OSF
If this option is enabled, the kernel will include support
for passive OS fingerprint via NFNETLINK.
2023-12-22 19:23:25 +00:00
+config NF_CONNTRACK_DESTROY_HOOK
2023-07-31 19:31:34 +00:00
+ bool
+
config NF_CONNTRACK
tristate "Netfilter connection tracking support"
default m if NETFILTER_ADVANCED=n
select NF_DEFRAG_IPV4
select NF_DEFRAG_IPV6 if IPV6 != n
2023-12-22 19:23:25 +00:00
+ select NF_CONNTRACK_DESTROY_HOOK
2023-07-31 19:31:34 +00:00
help
Connection tracking keeps a record of what packets have passed
through your machine, in order to figure out how they are related
diff -urpN linux-6.1.38.old/net/netfilter/nf_conntrack_core.c linux-6.1.38/net/netfilter/nf_conntrack_core.c
--- linux-6.1.38.old/net/netfilter/nf_conntrack_core.c 2023-07-05 23:27:38.000000000 +0600
+++ linux-6.1.38/net/netfilter/nf_conntrack_core.c 2023-07-14 12:33:45.580092713 +0600
@@ -582,9 +582,30 @@ static void destroy_gre_conntrack(struct
#endif
}
2023-12-22 19:23:25 +00:00
+#ifdef CONFIG_NF_CONNTRACK_DESTROY_HOOK
2023-07-31 19:31:34 +00:00
+
2023-12-22 19:23:25 +00:00
+static void (*nf_ct_destroy_hook)(struct nf_conn *) __rcu __read_mostly = NULL;
2023-07-31 19:31:34 +00:00
+
2023-12-22 19:23:25 +00:00
+void register_nf_ct_destroy_hook(void (*hook)(struct nf_conn *))
2023-07-31 19:31:34 +00:00
+{
2023-12-22 19:23:25 +00:00
+ rcu_assign_pointer(nf_ct_destroy_hook, hook);
2023-07-31 19:31:34 +00:00
+}
2023-12-22 19:23:25 +00:00
+EXPORT_SYMBOL(register_nf_ct_destroy_hook);
2023-07-31 19:31:34 +00:00
+
2023-12-22 19:23:25 +00:00
+void unregister_nf_ct_destroy_hook(void)
2023-07-31 19:31:34 +00:00
+{
2023-12-22 19:23:25 +00:00
+ rcu_assign_pointer(nf_ct_destroy_hook, NULL);
2023-07-31 19:31:34 +00:00
+}
+
2023-12-22 19:23:25 +00:00
+EXPORT_SYMBOL(unregister_nf_ct_destroy_hook);
2023-07-31 19:31:34 +00:00
+#endif
+
void nf_ct_destroy(struct nf_conntrack *nfct)
{
struct nf_conn *ct = (struct nf_conn *)nfct;
2023-12-22 19:23:25 +00:00
+#ifdef CONFIG_NF_CONNTRACK_DESTROY_HOOK
2023-07-31 19:31:34 +00:00
+ void (*hook)(struct nf_conn *);
+#endif
pr_debug("%s(%p)\n", __func__, ct);
WARN_ON(refcount_read(&nfct->use) != 0);
@@ -594,6 +615,12 @@ void nf_ct_destroy(struct nf_conntrack *
return;
}
2023-12-22 19:23:25 +00:00
+#ifdef CONFIG_NF_CONNTRACK_DESTROY_HOOK
+ hook = rcu_dereference(nf_ct_destroy_hook);
2023-07-31 19:31:34 +00:00
+ if (hook)
+ hook(ct);
+#endif
+
if (unlikely(nf_ct_protonum(ct) == IPPROTO_GRE))
destroy_gre_conntrack(ct);