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