e65e26e210ee3a66873f6d472fdca708559fb0a2
[safe/jmp/linux-2.6] / 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 #include <linux/errno.h>
18 #include <linux/types.h>
19 #include <linux/string.h>
20 #include <linux/socket.h>
21 #include <linux/sockios.h>
22 #include <linux/jiffies.h>
23 #include <linux/net.h>
24 #include <linux/list.h>
25 #include <linux/netdevice.h>
26 #include <linux/in6.h>
27 #include <linux/ipv6.h>
28 #include <linux/icmpv6.h>
29 #include <linux/random.h>
30 #include <linux/jhash.h>
31
32 #include <net/sock.h>
33 #include <net/snmp.h>
34 #include <net/inet_frag.h>
35
36 #include <net/ipv6.h>
37 #include <net/protocol.h>
38 #include <net/transp_v6.h>
39 #include <net/rawv6.h>
40 #include <net/ndisc.h>
41 #include <net/addrconf.h>
42 #include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
43 #include <linux/sysctl.h>
44 #include <linux/netfilter.h>
45 #include <linux/netfilter_ipv6.h>
46 #include <linux/kernel.h>
47 #include <linux/module.h>
48
49 #define NF_CT_FRAG6_HIGH_THRESH 262144 /* == 256*1024 */
50 #define NF_CT_FRAG6_LOW_THRESH 196608  /* == 192*1024 */
51 #define NF_CT_FRAG6_TIMEOUT IPV6_FRAG_TIMEOUT
52
53 struct nf_ct_frag6_skb_cb
54 {
55         struct inet6_skb_parm   h;
56         int                     offset;
57         struct sk_buff          *orig;
58 };
59
60 #define NFCT_FRAG6_CB(skb)      ((struct nf_ct_frag6_skb_cb*)((skb)->cb))
61
62 struct nf_ct_frag6_queue
63 {
64         struct inet_frag_queue  q;
65
66         __be32                  id;             /* fragment id          */
67         struct in6_addr         saddr;
68         struct in6_addr         daddr;
69
70         unsigned int            csum;
71         __u16                   nhoffset;
72 };
73
74 static struct inet_frags nf_frags;
75 static struct netns_frags nf_init_frags;
76
77 #ifdef CONFIG_SYSCTL
78 struct ctl_table nf_ct_ipv6_sysctl_table[] = {
79         {
80                 .procname       = "nf_conntrack_frag6_timeout",
81                 .data           = &nf_init_frags.timeout,
82                 .maxlen         = sizeof(unsigned int),
83                 .mode           = 0644,
84                 .proc_handler   = &proc_dointvec_jiffies,
85         },
86         {
87                 .ctl_name       = NET_NF_CONNTRACK_FRAG6_LOW_THRESH,
88                 .procname       = "nf_conntrack_frag6_low_thresh",
89                 .data           = &nf_init_frags.low_thresh,
90                 .maxlen         = sizeof(unsigned int),
91                 .mode           = 0644,
92                 .proc_handler   = &proc_dointvec,
93         },
94         {
95                 .ctl_name       = NET_NF_CONNTRACK_FRAG6_HIGH_THRESH,
96                 .procname       = "nf_conntrack_frag6_high_thresh",
97                 .data           = &nf_init_frags.high_thresh,
98                 .maxlen         = sizeof(unsigned int),
99                 .mode           = 0644,
100                 .proc_handler   = &proc_dointvec,
101         },
102         { .ctl_name = 0 }
103 };
104 #endif
105
106 static unsigned int ip6qhashfn(__be32 id, const struct in6_addr *saddr,
107                                const struct in6_addr *daddr)
108 {
109         u32 a, b, c;
110
111         a = (__force u32)saddr->s6_addr32[0];
112         b = (__force u32)saddr->s6_addr32[1];
113         c = (__force u32)saddr->s6_addr32[2];
114
115         a += JHASH_GOLDEN_RATIO;
116         b += JHASH_GOLDEN_RATIO;
117         c += nf_frags.rnd;
118         __jhash_mix(a, b, c);
119
120         a += (__force u32)saddr->s6_addr32[3];
121         b += (__force u32)daddr->s6_addr32[0];
122         c += (__force u32)daddr->s6_addr32[1];
123         __jhash_mix(a, b, c);
124
125         a += (__force u32)daddr->s6_addr32[2];
126         b += (__force u32)daddr->s6_addr32[3];
127         c += (__force u32)id;
128         __jhash_mix(a, b, c);
129
130         return c & (INETFRAGS_HASHSZ - 1);
131 }
132
133 static unsigned int nf_hashfn(struct inet_frag_queue *q)
134 {
135         const struct nf_ct_frag6_queue *nq;
136
137         nq = container_of(q, struct nf_ct_frag6_queue, q);
138         return ip6qhashfn(nq->id, &nq->saddr, &nq->daddr);
139 }
140
141 static void nf_skb_free(struct sk_buff *skb)
142 {
143         if (NFCT_FRAG6_CB(skb)->orig)
144                 kfree_skb(NFCT_FRAG6_CB(skb)->orig);
145 }
146
147 /* Memory Tracking Functions. */
148 static inline void frag_kfree_skb(struct sk_buff *skb, unsigned int *work)
149 {
150         if (work)
151                 *work -= skb->truesize;
152         atomic_sub(skb->truesize, &nf_init_frags.mem);
153         nf_skb_free(skb);
154         kfree_skb(skb);
155 }
156
157 /* Destruction primitives. */
158
159 static __inline__ void fq_put(struct nf_ct_frag6_queue *fq)
160 {
161         inet_frag_put(&fq->q, &nf_frags);
162 }
163
164 /* Kill fq entry. It is not destroyed immediately,
165  * because caller (and someone more) holds reference count.
166  */
167 static __inline__ void fq_kill(struct nf_ct_frag6_queue *fq)
168 {
169         inet_frag_kill(&fq->q, &nf_frags);
170 }
171
172 static void nf_ct_frag6_evictor(void)
173 {
174         local_bh_disable();
175         inet_frag_evictor(&nf_init_frags, &nf_frags);
176         local_bh_enable();
177 }
178
179 static void nf_ct_frag6_expire(unsigned long data)
180 {
181         struct nf_ct_frag6_queue *fq;
182
183         fq = container_of((struct inet_frag_queue *)data,
184                         struct nf_ct_frag6_queue, q);
185
186         spin_lock(&fq->q.lock);
187
188         if (fq->q.last_in & INET_FRAG_COMPLETE)
189                 goto out;
190
191         fq_kill(fq);
192
193 out:
194         spin_unlock(&fq->q.lock);
195         fq_put(fq);
196 }
197
198 /* Creation primitives. */
199
200 static __inline__ struct nf_ct_frag6_queue *
201 fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst)
202 {
203         struct inet_frag_queue *q;
204         struct ip6_create_arg arg;
205         unsigned int hash;
206
207         arg.id = id;
208         arg.src = src;
209         arg.dst = dst;
210         hash = ip6qhashfn(id, src, dst);
211
212         local_bh_disable();
213         q = inet_frag_find(&nf_init_frags, &nf_frags, &arg, hash);
214         local_bh_enable();
215         if (q == NULL)
216                 goto oom;
217
218         return container_of(q, struct nf_ct_frag6_queue, q);
219
220 oom:
221         pr_debug("Can't alloc new queue\n");
222         return NULL;
223 }
224
225
226 static int nf_ct_frag6_queue(struct nf_ct_frag6_queue *fq, struct sk_buff *skb,
227                              const struct frag_hdr *fhdr, int nhoff)
228 {
229         struct sk_buff *prev, *next;
230         int offset, end;
231
232         if (fq->q.last_in & INET_FRAG_COMPLETE) {
233                 pr_debug("Allready completed\n");
234                 goto err;
235         }
236
237         offset = ntohs(fhdr->frag_off) & ~0x7;
238         end = offset + (ntohs(ipv6_hdr(skb)->payload_len) -
239                         ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1)));
240
241         if ((unsigned int)end > IPV6_MAXPLEN) {
242                 pr_debug("offset is too large.\n");
243                 return -1;
244         }
245
246         if (skb->ip_summed == CHECKSUM_COMPLETE) {
247                 const unsigned char *nh = skb_network_header(skb);
248                 skb->csum = csum_sub(skb->csum,
249                                      csum_partial(nh, (u8 *)(fhdr + 1) - nh,
250                                                   0));
251         }
252
253         /* Is this the final fragment? */
254         if (!(fhdr->frag_off & htons(IP6_MF))) {
255                 /* If we already have some bits beyond end
256                  * or have different end, the segment is corrupted.
257                  */
258                 if (end < fq->q.len ||
259                     ((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len)) {
260                         pr_debug("already received last fragment\n");
261                         goto err;
262                 }
263                 fq->q.last_in |= INET_FRAG_LAST_IN;
264                 fq->q.len = end;
265         } else {
266                 /* Check if the fragment is rounded to 8 bytes.
267                  * Required by the RFC.
268                  */
269                 if (end & 0x7) {
270                         /* RFC2460 says always send parameter problem in
271                          * this case. -DaveM
272                          */
273                         pr_debug("end of fragment not rounded to 8 bytes.\n");
274                         return -1;
275                 }
276                 if (end > fq->q.len) {
277                         /* Some bits beyond end -> corruption. */
278                         if (fq->q.last_in & INET_FRAG_LAST_IN) {
279                                 pr_debug("last packet already reached.\n");
280                                 goto err;
281                         }
282                         fq->q.len = end;
283                 }
284         }
285
286         if (end == offset)
287                 goto err;
288
289         /* Point into the IP datagram 'data' part. */
290         if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) {
291                 pr_debug("queue: message is too short.\n");
292                 goto err;
293         }
294         if (pskb_trim_rcsum(skb, end - offset)) {
295                 pr_debug("Can't trim\n");
296                 goto err;
297         }
298
299         /* Find out which fragments are in front and at the back of us
300          * in the chain of fragments so far.  We must know where to put
301          * this fragment, right?
302          */
303         prev = NULL;
304         for (next = fq->q.fragments; next != NULL; next = next->next) {
305                 if (NFCT_FRAG6_CB(next)->offset >= offset)
306                         break;  /* bingo! */
307                 prev = next;
308         }
309
310         /* We found where to put this one.  Check for overlap with
311          * preceding fragment, and, if needed, align things so that
312          * any overlaps are eliminated.
313          */
314         if (prev) {
315                 int i = (NFCT_FRAG6_CB(prev)->offset + prev->len) - offset;
316
317                 if (i > 0) {
318                         offset += i;
319                         if (end <= offset) {
320                                 pr_debug("overlap\n");
321                                 goto err;
322                         }
323                         if (!pskb_pull(skb, i)) {
324                                 pr_debug("Can't pull\n");
325                                 goto err;
326                         }
327                         if (skb->ip_summed != CHECKSUM_UNNECESSARY)
328                                 skb->ip_summed = CHECKSUM_NONE;
329                 }
330         }
331
332         /* Look for overlap with succeeding segments.
333          * If we can merge fragments, do it.
334          */
335         while (next && NFCT_FRAG6_CB(next)->offset < end) {
336                 /* overlap is 'i' bytes */
337                 int i = end - NFCT_FRAG6_CB(next)->offset;
338
339                 if (i < next->len) {
340                         /* Eat head of the next overlapped fragment
341                          * and leave the loop. The next ones cannot overlap.
342                          */
343                         pr_debug("Eat head of the overlapped parts.: %d", i);
344                         if (!pskb_pull(next, i))
345                                 goto err;
346
347                         /* next fragment */
348                         NFCT_FRAG6_CB(next)->offset += i;
349                         fq->q.meat -= i;
350                         if (next->ip_summed != CHECKSUM_UNNECESSARY)
351                                 next->ip_summed = CHECKSUM_NONE;
352                         break;
353                 } else {
354                         struct sk_buff *free_it = next;
355
356                         /* Old fragmnet is completely overridden with
357                          * new one drop it.
358                          */
359                         next = next->next;
360
361                         if (prev)
362                                 prev->next = next;
363                         else
364                                 fq->q.fragments = next;
365
366                         fq->q.meat -= free_it->len;
367                         frag_kfree_skb(free_it, NULL);
368                 }
369         }
370
371         NFCT_FRAG6_CB(skb)->offset = offset;
372
373         /* Insert this fragment in the chain of fragments. */
374         skb->next = next;
375         if (prev)
376                 prev->next = skb;
377         else
378                 fq->q.fragments = skb;
379
380         skb->dev = NULL;
381         fq->q.stamp = skb->tstamp;
382         fq->q.meat += skb->len;
383         atomic_add(skb->truesize, &nf_init_frags.mem);
384
385         /* The first fragment.
386          * nhoffset is obtained from the first fragment, of course.
387          */
388         if (offset == 0) {
389                 fq->nhoffset = nhoff;
390                 fq->q.last_in |= INET_FRAG_FIRST_IN;
391         }
392         write_lock(&nf_frags.lock);
393         list_move_tail(&fq->q.lru_list, &nf_init_frags.lru_list);
394         write_unlock(&nf_frags.lock);
395         return 0;
396
397 err:
398         return -1;
399 }
400
401 /*
402  *      Check if this packet is complete.
403  *      Returns NULL on failure by any reason, and pointer
404  *      to current nexthdr field in reassembled frame.
405  *
406  *      It is called with locked fq, and caller must check that
407  *      queue is eligible for reassembly i.e. it is not COMPLETE,
408  *      the last and the first frames arrived and all the bits are here.
409  */
410 static struct sk_buff *
411 nf_ct_frag6_reasm(struct nf_ct_frag6_queue *fq, struct net_device *dev)
412 {
413         struct sk_buff *fp, *op, *head = fq->q.fragments;
414         int    payload_len;
415
416         fq_kill(fq);
417
418         BUG_TRAP(head != NULL);
419         BUG_TRAP(NFCT_FRAG6_CB(head)->offset == 0);
420
421         /* Unfragmented part is taken from the first segment. */
422         payload_len = ((head->data - skb_network_header(head)) -
423                        sizeof(struct ipv6hdr) + fq->q.len -
424                        sizeof(struct frag_hdr));
425         if (payload_len > IPV6_MAXPLEN) {
426                 pr_debug("payload len is too large.\n");
427                 goto out_oversize;
428         }
429
430         /* Head of list must not be cloned. */
431         if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC)) {
432                 pr_debug("skb is cloned but can't expand head");
433                 goto out_oom;
434         }
435
436         /* If the first fragment is fragmented itself, we split
437          * it to two chunks: the first with data and paged part
438          * and the second, holding only fragments. */
439         if (skb_shinfo(head)->frag_list) {
440                 struct sk_buff *clone;
441                 int i, plen = 0;
442
443                 if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL) {
444                         pr_debug("Can't alloc skb\n");
445                         goto out_oom;
446                 }
447                 clone->next = head->next;
448                 head->next = clone;
449                 skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list;
450                 skb_shinfo(head)->frag_list = NULL;
451                 for (i=0; i<skb_shinfo(head)->nr_frags; i++)
452                         plen += skb_shinfo(head)->frags[i].size;
453                 clone->len = clone->data_len = head->data_len - plen;
454                 head->data_len -= clone->len;
455                 head->len -= clone->len;
456                 clone->csum = 0;
457                 clone->ip_summed = head->ip_summed;
458
459                 NFCT_FRAG6_CB(clone)->orig = NULL;
460                 atomic_add(clone->truesize, &nf_init_frags.mem);
461         }
462
463         /* We have to remove fragment header from datagram and to relocate
464          * header in order to calculate ICV correctly. */
465         skb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0];
466         memmove(head->head + sizeof(struct frag_hdr), head->head,
467                 (head->data - head->head) - sizeof(struct frag_hdr));
468         head->mac_header += sizeof(struct frag_hdr);
469         head->network_header += sizeof(struct frag_hdr);
470
471         skb_shinfo(head)->frag_list = head->next;
472         skb_reset_transport_header(head);
473         skb_push(head, head->data - skb_network_header(head));
474         atomic_sub(head->truesize, &nf_init_frags.mem);
475
476         for (fp=head->next; fp; fp = fp->next) {
477                 head->data_len += fp->len;
478                 head->len += fp->len;
479                 if (head->ip_summed != fp->ip_summed)
480                         head->ip_summed = CHECKSUM_NONE;
481                 else if (head->ip_summed == CHECKSUM_COMPLETE)
482                         head->csum = csum_add(head->csum, fp->csum);
483                 head->truesize += fp->truesize;
484                 atomic_sub(fp->truesize, &nf_init_frags.mem);
485         }
486
487         head->next = NULL;
488         head->dev = dev;
489         head->tstamp = fq->q.stamp;
490         ipv6_hdr(head)->payload_len = htons(payload_len);
491
492         /* Yes, and fold redundant checksum back. 8) */
493         if (head->ip_summed == CHECKSUM_COMPLETE)
494                 head->csum = csum_partial(skb_network_header(head),
495                                           skb_network_header_len(head),
496                                           head->csum);
497
498         fq->q.fragments = NULL;
499
500         /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */
501         fp = skb_shinfo(head)->frag_list;
502         if (NFCT_FRAG6_CB(fp)->orig == NULL)
503                 /* at above code, head skb is divided into two skbs. */
504                 fp = fp->next;
505
506         op = NFCT_FRAG6_CB(head)->orig;
507         for (; fp; fp = fp->next) {
508                 struct sk_buff *orig = NFCT_FRAG6_CB(fp)->orig;
509
510                 op->next = orig;
511                 op = orig;
512                 NFCT_FRAG6_CB(fp)->orig = NULL;
513         }
514
515         return head;
516
517 out_oversize:
518         if (net_ratelimit())
519                 printk(KERN_DEBUG "nf_ct_frag6_reasm: payload len = %d\n", payload_len);
520         goto out_fail;
521 out_oom:
522         if (net_ratelimit())
523                 printk(KERN_DEBUG "nf_ct_frag6_reasm: no memory for reassembly\n");
524 out_fail:
525         return NULL;
526 }
527
528 /*
529  * find the header just before Fragment Header.
530  *
531  * if success return 0 and set ...
532  * (*prevhdrp): the value of "Next Header Field" in the header
533  *              just before Fragment Header.
534  * (*prevhoff): the offset of "Next Header Field" in the header
535  *              just before Fragment Header.
536  * (*fhoff)   : the offset of Fragment Header.
537  *
538  * Based on ipv6_skip_hdr() in net/ipv6/exthdr.c
539  *
540  */
541 static int
542 find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
543 {
544         u8 nexthdr = ipv6_hdr(skb)->nexthdr;
545         const int netoff = skb_network_offset(skb);
546         u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
547         int start = netoff + sizeof(struct ipv6hdr);
548         int len = skb->len - start;
549         u8 prevhdr = NEXTHDR_IPV6;
550
551         while (nexthdr != NEXTHDR_FRAGMENT) {
552                 struct ipv6_opt_hdr hdr;
553                 int hdrlen;
554
555                 if (!ipv6_ext_hdr(nexthdr)) {
556                         return -1;
557                 }
558                 if (len < (int)sizeof(struct ipv6_opt_hdr)) {
559                         pr_debug("too short\n");
560                         return -1;
561                 }
562                 if (nexthdr == NEXTHDR_NONE) {
563                         pr_debug("next header is none\n");
564                         return -1;
565                 }
566                 if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
567                         BUG();
568                 if (nexthdr == NEXTHDR_AUTH)
569                         hdrlen = (hdr.hdrlen+2)<<2;
570                 else
571                         hdrlen = ipv6_optlen(&hdr);
572
573                 prevhdr = nexthdr;
574                 prev_nhoff = start;
575
576                 nexthdr = hdr.nexthdr;
577                 len -= hdrlen;
578                 start += hdrlen;
579         }
580
581         if (len < 0)
582                 return -1;
583
584         *prevhdrp = prevhdr;
585         *prevhoff = prev_nhoff;
586         *fhoff = start;
587
588         return 0;
589 }
590
591 struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb)
592 {
593         struct sk_buff *clone;
594         struct net_device *dev = skb->dev;
595         struct frag_hdr *fhdr;
596         struct nf_ct_frag6_queue *fq;
597         struct ipv6hdr *hdr;
598         int fhoff, nhoff;
599         u8 prevhdr;
600         struct sk_buff *ret_skb = NULL;
601
602         /* Jumbo payload inhibits frag. header */
603         if (ipv6_hdr(skb)->payload_len == 0) {
604                 pr_debug("payload len = 0\n");
605                 return skb;
606         }
607
608         if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0)
609                 return skb;
610
611         clone = skb_clone(skb, GFP_ATOMIC);
612         if (clone == NULL) {
613                 pr_debug("Can't clone skb\n");
614                 return skb;
615         }
616
617         NFCT_FRAG6_CB(clone)->orig = skb;
618
619         if (!pskb_may_pull(clone, fhoff + sizeof(*fhdr))) {
620                 pr_debug("message is too short.\n");
621                 goto ret_orig;
622         }
623
624         skb_set_transport_header(clone, fhoff);
625         hdr = ipv6_hdr(clone);
626         fhdr = (struct frag_hdr *)skb_transport_header(clone);
627
628         if (!(fhdr->frag_off & htons(0xFFF9))) {
629                 pr_debug("Invalid fragment offset\n");
630                 /* It is not a fragmented frame */
631                 goto ret_orig;
632         }
633
634         if (atomic_read(&nf_init_frags.mem) > nf_init_frags.high_thresh)
635                 nf_ct_frag6_evictor();
636
637         fq = fq_find(fhdr->identification, &hdr->saddr, &hdr->daddr);
638         if (fq == NULL) {
639                 pr_debug("Can't find and can't create new queue\n");
640                 goto ret_orig;
641         }
642
643         spin_lock_bh(&fq->q.lock);
644
645         if (nf_ct_frag6_queue(fq, clone, fhdr, nhoff) < 0) {
646                 spin_unlock_bh(&fq->q.lock);
647                 pr_debug("Can't insert skb to queue\n");
648                 fq_put(fq);
649                 goto ret_orig;
650         }
651
652         if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
653             fq->q.meat == fq->q.len) {
654                 ret_skb = nf_ct_frag6_reasm(fq, dev);
655                 if (ret_skb == NULL)
656                         pr_debug("Can't reassemble fragmented packets\n");
657         }
658         spin_unlock_bh(&fq->q.lock);
659
660         fq_put(fq);
661         return ret_skb;
662
663 ret_orig:
664         kfree_skb(clone);
665         return skb;
666 }
667
668 void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
669                         struct net_device *in, struct net_device *out,
670                         int (*okfn)(struct sk_buff *))
671 {
672         struct sk_buff *s, *s2;
673
674         for (s = NFCT_FRAG6_CB(skb)->orig; s;) {
675                 nf_conntrack_put_reasm(s->nfct_reasm);
676                 nf_conntrack_get_reasm(skb);
677                 s->nfct_reasm = skb;
678
679                 s2 = s->next;
680                 s->next = NULL;
681
682                 NF_HOOK_THRESH(PF_INET6, hooknum, s, in, out, okfn,
683                                NF_IP6_PRI_CONNTRACK_DEFRAG + 1);
684                 s = s2;
685         }
686         nf_conntrack_put_reasm(skb);
687 }
688
689 int nf_ct_frag6_init(void)
690 {
691         nf_frags.hashfn = nf_hashfn;
692         nf_frags.constructor = ip6_frag_init;
693         nf_frags.destructor = NULL;
694         nf_frags.skb_free = nf_skb_free;
695         nf_frags.qsize = sizeof(struct nf_ct_frag6_queue);
696         nf_frags.match = ip6_frag_match;
697         nf_frags.frag_expire = nf_ct_frag6_expire;
698         nf_frags.secret_interval = 10 * 60 * HZ;
699         nf_init_frags.timeout = IPV6_FRAG_TIMEOUT;
700         nf_init_frags.high_thresh = 256 * 1024;
701         nf_init_frags.low_thresh = 192 * 1024;
702         inet_frags_init_net(&nf_init_frags);
703         inet_frags_init(&nf_frags);
704
705         return 0;
706 }
707
708 void nf_ct_frag6_cleanup(void)
709 {
710         inet_frags_fini(&nf_frags);
711
712         nf_init_frags.low_thresh = 0;
713         nf_ct_frag6_evictor();
714 }