]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
92703eee PM |
2 | /* |
3 | * NetBIOS name service broadcast connection tracking helper | |
4 | * | |
5 | * (c) 2005 Patrick McHardy <kaber@trash.net> | |
92703eee PM |
6 | */ |
7 | /* | |
8 | * This helper tracks locally originating NetBIOS name service | |
9 | * requests by issuing permanent expectations (valid until | |
10 | * timing out) matching all reply connections from the | |
11 | * destination network. The only NetBIOS specific thing is | |
12 | * actually the port number. | |
13 | */ | |
14 | #include <linux/kernel.h> | |
15 | #include <linux/module.h> | |
16 | #include <linux/init.h> | |
92703eee | 17 | #include <linux/in.h> |
92703eee PM |
18 | |
19 | #include <net/netfilter/nf_conntrack.h> | |
20 | #include <net/netfilter/nf_conntrack_helper.h> | |
21 | #include <net/netfilter/nf_conntrack_expect.h> | |
22 | ||
23 | #define NMBD_PORT 137 | |
24 | ||
25 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); | |
26 | MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper"); | |
27 | MODULE_LICENSE("GPL"); | |
28 | MODULE_ALIAS("ip_conntrack_netbios_ns"); | |
4dc06f96 | 29 | MODULE_ALIAS_NFCT_HELPER("netbios_ns"); |
92703eee PM |
30 | |
31 | static unsigned int timeout __read_mostly = 3; | |
d6444062 | 32 | module_param(timeout, uint, 0400); |
92703eee PM |
33 | MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds"); |
34 | ||
6002f266 PM |
35 | static struct nf_conntrack_expect_policy exp_policy = { |
36 | .max_expected = 1, | |
37 | }; | |
38 | ||
93557f53 | 39 | static int netbios_ns_help(struct sk_buff *skb, unsigned int protoff, |
433029ec TY |
40 | struct nf_conn *ct, |
41 | enum ip_conntrack_info ctinfo) | |
93557f53 | 42 | { |
433029ec | 43 | return nf_conntrack_broadcast_help(skb, ct, ctinfo, timeout); |
93557f53 JO |
44 | } |
45 | ||
92703eee PM |
46 | static struct nf_conntrack_helper helper __read_mostly = { |
47 | .name = "netbios-ns", | |
93557f53 | 48 | .tuple.src.l3num = NFPROTO_IPV4, |
09640e63 | 49 | .tuple.src.u.udp.port = cpu_to_be16(NMBD_PORT), |
92703eee | 50 | .tuple.dst.protonum = IPPROTO_UDP, |
92703eee | 51 | .me = THIS_MODULE, |
93557f53 | 52 | .help = netbios_ns_help, |
6002f266 | 53 | .expect_policy = &exp_policy, |
92703eee PM |
54 | }; |
55 | ||
56 | static int __init nf_conntrack_netbios_ns_init(void) | |
57 | { | |
dcf67740 FW |
58 | NF_CT_HELPER_BUILD_BUG_ON(0); |
59 | ||
6002f266 | 60 | exp_policy.timeout = timeout; |
92703eee PM |
61 | return nf_conntrack_helper_register(&helper); |
62 | } | |
63 | ||
64 | static void __exit nf_conntrack_netbios_ns_fini(void) | |
65 | { | |
66 | nf_conntrack_helper_unregister(&helper); | |
67 | } | |
68 | ||
69 | module_init(nf_conntrack_netbios_ns_init); | |
70 | module_exit(nf_conntrack_netbios_ns_fini); |