blob: 2750e6c69f825e01c848e26873785e2c81099370 [file] [log] [blame]
Patrick McHardy59eecdf2007-07-14 20:48:44 -07001/* (C) 1999-2001 Paul `Rusty' Russell
2 * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
3 * (C) 2007 Patrick McHardy <kaber@trash.net>
4 *
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.
8 */
9
10#include <linux/types.h>
11#include <linux/timer.h>
12#include <linux/module.h>
Patrick McHardy59eecdf2007-07-14 20:48:44 -070013#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>
19
20#include <linux/netfilter.h>
21#include <linux/netfilter_ipv4.h>
22#include <linux/netfilter_ipv6.h>
23#include <net/netfilter/nf_conntrack_l4proto.h>
24#include <net/netfilter/nf_conntrack_ecache.h>
Patrick McHardyf01ffbd2007-12-17 22:38:49 -080025#include <net/netfilter/nf_log.h>
Patrick McHardy59eecdf2007-07-14 20:48:44 -070026
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +010027enum udplite_conntrack {
28 UDPLITE_CT_UNREPLIED,
29 UDPLITE_CT_REPLIED,
30 UDPLITE_CT_MAX
31};
32
33static unsigned int udplite_timeouts[UDPLITE_CT_MAX] = {
34 [UDPLITE_CT_UNREPLIED] = 30*HZ,
35 [UDPLITE_CT_REPLIED] = 180*HZ,
36};
Patrick McHardy59eecdf2007-07-14 20:48:44 -070037
Gao fenga8021fe2012-05-28 21:04:19 +000038static int udplite_net_id __read_mostly;
39struct udplite_net {
40 struct nf_proto_net pn;
41 unsigned int timeouts[UDPLITE_CT_MAX];
42};
43
44static inline struct udplite_net *udplite_pernet(struct net *net)
45{
46 return net_generic(net, udplite_net_id);
47}
48
Jan Engelhardt09f263c2008-04-14 11:15:53 +020049static bool udplite_pkt_to_tuple(const struct sk_buff *skb,
50 unsigned int dataoff,
51 struct nf_conntrack_tuple *tuple)
Patrick McHardy59eecdf2007-07-14 20:48:44 -070052{
Jan Engelhardtda3f13c2008-01-31 04:52:29 -080053 const struct udphdr *hp;
54 struct udphdr _hdr;
Patrick McHardy59eecdf2007-07-14 20:48:44 -070055
56 hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
57 if (hp == NULL)
Jan Engelhardt09f263c2008-04-14 11:15:53 +020058 return false;
Patrick McHardy59eecdf2007-07-14 20:48:44 -070059
60 tuple->src.u.udp.port = hp->source;
61 tuple->dst.u.udp.port = hp->dest;
Jan Engelhardt09f263c2008-04-14 11:15:53 +020062 return true;
Patrick McHardy59eecdf2007-07-14 20:48:44 -070063}
64
Jan Engelhardt09f263c2008-04-14 11:15:53 +020065static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,
66 const struct nf_conntrack_tuple *orig)
Patrick McHardy59eecdf2007-07-14 20:48:44 -070067{
68 tuple->src.u.udp.port = orig->dst.u.udp.port;
69 tuple->dst.u.udp.port = orig->src.u.udp.port;
Jan Engelhardt09f263c2008-04-14 11:15:53 +020070 return true;
Patrick McHardy59eecdf2007-07-14 20:48:44 -070071}
72
73/* Print out the per-protocol part of the tuple. */
74static int udplite_print_tuple(struct seq_file *s,
75 const struct nf_conntrack_tuple *tuple)
76{
77 return seq_printf(s, "sport=%hu dport=%hu ",
78 ntohs(tuple->src.u.udp.port),
79 ntohs(tuple->dst.u.udp.port));
80}
81
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010082static unsigned int *udplite_get_timeouts(struct net *net)
83{
Gao fenga8021fe2012-05-28 21:04:19 +000084 return udplite_pernet(net)->timeouts;
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010085}
86
Patrick McHardy59eecdf2007-07-14 20:48:44 -070087/* Returns verdict for packet, and may modify conntracktype */
Patrick McHardyc88130b2008-01-31 04:42:11 -080088static int udplite_packet(struct nf_conn *ct,
Patrick McHardy59eecdf2007-07-14 20:48:44 -070089 const struct sk_buff *skb,
90 unsigned int dataoff,
91 enum ip_conntrack_info ctinfo,
Jan Engelhardt76108ce2008-10-08 11:35:00 +020092 u_int8_t pf,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +010093 unsigned int hooknum,
94 unsigned int *timeouts)
Patrick McHardy59eecdf2007-07-14 20:48:44 -070095{
96 /* If we've seen traffic both ways, this is some kind of UDP
97 stream. Extend timeout. */
Patrick McHardyc88130b2008-01-31 04:42:11 -080098 if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
99 nf_ct_refresh_acct(ct, ctinfo, skb,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100100 timeouts[UDPLITE_CT_REPLIED]);
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700101 /* Also, more likely to be important, and not a probe */
Patrick McHardyc88130b2008-01-31 04:42:11 -0800102 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
Patrick McHardy858b31332010-02-03 13:48:53 +0100103 nf_conntrack_event_cache(IPCT_ASSURED, ct);
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +0100104 } else {
105 nf_ct_refresh_acct(ct, ctinfo, skb,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100106 timeouts[UDPLITE_CT_UNREPLIED]);
Pablo Neira Ayuso5a41db92012-02-28 02:23:28 +0100107 }
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700108 return NF_ACCEPT;
109}
110
111/* Called when a new connection for this protocol found. */
Jan Engelhardt09f263c2008-04-14 11:15:53 +0200112static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100113 unsigned int dataoff, unsigned int *timeouts)
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700114{
Jan Engelhardt09f263c2008-04-14 11:15:53 +0200115 return true;
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700116}
117
Patrick McHardy8fea97e2010-02-15 17:45:08 +0100118static int udplite_error(struct net *net, struct nf_conn *tmpl,
Alexey Dobriyan74c51a12008-10-08 11:35:05 +0200119 struct sk_buff *skb,
120 unsigned int dataoff,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700121 enum ip_conntrack_info *ctinfo,
Jan Engelhardt76108ce2008-10-08 11:35:00 +0200122 u_int8_t pf,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700123 unsigned int hooknum)
124{
125 unsigned int udplen = skb->len - dataoff;
Jan Engelhardtda3f13c2008-01-31 04:52:29 -0800126 const struct udphdr *hdr;
127 struct udphdr _hdr;
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700128 unsigned int cscov;
129
130 /* Header is too small? */
131 hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);
132 if (hdr == NULL) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200133 if (LOG_INVALID(net, IPPROTO_UDPLITE))
Gao feng30e0c6a2013-03-24 23:50:40 +0000134 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700135 "nf_ct_udplite: short packet ");
136 return -NF_ACCEPT;
137 }
138
139 cscov = ntohs(hdr->len);
140 if (cscov == 0)
141 cscov = udplen;
142 else if (cscov < sizeof(*hdr) || cscov > udplen) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200143 if (LOG_INVALID(net, IPPROTO_UDPLITE))
Gao feng30e0c6a2013-03-24 23:50:40 +0000144 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700145 "nf_ct_udplite: invalid checksum coverage ");
146 return -NF_ACCEPT;
147 }
148
149 /* UDPLITE mandates checksums */
150 if (!hdr->check) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200151 if (LOG_INVALID(net, IPPROTO_UDPLITE))
Gao feng30e0c6a2013-03-24 23:50:40 +0000152 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700153 "nf_ct_udplite: checksum missing ");
154 return -NF_ACCEPT;
155 }
156
157 /* Checksum invalid? Ignore. */
Alexey Dobriyanc04d0552008-10-08 11:35:08 +0200158 if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING &&
Patrick McHardyd63a6502008-03-20 15:15:53 +0100159 nf_checksum_partial(skb, hooknum, dataoff, cscov, IPPROTO_UDP,
160 pf)) {
Alexey Dobriyanc2a2c7e2008-10-08 11:35:08 +0200161 if (LOG_INVALID(net, IPPROTO_UDPLITE))
Gao feng30e0c6a2013-03-24 23:50:40 +0000162 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
Patrick McHardyd63a6502008-03-20 15:15:53 +0100163 "nf_ct_udplite: bad UDPLite checksum ");
164 return -NF_ACCEPT;
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700165 }
166
167 return NF_ACCEPT;
168}
169
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100170#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
171
172#include <linux/netfilter/nfnetlink.h>
173#include <linux/netfilter/nfnetlink_cttimeout.h>
174
Gao feng8264deb2012-05-28 21:04:23 +0000175static int udplite_timeout_nlattr_to_obj(struct nlattr *tb[],
176 struct net *net, void *data)
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100177{
178 unsigned int *timeouts = data;
Gao feng8264deb2012-05-28 21:04:23 +0000179 struct udplite_net *un = udplite_pernet(net);
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100180
181 /* set default timeouts for UDPlite. */
Gao feng8264deb2012-05-28 21:04:23 +0000182 timeouts[UDPLITE_CT_UNREPLIED] = un->timeouts[UDPLITE_CT_UNREPLIED];
183 timeouts[UDPLITE_CT_REPLIED] = un->timeouts[UDPLITE_CT_REPLIED];
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100184
185 if (tb[CTA_TIMEOUT_UDPLITE_UNREPLIED]) {
186 timeouts[UDPLITE_CT_UNREPLIED] =
187 ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDPLITE_UNREPLIED])) * HZ;
188 }
189 if (tb[CTA_TIMEOUT_UDPLITE_REPLIED]) {
190 timeouts[UDPLITE_CT_REPLIED] =
191 ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDPLITE_REPLIED])) * HZ;
192 }
193 return 0;
194}
195
196static int
197udplite_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data)
198{
199 const unsigned int *timeouts = data;
200
David S. Miller3c60a172012-04-01 18:48:06 -0400201 if (nla_put_be32(skb, CTA_TIMEOUT_UDPLITE_UNREPLIED,
202 htonl(timeouts[UDPLITE_CT_UNREPLIED] / HZ)) ||
203 nla_put_be32(skb, CTA_TIMEOUT_UDPLITE_REPLIED,
204 htonl(timeouts[UDPLITE_CT_REPLIED] / HZ)))
205 goto nla_put_failure;
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100206 return 0;
207
208nla_put_failure:
209 return -ENOSPC;
210}
211
212static const struct nla_policy
213udplite_timeout_nla_policy[CTA_TIMEOUT_UDPLITE_MAX+1] = {
214 [CTA_TIMEOUT_UDPLITE_UNREPLIED] = { .type = NLA_U32 },
215 [CTA_TIMEOUT_UDPLITE_REPLIED] = { .type = NLA_U32 },
216};
217#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
218
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700219#ifdef CONFIG_SYSCTL
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700220static struct ctl_table udplite_sysctl_table[] = {
221 {
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700222 .procname = "nf_conntrack_udplite_timeout",
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700223 .maxlen = sizeof(unsigned int),
224 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800225 .proc_handler = proc_dointvec_jiffies,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700226 },
227 {
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700228 .procname = "nf_conntrack_udplite_timeout_stream",
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700229 .maxlen = sizeof(unsigned int),
230 .mode = 0644,
Alexey Dobriyan6d9f2392008-11-03 18:21:05 -0800231 .proc_handler = proc_dointvec_jiffies,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700232 },
Eric W. Biedermanf8572d82009-11-05 13:32:03 -0800233 { }
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700234};
235#endif /* CONFIG_SYSCTL */
236
Gao feng51b4c822012-06-21 04:36:45 +0000237static int udplite_kmemdup_sysctl_table(struct nf_proto_net *pn,
238 struct udplite_net *un)
239{
240#ifdef CONFIG_SYSCTL
241 if (pn->ctl_table)
242 return 0;
243
244 pn->ctl_table = kmemdup(udplite_sysctl_table,
245 sizeof(udplite_sysctl_table),
246 GFP_KERNEL);
247 if (!pn->ctl_table)
248 return -ENOMEM;
249
250 pn->ctl_table[0].data = &un->timeouts[UDPLITE_CT_UNREPLIED];
251 pn->ctl_table[1].data = &un->timeouts[UDPLITE_CT_REPLIED];
252#endif
253 return 0;
254}
255
Gao fengf1caad22012-06-21 04:36:39 +0000256static int udplite_init_net(struct net *net, u_int16_t proto)
Gao fenga8021fe2012-05-28 21:04:19 +0000257{
Gao fenga8021fe2012-05-28 21:04:19 +0000258 struct udplite_net *un = udplite_pernet(net);
Gao feng51b4c822012-06-21 04:36:45 +0000259 struct nf_proto_net *pn = &un->pn;
260
261 if (!pn->users) {
262 int i;
263
Gao fenga8021fe2012-05-28 21:04:19 +0000264 for (i = 0 ; i < UDPLITE_CT_MAX; i++)
265 un->timeouts[i] = udplite_timeouts[i];
Gao fenga8021fe2012-05-28 21:04:19 +0000266 }
Gao feng51b4c822012-06-21 04:36:45 +0000267
268 return udplite_kmemdup_sysctl_table(pn, un);
Gao fenga8021fe2012-05-28 21:04:19 +0000269}
270
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700271static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 __read_mostly =
272{
273 .l3proto = PF_INET,
274 .l4proto = IPPROTO_UDPLITE,
275 .name = "udplite",
276 .pkt_to_tuple = udplite_pkt_to_tuple,
277 .invert_tuple = udplite_invert_tuple,
278 .print_tuple = udplite_print_tuple,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700279 .packet = udplite_packet,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100280 .get_timeouts = udplite_get_timeouts,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700281 .new = udplite_new,
282 .error = udplite_error,
Igor Maravićc0cd1152011-12-12 02:58:24 +0000283#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
Patrick McHardyfdf70832007-09-28 14:37:41 -0700284 .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
Holger Eitzenbergera400c302009-03-25 21:53:39 +0100285 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
Patrick McHardyfdf70832007-09-28 14:37:41 -0700286 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
Patrick McHardyf73e9242007-09-28 14:39:55 -0700287 .nla_policy = nf_ct_port_nla_policy,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700288#endif
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100289#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
290 .ctnl_timeout = {
291 .nlattr_to_obj = udplite_timeout_nlattr_to_obj,
292 .obj_to_nlattr = udplite_timeout_obj_to_nlattr,
293 .nlattr_max = CTA_TIMEOUT_UDPLITE_MAX,
294 .obj_size = sizeof(unsigned int) *
295 CTA_TIMEOUT_UDPLITE_MAX,
296 .nla_policy = udplite_timeout_nla_policy,
297 },
298#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
Gao fenga8021fe2012-05-28 21:04:19 +0000299 .net_id = &udplite_net_id,
300 .init_net = udplite_init_net,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700301};
302
303static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 __read_mostly =
304{
305 .l3proto = PF_INET6,
306 .l4proto = IPPROTO_UDPLITE,
307 .name = "udplite",
308 .pkt_to_tuple = udplite_pkt_to_tuple,
309 .invert_tuple = udplite_invert_tuple,
310 .print_tuple = udplite_print_tuple,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700311 .packet = udplite_packet,
Pablo Neira Ayuso2c8503f2012-02-28 18:23:31 +0100312 .get_timeouts = udplite_get_timeouts,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700313 .new = udplite_new,
314 .error = udplite_error,
Igor Maravićc0cd1152011-12-12 02:58:24 +0000315#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
Patrick McHardyfdf70832007-09-28 14:37:41 -0700316 .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr,
Patrick McHardy5ff48292009-04-24 15:37:44 +0200317 .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size,
Patrick McHardyfdf70832007-09-28 14:37:41 -0700318 .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple,
Patrick McHardyf73e9242007-09-28 14:39:55 -0700319 .nla_policy = nf_ct_port_nla_policy,
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700320#endif
Pablo Neira Ayuso50978462012-02-28 19:13:48 +0100321#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
322 .ctnl_timeout = {
323 .nlattr_to_obj = udplite_timeout_nlattr_to_obj,
324 .obj_to_nlattr = udplite_timeout_obj_to_nlattr,
325 .nlattr_max = CTA_TIMEOUT_UDPLITE_MAX,
326 .obj_size = sizeof(unsigned int) *
327 CTA_TIMEOUT_UDPLITE_MAX,
328 .nla_policy = udplite_timeout_nla_policy,
329 },
330#endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */
Gao fenga8021fe2012-05-28 21:04:19 +0000331 .net_id = &udplite_net_id,
332 .init_net = udplite_init_net,
333};
334
335static int udplite_net_init(struct net *net)
336{
337 int ret = 0;
338
Gao fengc296bb42013-01-23 12:51:10 +0100339 ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_udplite4);
Gao fenga8021fe2012-05-28 21:04:19 +0000340 if (ret < 0) {
Gao fengc296bb42013-01-23 12:51:10 +0100341 pr_err("nf_conntrack_udplite4: pernet registration failed.\n");
Gao fenga8021fe2012-05-28 21:04:19 +0000342 goto out;
343 }
Gao fengc296bb42013-01-23 12:51:10 +0100344 ret = nf_ct_l4proto_pernet_register(net, &nf_conntrack_l4proto_udplite6);
Gao fenga8021fe2012-05-28 21:04:19 +0000345 if (ret < 0) {
Gao fengc296bb42013-01-23 12:51:10 +0100346 pr_err("nf_conntrack_udplite6: pernet registration failed.\n");
Gao fenga8021fe2012-05-28 21:04:19 +0000347 goto cleanup_udplite4;
348 }
349 return 0;
350
351cleanup_udplite4:
Gao fengc296bb42013-01-23 12:51:10 +0100352 nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udplite4);
Gao fenga8021fe2012-05-28 21:04:19 +0000353out:
354 return ret;
355}
356
357static void udplite_net_exit(struct net *net)
358{
Gao fengc296bb42013-01-23 12:51:10 +0100359 nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udplite6);
360 nf_ct_l4proto_pernet_unregister(net, &nf_conntrack_l4proto_udplite4);
Gao fenga8021fe2012-05-28 21:04:19 +0000361}
362
363static struct pernet_operations udplite_net_ops = {
364 .init = udplite_net_init,
365 .exit = udplite_net_exit,
366 .id = &udplite_net_id,
367 .size = sizeof(struct udplite_net),
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700368};
369
370static int __init nf_conntrack_proto_udplite_init(void)
371{
Gao fengc296bb42013-01-23 12:51:10 +0100372 int ret;
373
Gao feng0d98da52013-03-07 17:20:46 +0000374 ret = register_pernet_subsys(&udplite_net_ops);
375 if (ret < 0)
376 goto out_pernet;
377
Gao fengc296bb42013-01-23 12:51:10 +0100378 ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udplite4);
379 if (ret < 0)
380 goto out_udplite4;
381
382 ret = nf_ct_l4proto_register(&nf_conntrack_l4proto_udplite6);
383 if (ret < 0)
384 goto out_udplite6;
385
Gao fengc296bb42013-01-23 12:51:10 +0100386 return 0;
Gao fengc296bb42013-01-23 12:51:10 +0100387out_udplite6:
388 nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite4);
389out_udplite4:
Gao feng0d98da52013-03-07 17:20:46 +0000390 unregister_pernet_subsys(&udplite_net_ops);
391out_pernet:
Gao fengc296bb42013-01-23 12:51:10 +0100392 return ret;
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700393}
394
395static void __exit nf_conntrack_proto_udplite_exit(void)
396{
Gao fengc296bb42013-01-23 12:51:10 +0100397 nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite6);
398 nf_ct_l4proto_unregister(&nf_conntrack_l4proto_udplite4);
Gao fenga8021fe2012-05-28 21:04:19 +0000399 unregister_pernet_subsys(&udplite_net_ops);
Patrick McHardy59eecdf2007-07-14 20:48:44 -0700400}
401
402module_init(nf_conntrack_proto_udplite_init);
403module_exit(nf_conntrack_proto_udplite_exit);
404
405MODULE_LICENSE("GPL");