]> git.karo-electronics.de Git - karo-tx-linux.git/blob - net/ipv6/netfilter/nf_conntrack_reasm.c
Merge branch 'inet_frag_kill_lru_list'
[karo-tx-linux.git] / net / ipv6 / netfilter / nf_conntrack_reasm.c
1 /*
2  * IPv6 fragment reassembly for connection tracking
3  *
4  * Copyright (C)2004 USAGI/WIDE Project
5  *
6  * Author:
7  *      Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
8  *
9  * Based on: net/ipv6/reassembly.c
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version
14  * 2 of the License, or (at your option) any later version.
15  */
16
17 #define pr_fmt(fmt) "IPv6-nf: " fmt
18
19 #include <linux/errno.h>
20 #include <linux/types.h>
21 #include <linux/string.h>
22 #include <linux/socket.h>
23 #include <linux/sockios.h>
24 #include <linux/jiffies.h>
25 #include <linux/net.h>
26 #include <linux/list.h>
27 #include <linux/netdevice.h>
28 #include <linux/in6.h>
29 #include <linux/ipv6.h>
30 #include <linux/icmpv6.h>
31 #include <linux/random.h>
32 #include <linux/slab.h>
33
34 #include <net/sock.h>
35 #include <net/snmp.h>
36 #include <net/inet_frag.h>
37
38 #include <net/ipv6.h>
39 #include <net/protocol.h>
40 #include <net/transp_v6.h>
41 #include <net/rawv6.h>
42 #include <net/ndisc.h>
43 #include <net/addrconf.h>
44 #include <net/inet_ecn.h>
45 #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
46 #include <linux/sysctl.h>
47 #include <linux/netfilter.h>
48 #include <linux/netfilter_ipv6.h>
49 #include <linux/kernel.h>
50 #include <linux/module.h>
51 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
52
53
54 struct nf_ct_frag6_skb_cb
55 {
56         struct inet6_skb_parm   h;
57         int                     offset;
58         struct sk_buff          *orig;
59 };
60
61 #define NFCT_FRAG6_CB(skb)      ((struct nf_ct_frag6_skb_cb*)((skb)->cb))
62
63 static struct inet_frags nf_frags;
64
65 #ifdef CONFIG_SYSCTL
66 static int zero;
67
68 static struct ctl_table nf_ct_frag6_sysctl_table[] = {
69         {
70                 .procname       = "nf_conntrack_frag6_timeout",
71                 .data           = &init_net.nf_frag.frags.timeout,
72                 .maxlen         = sizeof(unsigned int),
73                 .mode           = 0644,
74                 .proc_handler   = proc_dointvec_jiffies,
75         },
76         {
77                 .procname       = "nf_conntrack_frag6_low_thresh",
78                 .data           = &init_net.nf_frag.frags.low_thresh,
79                 .maxlen         = sizeof(unsigned int),
80                 .mode           = 0644,
81                 .proc_handler   = proc_dointvec_minmax,
82                 .extra1         = &zero,
83                 .extra2         = &init_net.nf_frag.frags.high_thresh
84         },
85         {
86                 .procname       = "nf_conntrack_frag6_high_thresh",
87                 .data           = &init_net.nf_frag.frags.high_thresh,
88                 .maxlen         = sizeof(unsigned int),
89                 .mode           = 0644,
90                 .proc_handler   = proc_dointvec_minmax,
91                 .extra1         = &init_net.nf_frag.frags.low_thresh
92         },
93         { }
94 };
95
96 static int nf_ct_frag6_sysctl_register(struct net *net)
97 {
98         struct ctl_table *table;
99         struct ctl_table_header *hdr;
100
101         table = nf_ct_frag6_sysctl_table;
102         if (!net_eq(net, &init_net)) {
103                 table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
104                                 GFP_KERNEL);
105                 if (table == NULL)
106                         goto err_alloc;
107
108                 table[0].data = &net->nf_frag.frags.timeout;
109                 table[1].data = &net->nf_frag.frags.low_thresh;
110                 table[1].extra2 = &net->nf_frag.frags.high_thresh;
111                 table[2].data = &net->nf_frag.frags.high_thresh;
112                 table[2].extra1 = &net->nf_frag.frags.low_thresh;
113                 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
114         }
115
116         hdr = register_net_sysctl(net, "net/netfilter", table);
117         if (hdr == NULL)
118                 goto err_reg;
119
120         net->nf_frag.sysctl.frags_hdr = hdr;
121         return 0;
122
123 err_reg:
124         if (!net_eq(net, &init_net))
125                 kfree(table);
126 err_alloc:
127         return -ENOMEM;
128 }
129
130 static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
131 {
132         struct ctl_table *table;
133
134         table = net->nf_frag.sysctl.frags_hdr->ctl_table_arg;
135         unregister_net_sysctl_table(net->nf_frag.sysctl.frags_hdr);
136         if (!net_eq(net, &init_net))
137                 kfree(table);
138 }
139
140 #else
141 static int nf_ct_frag6_sysctl_register(struct net *net)
142 {
143         return 0;
144 }
145 static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
146 {
147 }
148 #endif
149
150 static inline u8 ip6_frag_ecn(const struct ipv6hdr *ipv6h)
151 {
152         return 1 << (ipv6_get_dsfield(ipv6h) & INET_ECN_MASK);
153 }
154
155 static unsigned int nf_hash_frag(__be32 id, const struct in6_addr *saddr,
156                                  const struct in6_addr *daddr)
157 {
158         net_get_random_once(&nf_frags.rnd, sizeof(nf_frags.rnd));
159         return jhash_3words(ipv6_addr_hash(saddr), ipv6_addr_hash(daddr),
160                             (__force u32)id, nf_frags.rnd);
161 }
162
163
164 static unsigned int nf_hashfn(const struct inet_frag_queue *q)
165 {
166         const struct frag_queue *nq;
167
168         nq = container_of(q, struct frag_queue, q);
169         return nf_hash_frag(nq->id, &nq->saddr, &nq->daddr);
170 }
171
172 static void nf_skb_free(struct sk_buff *skb)
173 {
174         if (NFCT_FRAG6_CB(skb)->orig)
175                 kfree_skb(NFCT_FRAG6_CB(skb)->orig);
176 }
177
178 static void nf_ct_frag6_expire(unsigned long data)
179 {
180         struct frag_queue *fq;
181         struct net *net;
182
183         fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
184         net = container_of(fq->q.net, struct net, nf_frag.frags);
185
186         ip6_expire_frag_queue(net, fq, &nf_frags);
187 }
188
189 /* Creation primitives. */
190 static inline struct frag_queue *fq_find(struct net *net, __be32 id,
191                                          u32 user, struct in6_addr *src,
192                                          struct in6_addr *dst, u8 ecn)
193 {
194         struct inet_frag_queue *q;
195         struct ip6_create_arg arg;
196         unsigned int hash;
197
198         arg.id = id;
199         arg.user = user;
200         arg.src = src;
201         arg.dst = dst;
202         arg.ecn = ecn;
203
204         local_bh_disable();
205         hash = nf_hash_frag(id, src, dst);
206
207         q = inet_frag_find(&net->nf_frag.frags, &nf_frags, &arg, hash);
208         local_bh_enable();
209         if (IS_ERR_OR_NULL(q)) {
210                 inet_frag_maybe_warn_overflow(q, pr_fmt());
211                 return NULL;
212         }
213         return container_of(q, struct frag_queue, q);
214 }
215
216
217 static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
218                              const struct frag_hdr *fhdr, int nhoff)
219 {
220         struct sk_buff *prev, *next;
221         unsigned int payload_len;
222         int offset, end;
223         u8 ecn;
224
225         if (fq->q.last_in & INET_FRAG_COMPLETE) {
226                 pr_debug("Already completed\n");
227                 goto err;
228         }
229
230         payload_len = ntohs(ipv6_hdr(skb)->payload_len);
231
232         offset = ntohs(fhdr->frag_off) & ~0x7;
233         end = offset + (payload_len -
234                         ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1)));
235
236         if ((unsigned int)end > IPV6_MAXPLEN) {
237                 pr_debug("offset is too large.\n");
238                 return -1;
239         }
240
241         ecn = ip6_frag_ecn(ipv6_hdr(skb));
242
243         if (skb->ip_summed == CHECKSUM_COMPLETE) {
244                 const unsigned char *nh = skb_network_header(skb);
245                 skb->csum = csum_sub(skb->csum,
246                                      csum_partial(nh, (u8 *)(fhdr + 1) - nh,
247                                                   0));
248         }
249
250         /* Is this the final fragment? */
251         if (!(fhdr->frag_off & htons(IP6_MF))) {
252                 /* If we already have some bits beyond end
253                  * or have different end, the segment is corrupted.
254                  */
255                 if (end < fq->q.len ||
256                     ((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) {
257                         pr_debug("already received last fragment\n");
258                         goto err;
259                 }
260                 fq->q.last_in |= INET_FRAG_LAST_IN;
261                 fq->q.len = end;
262         } else {
263                 /* Check if the fragment is rounded to 8 bytes.
264                  * Required by the RFC.
265                  */
266                 if (end & 0x7) {
267                         /* RFC2460 says always send parameter problem in
268                          * this case. -DaveM
269                          */
270                         pr_debug("end of fragment not rounded to 8 bytes.\n");
271                         return -1;
272                 }
273                 if (end > fq->q.len) {
274                         /* Some bits beyond end -> corruption. */
275                         if (fq->q.last_in & INET_FRAG_LAST_IN) {
276                                 pr_debug("last packet already reached.\n");
277                                 goto err;
278                         }
279                         fq->q.len = end;
280                 }
281         }
282
283         if (end == offset)
284                 goto err;
285
286         /* Point into the IP datagram 'data' part. */
287         if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) {
288                 pr_debug("queue: message is too short.\n");
289                 goto err;
290         }
291         if (pskb_trim_rcsum(skb, end - offset)) {
292                 pr_debug("Can't trim\n");
293                 goto err;
294         }
295
296         /* Find out which fragments are in front and at the back of us
297          * in the chain of fragments so far.  We must know where to put
298          * this fragment, right?
299          */
300         prev = fq->q.fragments_tail;
301         if (!prev || NFCT_FRAG6_CB(prev)->offset < offset) {
302                 next = NULL;
303                 goto found;
304         }
305         prev = NULL;
306         for (next = fq->q.fragments; next != NULL; next = next->next) {
307                 if (NFCT_FRAG6_CB(next)->offset >= offset)
308                         break;  /* bingo! */
309                 prev = next;
310         }
311
312 found:
313         /* RFC5722, Section 4:
314          *                                  When reassembling an IPv6 datagram, if
315          *   one or more its constituent fragments is determined to be an
316          *   overlapping fragment, the entire datagram (and any constituent
317          *   fragments, including those not yet received) MUST be silently
318          *   discarded.
319          */
320
321         /* Check for overlap with preceding fragment. */
322         if (prev &&
323             (NFCT_FRAG6_CB(prev)->offset + prev->len) > offset)
324                 goto discard_fq;
325
326         /* Look for overlap with succeeding segment. */
327         if (next && NFCT_FRAG6_CB(next)->offset < end)
328                 goto discard_fq;
329
330         NFCT_FRAG6_CB(skb)->offset = offset;
331
332         /* Insert this fragment in the chain of fragments. */
333         skb->next = next;
334         if (!next)
335                 fq->q.fragments_tail = skb;
336         if (prev)
337                 prev->next = skb;
338         else
339                 fq->q.fragments = skb;
340
341         if (skb->dev) {
342                 fq->iif = skb->dev->ifindex;
343                 skb->dev = NULL;
344         }
345         fq->q.stamp = skb->tstamp;
346         fq->q.meat += skb->len;
347         fq->ecn |= ecn;
348         if (payload_len > fq->q.max_size)
349                 fq->q.max_size = payload_len;
350         add_frag_mem_limit(&fq->q, skb->truesize);
351
352         /* The first fragment.
353          * nhoffset is obtained from the first fragment, of course.
354          */
355         if (offset == 0) {
356                 fq->nhoffset = nhoff;
357                 fq->q.last_in |= INET_FRAG_FIRST_IN;
358         }
359
360         return 0;
361
362 discard_fq:
363         inet_frag_kill(&fq->q, &nf_frags);
364 err:
365         return -1;
366 }
367
368 /*
369  *      Check if this packet is complete.
370  *      Returns NULL on failure by any reason, and pointer
371  *      to current nexthdr field in reassembled frame.
372  *
373  *      It is called with locked fq, and caller must check that
374  *      queue is eligible for reassembly i.e. it is not COMPLETE,
375  *      the last and the first frames arrived and all the bits are here.
376  */
377 static struct sk_buff *
378 nf_ct_frag6_reasm(struct frag_queue *fq, struct net_device *dev)
379 {
380         struct sk_buff *fp, *op, *head = fq->q.fragments;
381         int    payload_len;
382         u8 ecn;
383
384         inet_frag_kill(&fq->q, &nf_frags);
385
386         WARN_ON(head == NULL);
387         WARN_ON(NFCT_FRAG6_CB(head)->offset != 0);
388
389         ecn = ip_frag_ecn_table[fq->ecn];
390         if (unlikely(ecn == 0xff))
391                 goto out_fail;
392
393         /* Unfragmented part is taken from the first segment. */
394         payload_len = ((head->data - skb_network_header(head)) -
395                        sizeof(struct ipv6hdr) + fq->q.len -
396                        sizeof(struct frag_hdr));
397         if (payload_len > IPV6_MAXPLEN) {
398                 pr_debug("payload len is too large.\n");
399                 goto out_oversize;
400         }
401
402         /* Head of list must not be cloned. */
403         if (skb_unclone(head, GFP_ATOMIC)) {
404                 pr_debug("skb is cloned but can't expand head");
405                 goto out_oom;
406         }
407
408         /* If the first fragment is fragmented itself, we split
409          * it to two chunks: the first with data and paged part
410          * and the second, holding only fragments. */
411         if (skb_has_frag_list(head)) {
412                 struct sk_buff *clone;
413                 int i, plen = 0;
414
415                 clone = alloc_skb(0, GFP_ATOMIC);
416                 if (clone == NULL)
417                         goto out_oom;
418
419                 clone->next = head->next;
420                 head->next = clone;
421                 skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list;
422                 skb_frag_list_init(head);
423                 for (i = 0; i < skb_shinfo(head)->nr_frags; i++)
424                         plen += skb_frag_size(&skb_shinfo(head)->frags[i]);
425                 clone->len = clone->data_len = head->data_len - plen;
426                 head->data_len -= clone->len;
427                 head->len -= clone->len;
428                 clone->csum = 0;
429                 clone->ip_summed = head->ip_summed;
430
431                 NFCT_FRAG6_CB(clone)->orig = NULL;
432                 add_frag_mem_limit(&fq->q, clone->truesize);
433         }
434
435         /* We have to remove fragment header from datagram and to relocate
436          * header in order to calculate ICV correctly. */
437         skb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0];
438         memmove(head->head + sizeof(struct frag_hdr), head->head,
439                 (head->data - head->head) - sizeof(struct frag_hdr));
440         head->mac_header += sizeof(struct frag_hdr);
441         head->network_header += sizeof(struct frag_hdr);
442
443         skb_shinfo(head)->frag_list = head->next;
444         skb_reset_transport_header(head);
445         skb_push(head, head->data - skb_network_header(head));
446
447         for (fp=head->next; fp; fp = fp->next) {
448                 head->data_len += fp->len;
449                 head->len += fp->len;
450                 if (head->ip_summed != fp->ip_summed)
451                         head->ip_summed = CHECKSUM_NONE;
452                 else if (head->ip_summed == CHECKSUM_COMPLETE)
453                         head->csum = csum_add(head->csum, fp->csum);
454                 head->truesize += fp->truesize;
455         }
456         sub_frag_mem_limit(&fq->q, head->truesize);
457
458         head->ignore_df = 1;
459         head->next = NULL;
460         head->dev = dev;
461         head->tstamp = fq->q.stamp;
462         ipv6_hdr(head)->payload_len = htons(payload_len);
463         ipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn);
464         IP6CB(head)->frag_max_size = sizeof(struct ipv6hdr) + fq->q.max_size;
465
466         /* Yes, and fold redundant checksum back. 8) */
467         if (head->ip_summed == CHECKSUM_COMPLETE)
468                 head->csum = csum_partial(skb_network_header(head),
469                                           skb_network_header_len(head),
470                                           head->csum);
471
472         fq->q.fragments = NULL;
473         fq->q.fragments_tail = NULL;
474
475         /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */
476         fp = skb_shinfo(head)->frag_list;
477         if (fp && NFCT_FRAG6_CB(fp)->orig == NULL)
478                 /* at above code, head skb is divided into two skbs. */
479                 fp = fp->next;
480
481         op = NFCT_FRAG6_CB(head)->orig;
482         for (; fp; fp = fp->next) {
483                 struct sk_buff *orig = NFCT_FRAG6_CB(fp)->orig;
484
485                 op->next = orig;
486                 op = orig;
487                 NFCT_FRAG6_CB(fp)->orig = NULL;
488         }
489
490         return head;
491
492 out_oversize:
493         net_dbg_ratelimited("nf_ct_frag6_reasm: payload len = %d\n",
494                             payload_len);
495         goto out_fail;
496 out_oom:
497         net_dbg_ratelimited("nf_ct_frag6_reasm: no memory for reassembly\n");
498 out_fail:
499         return NULL;
500 }
501
502 /*
503  * find the header just before Fragment Header.
504  *
505  * if success return 0 and set ...
506  * (*prevhdrp): the value of "Next Header Field" in the header
507  *              just before Fragment Header.
508  * (*prevhoff): the offset of "Next Header Field" in the header
509  *              just before Fragment Header.
510  * (*fhoff)   : the offset of Fragment Header.
511  *
512  * Based on ipv6_skip_hdr() in net/ipv6/exthdr.c
513  *
514  */
515 static int
516 find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
517 {
518         u8 nexthdr = ipv6_hdr(skb)->nexthdr;
519         const int netoff = skb_network_offset(skb);
520         u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
521         int start = netoff + sizeof(struct ipv6hdr);
522         int len = skb->len - start;
523         u8 prevhdr = NEXTHDR_IPV6;
524
525         while (nexthdr != NEXTHDR_FRAGMENT) {
526                 struct ipv6_opt_hdr hdr;
527                 int hdrlen;
528
529                 if (!ipv6_ext_hdr(nexthdr)) {
530                         return -1;
531                 }
532                 if (nexthdr == NEXTHDR_NONE) {
533                         pr_debug("next header is none\n");
534                         return -1;
535                 }
536                 if (len < (int)sizeof(struct ipv6_opt_hdr)) {
537                         pr_debug("too short\n");
538                         return -1;
539                 }
540                 if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
541                         BUG();
542                 if (nexthdr == NEXTHDR_AUTH)
543                         hdrlen = (hdr.hdrlen+2)<<2;
544                 else
545                         hdrlen = ipv6_optlen(&hdr);
546
547                 prevhdr = nexthdr;
548                 prev_nhoff = start;
549
550                 nexthdr = hdr.nexthdr;
551                 len -= hdrlen;
552                 start += hdrlen;
553         }
554
555         if (len < 0)
556                 return -1;
557
558         *prevhdrp = prevhdr;
559         *prevhoff = prev_nhoff;
560         *fhoff = start;
561
562         return 0;
563 }
564
565 struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user)
566 {
567         struct sk_buff *clone;
568         struct net_device *dev = skb->dev;
569         struct net *net = skb_dst(skb) ? dev_net(skb_dst(skb)->dev)
570                                        : dev_net(skb->dev);
571         struct frag_hdr *fhdr;
572         struct frag_queue *fq;
573         struct ipv6hdr *hdr;
574         int fhoff, nhoff;
575         u8 prevhdr;
576         struct sk_buff *ret_skb = NULL;
577
578         /* Jumbo payload inhibits frag. header */
579         if (ipv6_hdr(skb)->payload_len == 0) {
580                 pr_debug("payload len = 0\n");
581                 return skb;
582         }
583
584         if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0)
585                 return skb;
586
587         clone = skb_clone(skb, GFP_ATOMIC);
588         if (clone == NULL) {
589                 pr_debug("Can't clone skb\n");
590                 return skb;
591         }
592
593         NFCT_FRAG6_CB(clone)->orig = skb;
594
595         if (!pskb_may_pull(clone, fhoff + sizeof(*fhdr))) {
596                 pr_debug("message is too short.\n");
597                 goto ret_orig;
598         }
599
600         skb_set_transport_header(clone, fhoff);
601         hdr = ipv6_hdr(clone);
602         fhdr = (struct frag_hdr *)skb_transport_header(clone);
603
604         fq = fq_find(net, fhdr->identification, user, &hdr->saddr, &hdr->daddr,
605                      ip6_frag_ecn(hdr));
606         if (fq == NULL) {
607                 pr_debug("Can't find and can't create new queue\n");
608                 goto ret_orig;
609         }
610
611         spin_lock_bh(&fq->q.lock);
612
613         if (nf_ct_frag6_queue(fq, clone, fhdr, nhoff) < 0) {
614                 spin_unlock_bh(&fq->q.lock);
615                 pr_debug("Can't insert skb to queue\n");
616                 inet_frag_put(&fq->q, &nf_frags);
617                 goto ret_orig;
618         }
619
620         if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
621             fq->q.meat == fq->q.len) {
622                 ret_skb = nf_ct_frag6_reasm(fq, dev);
623                 if (ret_skb == NULL)
624                         pr_debug("Can't reassemble fragmented packets\n");
625         }
626         spin_unlock_bh(&fq->q.lock);
627
628         inet_frag_put(&fq->q, &nf_frags);
629         return ret_skb;
630
631 ret_orig:
632         kfree_skb(clone);
633         return skb;
634 }
635
636 void nf_ct_frag6_consume_orig(struct sk_buff *skb)
637 {
638         struct sk_buff *s, *s2;
639
640         for (s = NFCT_FRAG6_CB(skb)->orig; s;) {
641                 s2 = s->next;
642                 s->next = NULL;
643                 consume_skb(s);
644                 s = s2;
645         }
646 }
647
648 static int nf_ct_net_init(struct net *net)
649 {
650         net->nf_frag.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
651         net->nf_frag.frags.low_thresh = IPV6_FRAG_LOW_THRESH;
652         net->nf_frag.frags.timeout = IPV6_FRAG_TIMEOUT;
653         inet_frags_init_net(&net->nf_frag.frags);
654
655         return nf_ct_frag6_sysctl_register(net);
656 }
657
658 static void nf_ct_net_exit(struct net *net)
659 {
660         nf_ct_frags6_sysctl_unregister(net);
661         inet_frags_exit_net(&net->nf_frag.frags, &nf_frags);
662 }
663
664 static struct pernet_operations nf_ct_net_ops = {
665         .init = nf_ct_net_init,
666         .exit = nf_ct_net_exit,
667 };
668
669 int nf_ct_frag6_init(void)
670 {
671         int ret = 0;
672
673         nf_frags.hashfn = nf_hashfn;
674         nf_frags.constructor = ip6_frag_init;
675         nf_frags.destructor = NULL;
676         nf_frags.skb_free = nf_skb_free;
677         nf_frags.qsize = sizeof(struct frag_queue);
678         nf_frags.match = ip6_frag_match;
679         nf_frags.frag_expire = nf_ct_frag6_expire;
680         inet_frags_init(&nf_frags);
681
682         ret = register_pernet_subsys(&nf_ct_net_ops);
683         if (ret)
684                 inet_frags_fini(&nf_frags);
685
686         return ret;
687 }
688
689 void nf_ct_frag6_cleanup(void)
690 {
691         unregister_pernet_subsys(&nf_ct_net_ops);
692         inet_frags_fini(&nf_frags);
693 }