]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - net/netfilter/nf_conntrack_netbios_ns.c
Merge tag 'trace-v5.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[mirror_ubuntu-jammy-kernel.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
23#define NMBD_PORT 137
24
25MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
26MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper");
27MODULE_LICENSE("GPL");
28MODULE_ALIAS("ip_conntrack_netbios_ns");
4dc06f96 29MODULE_ALIAS_NFCT_HELPER("netbios_ns");
92703eee
PM
30
31static unsigned int timeout __read_mostly = 3;
d6444062 32module_param(timeout, uint, 0400);
92703eee
PM
33MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds");
34
6002f266
PM
35static struct nf_conntrack_expect_policy exp_policy = {
36 .max_expected = 1,
37};
38
93557f53 39static 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
46static 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
56static 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
64static void __exit nf_conntrack_netbios_ns_fini(void)
65{
66 nf_conntrack_helper_unregister(&helper);
67}
68
69module_init(nf_conntrack_netbios_ns_init);
70module_exit(nf_conntrack_netbios_ns_fini);