Blame view
net/netfilter/nf_nat_tftp.c
1.44 KB
d2912cb15 treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
a536df35b [NETFILTER]: nf_c... |
2 |
/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu> |
a536df35b [NETFILTER]: nf_c... |
3 4 5 |
*/ #include <linux/module.h> |
a536df35b [NETFILTER]: nf_c... |
6 |
#include <linux/udp.h> |
a536df35b [NETFILTER]: nf_c... |
7 8 |
#include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_expect.h> |
1afc56794 netfilter: nf_ct_... |
9 |
#include <net/netfilter/nf_nat_helper.h> |
a536df35b [NETFILTER]: nf_c... |
10 |
#include <linux/netfilter/nf_conntrack_tftp.h> |
53b11308a netfilter: nf_nat... |
11 |
#define NAT_HELPER_NAME "tftp" |
a536df35b [NETFILTER]: nf_c... |
12 13 14 |
MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>"); MODULE_DESCRIPTION("TFTP NAT helper"); MODULE_LICENSE("GPL"); |
53b11308a netfilter: nf_nat... |
15 16 17 18 |
MODULE_ALIAS_NF_NAT_HELPER(NAT_HELPER_NAME); static struct nf_conntrack_nat_helper nat_helper_tftp = NF_CT_NAT_HELPER_INIT(NAT_HELPER_NAME); |
a536df35b [NETFILTER]: nf_c... |
19 |
|
3db05fea5 [NETFILTER]: Repl... |
20 |
static unsigned int help(struct sk_buff *skb, |
a536df35b [NETFILTER]: nf_c... |
21 22 23 |
enum ip_conntrack_info ctinfo, struct nf_conntrack_expect *exp) { |
de24b4ebb [NETFILTER]: nf_{... |
24 |
const struct nf_conn *ct = exp->master; |
a536df35b [NETFILTER]: nf_c... |
25 26 27 28 29 |
exp->saved_proto.udp.port = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port; exp->dir = IP_CT_DIR_REPLY; exp->expectfn = nf_nat_follow_master; |
3c00fb0bf netfilter: nf_con... |
30 |
if (nf_ct_expect_related(exp, 0) != 0) { |
b20ab9cc6 netfilter: nf_ct_... |
31 |
nf_ct_helper_log(skb, exp->master, "cannot add expectation"); |
a536df35b [NETFILTER]: nf_c... |
32 |
return NF_DROP; |
b20ab9cc6 netfilter: nf_ct_... |
33 |
} |
a536df35b [NETFILTER]: nf_c... |
34 35 36 37 38 |
return NF_ACCEPT; } static void __exit nf_nat_tftp_fini(void) { |
53b11308a netfilter: nf_nat... |
39 |
nf_nat_helper_unregister(&nat_helper_tftp); |
a9b3cd7f3 rcu: convert uses... |
40 |
RCU_INIT_POINTER(nf_nat_tftp_hook, NULL); |
a536df35b [NETFILTER]: nf_c... |
41 42 43 44 45 |
synchronize_rcu(); } static int __init nf_nat_tftp_init(void) { |
d1332e0ab [NETFILTER]: remo... |
46 |
BUG_ON(nf_nat_tftp_hook != NULL); |
53b11308a netfilter: nf_nat... |
47 |
nf_nat_helper_register(&nat_helper_tftp); |
a9b3cd7f3 rcu: convert uses... |
48 |
RCU_INIT_POINTER(nf_nat_tftp_hook, help); |
a536df35b [NETFILTER]: nf_c... |
49 50 51 52 53 |
return 0; } module_init(nf_nat_tftp_init); module_exit(nf_nat_tftp_fini); |