8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9 #include <linux/module.h>
12 #include <linux/netfilter_ipv4/ip_tables.h>
13 #include <linux/netfilter_ipv6/ip6_tables.h>
14 #include <linux/netfilter/x_tables.h>
23 static unsigned int xt_ct_target_v0(
struct sk_buff *
skb,
30 if (skb->nfct !=
NULL)
40 static unsigned int xt_ct_target_v1(
struct sk_buff *
skb,
47 if (skb->nfct !=
NULL)
76 xt_ct_set_helper(
struct nf_conn *ct,
const char *helper_name,
83 proto = xt_ct_find_proto(par);
85 pr_info(
"You must specify a L4 protocol, and not use "
86 "inversions on it.\n");
93 pr_info(
"No such helper \"%s\"\n", helper_name);
99 module_put(helper->
me);
118 ct = nf_ct_untracked_get();
123 #ifndef CONFIG_NF_CONNTRACK_ZONES
145 ret = xt_ct_set_helper(ct, info->
helper, par);
164 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
171 timeout_put(timeout);
177 const char *timeout_name)
179 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
189 if (timeout_find_get ==
NULL) {
191 pr_info(
"Timeout policy base is empty\n");
195 proto = xt_ct_find_proto(par);
198 pr_info(
"You must specify a L4 protocol, and not use "
199 "inversions on it.\n");
203 timeout = timeout_find_get(timeout_name);
204 if (timeout ==
NULL) {
206 pr_info(
"No such timeout policy \"%s\"\n", timeout_name);
210 if (timeout->l3num != par->
family) {
212 pr_info(
"Timeout policy `%s' can only be used by L3 protocol "
213 "number %d\n", timeout_name, timeout->l3num);
214 goto err_put_timeout;
220 if (timeout->l4proto->l4proto != l4proto->l4proto) {
222 pr_info(
"Timeout policy `%s' can only be used by L4 protocol "
224 timeout_name, timeout->l4proto->l4proto);
225 goto err_put_timeout;
227 timeout_ext = nf_ct_timeout_ext_add(ct, timeout,
GFP_ATOMIC);
228 if (timeout_ext ==
NULL)
232 __xt_ct_tg_timeout_put(timeout);
252 ct = nf_ct_untracked_get();
257 #ifndef CONFIG_NF_CONNTRACK_ZONES
279 ret = xt_ct_set_helper(ct, info->
helper, par);
285 ret = xt_ct_set_timeout(ct, par, info->
timeout);
310 if (!nf_ct_is_untracked(ct)) {
311 help = nfct_help(ct);
313 module_put(help->
helper->me);
320 static void xt_ct_destroy_timeout(
struct nf_conn *ct)
322 #ifdef CONFIG_NF_CONNTRACK_TIMEOUT
324 typeof(nf_ct_timeout_put_hook) timeout_put;
330 timeout_ext = nf_ct_timeout_find(ct);
332 timeout_put(timeout_ext->
timeout);
344 if (!nf_ct_is_untracked(ct)) {
345 help = nfct_help(ct);
347 module_put(help->
helper->me);
351 xt_ct_destroy_timeout(ct);
361 .checkentry = xt_ct_tg_check_v0,
362 .destroy = xt_ct_tg_destroy_v0,
363 .target = xt_ct_target_v0,
372 .checkentry = xt_ct_tg_check_v1,
373 .destroy = xt_ct_tg_destroy_v1,
374 .target = xt_ct_target_v1,
380 static int __init xt_ct_tg_init(
void)
385 static void __exit xt_ct_tg_exit(
void)