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