<div dir="ltr"><div>Hi,</div><div><br></div><div>I need to build the module attached but do not know the right way to do,</div><div>I do not want to change the original kernel, just run this module<br></div><div><br></div><div>I downloaded the kernel.src and applied the patch and went back to generate the RPM through SPEC, but got the following error.</div><div><br></div><div><p style="margin:0px;font-size:13px;font-family:Menlo">CC [M] net/sched//act_connmark.o</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:</b> In function ‘<b>tcf_connmark_init</b>’:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:112:2:</b> <span style="color:rgb(195,55,32)"><b>error: </b></span>too few arguments to function ‘<b>tcf_hash_check</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> if (!tcf_hash_check(parm->index, a, bind)) {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:93:20:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>declared here</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:113:3:</b> <span style="color:rgb(195,55,32)"><b>error: </b></span>too few arguments to function ‘<b>tcf_hash_create</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> ret = tcf_hash_create(parm->index, est, a, sizeof(*ci), bind);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:95:20:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>declared here</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:121:3:</b> <span style="color:rgb(213,59,211)"><b>warning: </b></span>passing argument 1 of ‘<b>tcf_hash_insert</b>’ from incompatible pointer type [enabled by default]</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> tcf_hash_insert(a);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:99:6:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>expected ‘<b>struct tcf_common *</b>’ but argument is of type ‘<b>struct tc_action *</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:121:3:</b> <span style="color:rgb(195,55,32)"><b>error: </b></span>too few arguments to function ‘<b>tcf_hash_insert</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> tcf_hash_insert(a);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:99:6:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>declared here</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:127:3:</b> <span style="color:rgb(213,59,211)"><b>warning: </b></span>passing argument 1 of ‘<b>tcf_hash_release</b>’ from incompatible pointer type [enabled by default]</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> tcf_hash_release(a, bind);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:87:5:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>expected ‘<b>struct tcf_common *</b>’ but argument is of type ‘<b>struct tc_action *</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> int tcf_hash_release(struct tcf_common *p, int bind,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:127:3:</b> <span style="color:rgb(195,55,32)"><b>error: </b></span>too few arguments to function ‘<b>tcf_hash_release</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> tcf_hash_release(a, bind);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:87:5:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>declared here</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> int tcf_hash_release(struct tcf_common *p, int bind,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:</b> In function ‘<b>connmark_init_module</b>’:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>net/sched//act_connmark.c:179:2:</b> <span style="color:rgb(195,55,32)"><b>error: </b></span>too many arguments to function ‘<b>tcf_register_action</b>’</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> return tcf_register_action(&act_connmark_ops, CONNMARK_TAB_MASK);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">In file included from <b>net/sched//act_connmark.c:23:0</b>:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"><b>include/net/act_api.h:101:5:</b> <span style="color:rgb(52,187,199)"><b>note: </b></span>declared here</p>
<p style="margin:0px;font-size:13px;font-family:Menlo"> int tcf_register_action(struct tc_action_ops *a);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)"><b> ^</b></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">make[1]: *** [net/sched//act_connmark.o] Error 1</p>
<p style="margin:0px;font-size:13px;font-family:Menlo">make: *** [_module_net/sched/] Error 2</p></div><div><br></div><div><br></div><div>Kernel patch module</div><div><br></div><div><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">diff --git a/include/net/tc_act/tc_connmark<span style="color:rgb(0,165,0);background-color:rgb(230,230,0)">.h</span> b/include/net/tc_act/tc_connmark<span style="color:rgb(0,165,0);background-color:rgb(230,230,0)">.h</span></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">new file mode 100644</p>
<p style="margin:0px;font-size:13px;font-family:Menlo">index 0000000..5c1104c</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">--- /dev/null</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">+++ b/include/net/tc_act/tc_connmark<span style="color:rgb(0,165,0);background-color:rgb(230,230,0)">.h</span></p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(206,121,36)">@@ -0,0 +1,14 @@</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#ifndef __NET_TC_CONNMARK_H</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#define __NET_TC_CONNMARK_H</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/act_api<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+struct tcf_connmark_info {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tcf_common common;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ u16 zone;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+};</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#define to_connmark(a) \</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ container_of(a->priv, struct tcf_connmark_info, common)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#endif /* __NET_TC_CONNMARK_H */</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">diff --git a/include/uapi/linux/tc_act/tc_connmark<span style="color:rgb(0,165,0);background-color:rgb(230,230,0)">.h</span> b/include/uapi/linux/tc_act/tc_connmark<span style="color:rgb(0,165,0);background-color:rgb(230,230,0)">.h</span></p>
<p style="margin:0px;font-size:13px;font-family:Menlo">new file mode 100644</p>
<p style="margin:0px;font-size:13px;font-family:Menlo">index 0000000..994b097</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">--- /dev/null</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">+++ b/include/uapi/linux/tc_act/tc_connmark<span style="color:rgb(0,165,0);background-color:rgb(230,230,0)">.h</span></p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(206,121,36)">@@ -0,0 +1,22 @@</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#ifndef __UAPI_TC_CONNMARK_H</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#define __UAPI_TC_CONNMARK_H</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/types<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/pkt_cls<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#define TCA_ACT_CONNMARK 14</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+struct tc_connmark {</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ tc_gen;</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ __u16 zone;</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+};</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+enum {</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ TCA_CONNMARK_UNSPEC,</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ TCA_CONNMARK_PARMS,</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ TCA_CONNMARK_TM,</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ __TCA_CONNMARK_MAX</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+};</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#define TCA_CONNMARK_MAX (__TCA_CONNMARK_MAX - 1)</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#endif</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">diff --git a/net/sched/Kconfig b/net/sched/Kconfig</p><p style="margin:0px;font-size:13px;font-family:Menlo">index 4669435..475e35e 100644</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">--- a/net/sched/Kconfig</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">+++ b/net/sched/Kconfig</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(206,121,36)">@@ -549,6 +549,17 @@</p><p style="margin:0px;font-size:13px;font-family:Menlo"> To compile this code as a module, choose M here: the</p><p style="margin:0px;font-size:13px;font-family:Menlo"> module will be called act_police.</p><p style="margin:0px;font-size:13px;font-family:Menlo;min-height:15px"><br></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+config NET_ACT_CONNMARK</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ tristate "Netfilter Connection Mark Retriever"</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ depends on NET_CLS_ACT && NETFILTER && IP_NF_IPTABLES</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ---help---</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ Say Y here to allow retrieving of conn mark</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ If unsure, say N.</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ To compile this code as a module, choose M here: the</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ module will be called act_connmark.</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo"> config NET_ACT_GACT</p><p style="margin:0px;font-size:13px;font-family:Menlo"> tristate "Generic actions"</p><p style="margin:0px;font-size:13px;font-family:Menlo"> depends on NET_CLS_ACT</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">diff --git a/net/sched/Makefile b/net/sched/Makefile</p><p style="margin:0px;font-size:13px;font-family:Menlo">index 7ca2b4e..7ca7f4c 100644</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">--- a/net/sched/Makefile</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">
</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">+++ b/net/sched/Makefile</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">+++ b/net/sched/Makefile</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(206,121,36)">@@ -16,6 +16,7 @@</p><p style="margin:0px;font-size:13px;font-family:Menlo"> obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o</p><p style="margin:0px;font-size:13px;font-family:Menlo"> obj-$(CONFIG_NET_ACT_SKBEDIT) += act_skbedit.o</p><p style="margin:0px;font-size:13px;font-family:Menlo"> obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+obj-$(CONFIG_NET_ACT_CONNMARK) += act_connmark.o</p><p style="margin:0px;font-size:13px;font-family:Menlo"> obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o</p><p style="margin:0px;font-size:13px;font-family:Menlo"> obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o</p><p style="margin:0px;font-size:13px;font-family:Menlo"> obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">diff --git a/net/sched/act_connmark.c b/net/sched/act_connmark.c</p><p style="margin:0px;font-size:13px;font-family:Menlo">new file mode 100644</p><p style="margin:0px;font-size:13px;font-family:Menlo">index 0000000..8e47251</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">--- /dev/null</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">+++ b/net/sched/act_connmark.c</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(206,121,36)">@@ -0,0 +1,192 @@</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+/*</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * net/sched/act_connmark.c netfilter connmark retriever action</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * skb mark is over-written</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ *</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * Copyright (c) 2011 Felix Fietkau <<a href="mailto:nbd@openwrt.org">nbd@openwrt.org</a>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ *</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * This program is free software; you can redistribute it and/or modify</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * it under the terms of the GNU General Public License as published by</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * the Free Software Foundation; either version 2 of the License, or</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ * (at your option) any later version.</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+*/</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/module<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/init<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/kernel<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/skbuff<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/rtnetlink<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/pkt_cls<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/ip<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <linux/ipv6<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/netlink<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/pkt_sched<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/act_api<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <uapi/linux/tc_act/tc_connmark<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/tc_act/tc_connmark<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/netfilter/nf_conntrack<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/netfilter/nf_conntrack_core<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#include <net/netfilter/nf_conntrack_zones<span style="color:rgb(0,166,178);background-color:rgb(230,230,0)">.h</span>></p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,189,38)">
</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+#define CONNMARK_TAB_MASK 3</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static int tcf_connmark(struct sk_buff *skb, const struct tc_action *a,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tcf_result *res)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+{</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ const struct nf_conntrack_tuple_hash *thash;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct nf_conntrack_tuple tuple;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ enum ip_conntrack_info ctinfo;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tcf_connmark_info *ca = a->priv;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct nf_conn *c;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ int proto;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ spin_lock(&ca->tcf_lock);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ca->tcf_tm.lastuse = jiffies;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ bstats_update(&ca->tcf_bstats, skb);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (skb->protocol == htons(ETH_P_IP)) {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (skb->len < sizeof(struct iphdr))</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto out;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ proto = NFPROTO_IPV4;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ } else if (skb->protocol == htons(ETH_P_IPV6)) {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (skb->len < sizeof(struct ipv6hdr))</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto out;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ proto = NFPROTO_IPV6;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ } else {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto out;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ }</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ c = nf_ct_get(skb, &ctinfo);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (c) {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ skb->mark = c->mark;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ /* using overlimits stats to count how many packets marked */</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ca->tcf_qstats.overlimits++;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ nf_ct_put(c);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto out;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ }</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb),</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ proto, &tuple))</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto out;</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ thash = nf_conntrack_find_get(dev_net(skb->dev), ca->zone, &tuple);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (!thash)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto out;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ c = nf_ct_tuplehash_to_ctrack(thash);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ /* using overlimits stats to count how many packets marked */</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ca->tcf_qstats.overlimits++;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ skb->mark = c->mark;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ nf_ct_put(c);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+out:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ skb->nfct = NULL;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ spin_unlock(&ca->tcf_lock);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return ca->tcf_action;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+}</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static const struct nla_policy connmark_policy[TCA_CONNMARK_MAX + 1] = {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ [TCA_CONNMARK_PARMS] = { .len = sizeof(struct tc_connmark) },</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+};</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static int tcf_connmark_init(struct net *net, struct nlattr *nla,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct nlattr *est, struct tc_action *a,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ int ovr, int bind)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+{</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct nlattr *tb[TCA_CONNMARK_MAX + 1];</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tcf_connmark_info *ci;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tc_connmark *parm;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ int ret = 0;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (!nla)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return -EINVAL;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ret = nla_parse_nested(tb, TCA_CONNMARK_MAX, nla, connmark_policy);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (ret < 0)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return ret;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ parm = nla_data(tb[TCA_CONNMARK_PARMS]);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (!tcf_hash_check(parm->index, a, bind)) {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ret = tcf_hash_create(parm->index, est, a, sizeof(*ci), bind);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (ret)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return ret;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ci = to_connmark(a);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ci->tcf_action = parm->action;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ci->zone = parm->zone;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ tcf_hash_insert(a);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ret = ACT_P_CREATED;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ } else {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ci = to_connmark(a);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (bind)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return 0;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ tcf_hash_release(a, bind);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (!ovr)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return -EEXIST;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ /* replacing action and zone */</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ci->tcf_action = parm->action;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ ci->zone = parm->zone;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ }</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return ret;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+}</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ int bind, int ref)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+{</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ unsigned char *b = skb_tail_pointer(skb);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tcf_connmark_info *ci = a->priv;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tc_connmark opt = {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .index = ci->tcf_index,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .refcnt = ci->tcf_refcnt - ref,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .bindcnt = ci->tcf_bindcnt - bind,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .action = ci->tcf_action,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .zone = ci->zone,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ };</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ struct tcf_t t;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (nla_put(skb, TCA_CONNMARK_PARMS, sizeof(opt), &opt))</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto nla_put_failure;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ t.install = jiffies_to_clock_t(jiffies - ci->tcf_tm.install);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ t.lastuse = jiffies_to_clock_t(jiffies - ci->tcf_tm.lastuse);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ t.expires = jiffies_to_clock_t(ci->tcf_tm.expires);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ if (nla_put(skb, TCA_CONNMARK_TM, sizeof(t), &t))</p><p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ goto nla_put_failure;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return skb->len;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+nla_put_failure:</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ nlmsg_trim(skb, b);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return -1;</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+}</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static struct tc_action_ops act_connmark_ops = {</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .kind = "connmark",</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .type = TCA_ACT_CONNMARK,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .owner = THIS_MODULE,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .act = tcf_connmark,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .dump = tcf_connmark_dump,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ .init = tcf_connmark_init,</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+};</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static int __init connmark_init_module(void)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+{</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ return tcf_register_action(&act_connmark_ops, CONNMARK_TAB_MASK);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+}</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+static void __exit connmark_cleanup_module(void)</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+{</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+ tcf_unregister_action(&act_connmark_ops);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+}</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+module_init(connmark_init_module);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+module_exit(connmark_cleanup_module);</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+MODULE_AUTHOR("Felix Fietkau <<a href="mailto:nbd@openwrt.org">nbd@openwrt.org</a>>");</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+MODULE_DESCRIPTION("Connection tracking mark restoring");</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+MODULE_LICENSE("GPL");</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(52,187,199)">+</p>
<p style="margin:0px;font-size:13px;font-family:Menlo;color:rgb(213,59,211)">-- </p>
<p style="margin:0px;font-size:13px;font-family:Menlo">cgit v0.10.2</p><p style="margin:0px;font-size:13px;font-family:Menlo;min-height:15px"> </p></div></div>