blob: 4fd040575ffe4ed9bd887d9356dc9c6d84b73966 [file] [log] [blame]
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08001/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
Patrick McHardyf229f6c2013-04-06 15:24:29 +02003 * (C) 2006-2012 Patrick McHardy <kaber@trash.net>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08008 */
9
10#include <linux/types.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080011#include <linux/timer.h>
12#include <linux/module.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080013#include <linux/udp.h>
14#include <linux/seq_file.h>
15#include <linux/skbuff.h>
16#include <linux/ipv6.h>
17#include <net/ip6_checksum.h>
18#include <net/checksum.h>
Martin Josefssonf6180122006-11-29 02:35:01 +010019
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080020#include <linux/netfilter.h>
21#include <linux/netfilter_ipv4.h>
22#include <linux/netfilter_ipv6.h>
Martin Josefsson605dcad2006-11-29 02:35:06 +010023#include <net/netfilter/nf_conntrack_l4proto.h>
Martin Josefssonf6180122006-11-29 02:35:01 +010024#include <net/netfilter/nf_conntrack_ecache.h>
Patrick McHardyf01ffbd2007-12-17 22:38:49 -080025#include <net/netfilter/nf_log.h>
Christoph Paasch9d2493f2009-03-16 15:15:35 +010026#include <net/netfilter/ipv4/nf_conntrack_ipv4.h>
27#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080028
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +010029static unsigned int udp_timeouts[UDP_CT_MAX] = {
30 [UDP_CT_UNREPLIED] = 30*HZ,
31 [UDP_CT_REPLIED] = 180*HZ,
32};
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080033
Gao feng0ce490a2012-05-28 21:04:13 +000034static inline struct nf_udp_net *udp_pernet(struct net *net)
35{
36 return &net->ct.nf_ct_proto.udp;
37}
38
Jan Engelhardt09f263c2008-04-14 11:15:53 +020039static bool udp_pkt_to_tuple(const struct sk_buff *skb,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080040 unsigned int dataoff,
Eric W. Biedermana31f1ad2015-09-18 14:33:04 -050041 struct net *net,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080042 struct nf_conntrack_tuple *tuple)
43{
Jan Engelhardtda3f13c2008-01-31 04:52:29 -080044 const struct udphdr *hp;
45 struct udphdr _hdr;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080046
47 /* Actually only need first 8 bytes. */
48 hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
49 if (hp == NULL)
Jan Engelhardt09f263c2008-04-14 11:15:53 +020050 return false;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080051
52 tuple->src.u.udp.port = hp->source;
53 tuple->dst.u.udp.port = hp->dest;
54
Jan Engelhardt09f263c2008-04-14 11:15:53 +020055 return true;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080056}
57
Jan Engelhardt09f263c2008-04-14 11:15:53 +020058static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,
59 const struct nf_conntrack_tuple *orig)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080060{
61 tuple->src.u.udp.port = orig->dst.u.udp.port;
62 tuple->dst.u.udp.port = orig->src.u.udp.port;
Jan Engelhardt09f263c2008-04-14 11:15:53 +020063 return true;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080064}
65
66/* Print out the per-protocol part of the tuple. */
Joe Perches824f1fb2014-09-29 16:08:22 -070067static void udp_print_tuple(struct seq_file *s,
68 const struct nf_conntrack_tuple *tuple)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080069{
Joe Perches824f1fb2014-09-29 16:08:22 -070070 seq_printf(s, "sport=%hu dport=%hu ",
71 ntohs(tuple->src.u.udp.port),
72 ntohs(tuple->dst.u.udp.port));
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080073}
74
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010075static unsigned int *udp_get_timeouts(struct net *net)
76{
Gao feng0ce490a2012-05-28 21:04:13 +000077 return udp_pernet(net)->timeouts;
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010078}
79
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080080/* Returns verdict for packet, and may modify conntracktype */
Patrick McHardyc88130b2008-01-31 04:42:11 -080081static int udp_packet(struct nf_conn *ct,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080082 const struct sk_buff *skb,
83 unsigned int dataoff,
84 enum ip_conntrack_info ctinfo,
Jan Engelhardt76108ce2008-10-08 11:35:00 +020085 u_int8_t pf,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010086 unsigned int hooknum,
87 unsigned int *timeouts)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080088{
89 /* If we've seen traffic both ways, this is some kind of UDP
90 stream. Extend timeout. */
Patrick McHardyc88130b2008-01-31 04:42:11 -080091 if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +010092 nf_ct_refresh_acct(ct, ctinfo, skb,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010093 timeouts[UDP_CT_REPLIED]);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080094 /* Also, more likely to be important, and not a probe */
Patrick McHardyc88130b2008-01-31 04:42:11 -080095 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
Patrick McHardy858b31332010-02-03 13:48:53 +010096 nf_conntrack_event_cache(IPCT_ASSURED, ct);
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +010097 } else {
98 nf_ct_refresh_acct(ct, ctinfo, skb,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010099 timeouts[UDP_CT_UNREPLIED]);
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +0100100 }
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800101 return NF_ACCEPT;
102}
103
104/* Called when a new connection for this protocol found. */
Jan Engelhardt09f263c2008-04-14 11:15:53 +0200105static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100106 unsigned int dataoff, unsigned int *timeouts)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800107{
Jan Engelhardt09f263c2008-04-14 11:15:53 +0200108 return true;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800109}
110
Patrick McHardy8fea97e2010-02-15 17:45:08 +0100111static int udp_error(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
112 unsigned int dataoff, enum ip_conntrack_info *ctinfo,
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200113 u_int8_t pf,
Patrick McHardy96f6bf82006-04-06 14:19:24 -0700114 unsigned int hooknum)
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800115{
116 unsigned int udplen = skb->len - dataoff;
Jan Engelhardtda3f13c2008-01-31 04:52:29 -0800117 const struct udphdr *hdr;
118 struct udphdr _hdr;
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800119
120 /* Header is too small? */
121 hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
122 if (hdr == NULL) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200123 if (LOG_INVALID(net, IPPROTO_UDP))
Gao feng30e0c6a2013-03-24 23:50:40 +0000124 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800125 "nf_ct_udp: short packet ");
126 return -NF_ACCEPT;
127 }
128
129 /* Truncated/malformed packets */
130 if (ntohs(hdr->len) > udplen || ntohs(hdr->len) < sizeof(*hdr)) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200131 if (LOG_INVALID(net, IPPROTO_UDP))
Gao feng30e0c6a2013-03-24 23:50:40 +0000132 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800133 "nf_ct_udp: truncated/malformed packet ");
134 return -NF_ACCEPT;
135 }
136
137 /* Packet with no checksum */
138 if (!hdr->check)
139 return NF_ACCEPT;
140
141 /* Checksum invalid? Ignore.
142 * We skip checking packets on the outgoing path
Patrick McHardy84fa7932006-08-29 16:44:56 -0700143 * because the checksum is assumed to be correct.
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800144 * FIXME: Source route IP option packets --RR */
Alexey Dobriyanc04d0552008-10-08 11:35:08 +0200145 if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
Patrick McHardy96f6bf82006-04-06 14:19:24 -0700146 nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200147 if (LOG_INVALID(net, IPPROTO_UDP))
Gao feng30e0c6a2013-03-24 23:50:40 +0000148 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800149 "nf_ct_udp: bad UDP checksum ");
150 return -NF_ACCEPT;
151 }
152
153 return NF_ACCEPT;
154}
155
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100156#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
157
158#include <linux/netfilter/nfnetlink.h>
159#include <linux/netfilter/nfnetlink_cttimeout.h>
160
Gao feng8264deb2012-05-28 21:04:23 +0000161static int udp_timeout_nlattr_to_obj(struct nlattr *tb[],
162 struct net *net, void *data)
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100163{
164 unsigned int *timeouts = data;
Gao feng8264deb2012-05-28 21:04:23 +0000165 struct nf_udp_net *un = udp_pernet(net);
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100166
167 /* set default timeouts for UDP. */
Gao feng8264deb2012-05-28 21:04:23 +0000168 timeouts[UDP_CT_UNREPLIED] = un->timeouts[UDP_CT_UNREPLIED];
169 timeouts[UDP_CT_REPLIED] = un->timeouts[UDP_CT_REPLIED];
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100170
171 if (tb[CTA_TIMEOUT_UDP_UNREPLIED]) {
172 timeouts[UDP_CT_UNREPLIED] =
173 ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDP_UNREPLIED])) * HZ;
174 }
175 if (tb[CTA_TIMEOUT_UDP_REPLIED]) {
176 timeouts[UDP_CT_REPLIED] =
177 ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDP_REPLIED])) * HZ;
178 }
179 return 0;
180}
181
182static int
183udp_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
184{
185 const unsigned int *timeouts = data;
186
David S. Miller3c60a172012-04-01 18:48:06 -0400187 if (nla_put_be32(skb, CTA_TIMEOUT_UDP_UNREPLIED,
188 htonl(timeouts[UDP_CT_UNREPLIED] / HZ)) ||
189 nla_put_be32(skb, CTA_TIMEOUT_UDP_REPLIED,
190 htonl(timeouts[UDP_CT_REPLIED] / HZ)))
191 goto nla_put_failure;
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100192 return 0;
193
194nla_put_failure:
195 return -ENOSPC;
196}
197
198static const struct nla_policy
199udp_timeout_nla_policy[CTA_TIMEOUT_UDP_MAX+1] = {
200 [CTA_TIMEOUT_UDP_UNREPLIED] = { .type = NLA_U32 },
201 [CTA_TIMEOUT_UDP_REPLIED] = { .type = NLA_U32 },
202};
203#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
204
Patrick McHardy933a41e2006-11-29 02:35:18 +0100205#ifdef CONFIG_SYSCTL
Patrick McHardy933a41e2006-11-29 02:35:18 +0100206static struct ctl_table udp_sysctl_table[] = {
207 {
Patrick McHardy933a41e2006-11-29 02:35:18 +0100208 .procname = "nf_conntrack_udp_timeout",
Patrick McHardy933a41e2006-11-29 02:35:18 +0100209 .maxlen = sizeof(unsigned int),
210 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800211 .proc_handler = proc_dointvec_jiffies,
Patrick McHardy933a41e2006-11-29 02:35:18 +0100212 },
213 {
Patrick McHardy933a41e2006-11-29 02:35:18 +0100214 .procname = "nf_conntrack_udp_timeout_stream",
Patrick McHardy933a41e2006-11-29 02:35:18 +0100215 .maxlen = sizeof(unsigned int),
216 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800217 .proc_handler = proc_dointvec_jiffies,
Patrick McHardy933a41e2006-11-29 02:35:18 +0100218 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800219 { }
Patrick McHardy933a41e2006-11-29 02:35:18 +0100220};
Patrick McHardya999e682006-11-29 02:35:20 +0100221#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
222static struct ctl_table udp_compat_sysctl_table[] = {
223 {
Patrick McHardya999e682006-11-29 02:35:20 +0100224 .procname = "ip_conntrack_udp_timeout",
Patrick McHardya999e682006-11-29 02:35:20 +0100225 .maxlen = sizeof(unsigned int),
226 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800227 .proc_handler = proc_dointvec_jiffies,
Patrick McHardya999e682006-11-29 02:35:20 +0100228 },
229 {
Patrick McHardya999e682006-11-29 02:35:20 +0100230 .procname = "ip_conntrack_udp_timeout_stream",
Patrick McHardya999e682006-11-29 02:35:20 +0100231 .maxlen = sizeof(unsigned int),
232 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800233 .proc_handler = proc_dointvec_jiffies,
Patrick McHardya999e682006-11-29 02:35:20 +0100234 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800235 { }
Patrick McHardya999e682006-11-29 02:35:20 +0100236};
237#endif /* CONFIG_NF_CONNTRACK_PROC_COMPAT */
Patrick McHardy933a41e2006-11-29 02:35:18 +0100238#endif /* CONFIG_SYSCTL */
239
Gao fengdee73642012-06-21 04:36:44 +0000240static int udp_kmemdup_sysctl_table(struct nf_proto_net *pn,
241 struct nf_udp_net *un)
Gao feng0ce490a2012-05-28 21:04:13 +0000242{
243#ifdef CONFIG_SYSCTL
Gao feng0ce490a2012-05-28 21:04:13 +0000244 if (pn->ctl_table)
245 return 0;
246 pn->ctl_table = kmemdup(udp_sysctl_table,
247 sizeof(udp_sysctl_table),
248 GFP_KERNEL);
249 if (!pn->ctl_table)
250 return -ENOMEM;
251 pn->ctl_table[0].data = &un->timeouts[UDP_CT_UNREPLIED];
252 pn->ctl_table[1].data = &un->timeouts[UDP_CT_REPLIED];
253#endif
254 return 0;
255}
256
Gao fengdee73642012-06-21 04:36:44 +0000257static int udp_kmemdup_compat_sysctl_table(struct nf_proto_net *pn,
258 struct nf_udp_net *un)
Gao feng0ce490a2012-05-28 21:04:13 +0000259{
260#ifdef CONFIG_SYSCTL
261#ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
Gao feng0ce490a2012-05-28 21:04:13 +0000262 pn->ctl_compat_table = kmemdup(udp_compat_sysctl_table,
263 sizeof(udp_compat_sysctl_table),
264 GFP_KERNEL);
265 if (!pn->ctl_compat_table)
266 return -ENOMEM;
267
268 pn->ctl_compat_table[0].data = &un->timeouts[UDP_CT_UNREPLIED];
269 pn->ctl_compat_table[1].data = &un->timeouts[UDP_CT_REPLIED];
270#endif
271#endif
272 return 0;
273}
274
Gao fengdee73642012-06-21 04:36:44 +0000275static int udp_init_net(struct net *net, u_int16_t proto)
Gao feng0ce490a2012-05-28 21:04:13 +0000276{
277 int ret;
278 struct nf_udp_net *un = udp_pernet(net);
Gao fengdee73642012-06-21 04:36:44 +0000279 struct nf_proto_net *pn = &un->pn;
Gao feng0ce490a2012-05-28 21:04:13 +0000280
Gao fengdee73642012-06-21 04:36:44 +0000281 if (!pn->users) {
282 int i;
Gao feng0ce490a2012-05-28 21:04:13 +0000283
Gao fengdee73642012-06-21 04:36:44 +0000284 for (i = 0; i < UDP_CT_MAX; i++)
285 un->timeouts[i] = udp_timeouts[i];
Gao feng0ce490a2012-05-28 21:04:13 +0000286 }
Gao fengdee73642012-06-21 04:36:44 +0000287
288 if (proto == AF_INET) {
289 ret = udp_kmemdup_compat_sysctl_table(pn, un);
290 if (ret < 0)
291 return ret;
292
293 ret = udp_kmemdup_sysctl_table(pn, un);
294 if (ret < 0)
295 nf_ct_kfree_compat_sysctl_table(pn);
296 } else
297 ret = udp_kmemdup_sysctl_table(pn, un);
298
Gao feng0ce490a2012-05-28 21:04:13 +0000299 return ret;
300}
301
Pablo Neira Ayuso08911472012-06-29 05:23:24 +0000302static struct nf_proto_net *udp_get_net_proto(struct net *net)
303{
304 return &net->ct.nf_ct_proto.udp.pn;
305}
306
Patrick McHardy61075af2007-07-14 20:48:19 -0700307struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 __read_mostly =
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800308{
309 .l3proto = PF_INET,
Martin Josefsson605dcad2006-11-29 02:35:06 +0100310 .l4proto = IPPROTO_UDP,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800311 .name = "udp",
Pablo Neira Ayuso71d8c472016-05-01 00:28:40 +0200312 .allow_clash = true,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800313 .pkt_to_tuple = udp_pkt_to_tuple,
314 .invert_tuple = udp_invert_tuple,
315 .print_tuple = udp_print_tuple,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800316 .packet = udp_packet,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100317 .get_timeouts = udp_get_timeouts,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800318 .new = udp_new,
Patrick McHardy96f6bf82006-04-06 14:19:24 -0700319 .error = udp_error,
Igor Maravićc0cd1152011-12-12 02:58:24 +0000320#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
Patrick McHardyfdf70832007-09-28 14:37:41 -0700321 .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
322 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
Holger Eitzenbergera400c302009-03-25 21:53:39 +0100323 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
Patrick McHardyf73e9242007-09-28 14:39:55 -0700324 .nla_policy = nf_ct_port_nla_policy,
Pablo Neira Ayusoc1d10ad2006-01-05 12:19:05 -0800325#endif
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100326#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
327 .ctnl_timeout = {
328 .nlattr_to_obj = udp_timeout_nlattr_to_obj,
329 .obj_to_nlattr = udp_timeout_obj_to_nlattr,
330 .nlattr_max = CTA_TIMEOUT_UDP_MAX,
331 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
332 .nla_policy = udp_timeout_nla_policy,
333 },
334#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
Gao fengdee73642012-06-21 04:36:44 +0000335 .init_net = udp_init_net,
Pablo Neira Ayuso08911472012-06-29 05:23:24 +0000336 .get_net_proto = udp_get_net_proto,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800337};
Patrick McHardy13b18332006-12-02 22:11:25 -0800338EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp4);
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800339
Patrick McHardy61075af2007-07-14 20:48:19 -0700340struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 __read_mostly =
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800341{
342 .l3proto = PF_INET6,
Martin Josefsson605dcad2006-11-29 02:35:06 +0100343 .l4proto = IPPROTO_UDP,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800344 .name = "udp",
Pablo Neira Ayuso71d8c472016-05-01 00:28:40 +0200345 .allow_clash = true,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800346 .pkt_to_tuple = udp_pkt_to_tuple,
347 .invert_tuple = udp_invert_tuple,
348 .print_tuple = udp_print_tuple,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800349 .packet = udp_packet,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100350 .get_timeouts = udp_get_timeouts,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800351 .new = udp_new,
Patrick McHardy96f6bf82006-04-06 14:19:24 -0700352 .error = udp_error,
Igor Maravićc0cd1152011-12-12 02:58:24 +0000353#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
Patrick McHardyfdf70832007-09-28 14:37:41 -0700354 .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
355 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
Holger Eitzenbergera400c302009-03-25 21:53:39 +0100356 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
Patrick McHardyf73e9242007-09-28 14:39:55 -0700357 .nla_policy = nf_ct_port_nla_policy,
Pablo Neira Ayusoc1d10ad2006-01-05 12:19:05 -0800358#endif
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100359#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
360 .ctnl_timeout = {
361 .nlattr_to_obj = udp_timeout_nlattr_to_obj,
362 .obj_to_nlattr = udp_timeout_obj_to_nlattr,
363 .nlattr_max = CTA_TIMEOUT_UDP_MAX,
364 .obj_size = sizeof(unsigned int) * CTA_TIMEOUT_UDP_MAX,
365 .nla_policy = udp_timeout_nla_policy,
366 },
367#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
Gao fengdee73642012-06-21 04:36:44 +0000368 .init_net = udp_init_net,
Pablo Neira Ayuso08911472012-06-29 05:23:24 +0000369 .get_net_proto = udp_get_net_proto,
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -0800370};
Patrick McHardy13b18332006-12-02 22:11:25 -0800371EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_udp6);