dm-crypt: use __bio_add_page to add single page to clone bio
[linux-block.git] / net / netfilter / nf_conntrack_netbios_ns.c
CommitLineData
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
0e906607 23#define HELPER_NAME "netbios-ns"
92703eee
PM
24#define NMBD_PORT 137
25
26MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
27MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper");
28MODULE_LICENSE("GPL");
29MODULE_ALIAS("ip_conntrack_netbios_ns");
0e906607 30MODULE_ALIAS_NFCT_HELPER(HELPER_NAME);
92703eee
PM
31
32static unsigned int timeout __read_mostly = 3;
d6444062 33module_param(timeout, uint, 0400);
92703eee
PM
34MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds");
35
6002f266
PM
36static struct nf_conntrack_expect_policy exp_policy = {
37 .max_expected = 1,
38};
39
93557f53 40static int netbios_ns_help(struct sk_buff *skb, unsigned int protoff,
433029ec
TY
41 struct nf_conn *ct,
42 enum ip_conntrack_info ctinfo)
93557f53 43{
433029ec 44 return nf_conntrack_broadcast_help(skb, ct, ctinfo, timeout);
93557f53
JO
45}
46
92703eee 47static struct nf_conntrack_helper helper __read_mostly = {
0e906607 48 .name = HELPER_NAME,
93557f53 49 .tuple.src.l3num = NFPROTO_IPV4,
09640e63 50 .tuple.src.u.udp.port = cpu_to_be16(NMBD_PORT),
92703eee 51 .tuple.dst.protonum = IPPROTO_UDP,
92703eee 52 .me = THIS_MODULE,
93557f53 53 .help = netbios_ns_help,
6002f266 54 .expect_policy = &exp_policy,
92703eee
PM
55};
56
57static int __init nf_conntrack_netbios_ns_init(void)
58{
dcf67740
FW
59 NF_CT_HELPER_BUILD_BUG_ON(0);
60
6002f266 61 exp_policy.timeout = timeout;
92703eee
PM
62 return nf_conntrack_helper_register(&helper);
63}
64
65static void __exit nf_conntrack_netbios_ns_fini(void)
66{
67 nf_conntrack_helper_unregister(&helper);
68}
69
70module_init(nf_conntrack_netbios_ns_init);
71module_exit(nf_conntrack_netbios_ns_fini);