2 * IPv6 fragment reassembly for connection tracking
4 * Copyright (C)2004 USAGI/WIDE Project
7 * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
9 * Based on: net/ipv6/reassembly.c
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.
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>
36 #include <net/protocol.h>
37 #include <net/transp_v6.h>
38 #include <net/rawv6.h>
39 #include <net/ndisc.h>
40 #include <net/addrconf.h>
41 #include <linux/sysctl.h>
42 #include <linux/netfilter.h>
43 #include <linux/netfilter_ipv6.h>
44 #include <linux/kernel.h>
45 #include <linux/module.h>
50 #define DEBUGP(format, args...)
53 #define NF_CT_FRAG6_HIGH_THRESH 262144 /* == 256*1024 */
54 #define NF_CT_FRAG6_LOW_THRESH 196608 /* == 192*1024 */
55 #define NF_CT_FRAG6_TIMEOUT IPV6_FRAG_TIMEOUT
57 unsigned int nf_ct_frag6_high_thresh __read_mostly
= 256*1024;
58 unsigned int nf_ct_frag6_low_thresh __read_mostly
= 192*1024;
59 unsigned long nf_ct_frag6_timeout __read_mostly
= IPV6_FRAG_TIMEOUT
;
61 struct nf_ct_frag6_skb_cb
63 struct inet6_skb_parm h
;
68 #define NFCT_FRAG6_CB(skb) ((struct nf_ct_frag6_skb_cb*)((skb)->cb))
70 struct nf_ct_frag6_queue
72 struct hlist_node list
;
73 struct list_head lru_list
; /* lru list member */
75 __be32 id
; /* fragment id */
76 struct in6_addr saddr
;
77 struct in6_addr daddr
;
81 struct timer_list timer
; /* expire timer */
82 struct sk_buff
*fragments
;
87 __u8 last_in
; /* has first/last segment arrived? */
96 #define FRAG6Q_HASHSZ 64
98 static struct hlist_head nf_ct_frag6_hash
[FRAG6Q_HASHSZ
];
99 static DEFINE_RWLOCK(nf_ct_frag6_lock
);
100 static u32 nf_ct_frag6_hash_rnd
;
101 static LIST_HEAD(nf_ct_frag6_lru_list
);
102 int nf_ct_frag6_nqueues
= 0;
104 static __inline__
void __fq_unlink(struct nf_ct_frag6_queue
*fq
)
106 hlist_del(&fq
->list
);
107 list_del(&fq
->lru_list
);
108 nf_ct_frag6_nqueues
--;
111 static __inline__
void fq_unlink(struct nf_ct_frag6_queue
*fq
)
113 write_lock(&nf_ct_frag6_lock
);
115 write_unlock(&nf_ct_frag6_lock
);
118 static unsigned int ip6qhashfn(__be32 id
, struct in6_addr
*saddr
,
119 struct in6_addr
*daddr
)
123 a
= (__force u32
)saddr
->s6_addr32
[0];
124 b
= (__force u32
)saddr
->s6_addr32
[1];
125 c
= (__force u32
)saddr
->s6_addr32
[2];
127 a
+= JHASH_GOLDEN_RATIO
;
128 b
+= JHASH_GOLDEN_RATIO
;
129 c
+= nf_ct_frag6_hash_rnd
;
130 __jhash_mix(a
, b
, c
);
132 a
+= (__force u32
)saddr
->s6_addr32
[3];
133 b
+= (__force u32
)daddr
->s6_addr32
[0];
134 c
+= (__force u32
)daddr
->s6_addr32
[1];
135 __jhash_mix(a
, b
, c
);
137 a
+= (__force u32
)daddr
->s6_addr32
[2];
138 b
+= (__force u32
)daddr
->s6_addr32
[3];
139 c
+= (__force u32
)id
;
140 __jhash_mix(a
, b
, c
);
142 return c
& (FRAG6Q_HASHSZ
- 1);
145 static struct timer_list nf_ct_frag6_secret_timer
;
146 int nf_ct_frag6_secret_interval
= 10 * 60 * HZ
;
148 static void nf_ct_frag6_secret_rebuild(unsigned long dummy
)
150 unsigned long now
= jiffies
;
153 write_lock(&nf_ct_frag6_lock
);
154 get_random_bytes(&nf_ct_frag6_hash_rnd
, sizeof(u32
));
155 for (i
= 0; i
< FRAG6Q_HASHSZ
; i
++) {
156 struct nf_ct_frag6_queue
*q
;
157 struct hlist_node
*p
, *n
;
159 hlist_for_each_entry_safe(q
, p
, n
, &nf_ct_frag6_hash
[i
], list
) {
160 unsigned int hval
= ip6qhashfn(q
->id
,
165 /* Relink to new hash chain. */
166 hlist_add_head(&q
->list
,
167 &nf_ct_frag6_hash
[hval
]);
171 write_unlock(&nf_ct_frag6_lock
);
173 mod_timer(&nf_ct_frag6_secret_timer
, now
+ nf_ct_frag6_secret_interval
);
176 atomic_t nf_ct_frag6_mem
= ATOMIC_INIT(0);
178 /* Memory Tracking Functions. */
179 static inline void frag_kfree_skb(struct sk_buff
*skb
, unsigned int *work
)
182 *work
-= skb
->truesize
;
183 atomic_sub(skb
->truesize
, &nf_ct_frag6_mem
);
184 if (NFCT_FRAG6_CB(skb
)->orig
)
185 kfree_skb(NFCT_FRAG6_CB(skb
)->orig
);
190 static inline void frag_free_queue(struct nf_ct_frag6_queue
*fq
,
194 *work
-= sizeof(struct nf_ct_frag6_queue
);
195 atomic_sub(sizeof(struct nf_ct_frag6_queue
), &nf_ct_frag6_mem
);
199 static inline struct nf_ct_frag6_queue
*frag_alloc_queue(void)
201 struct nf_ct_frag6_queue
*fq
= kmalloc(sizeof(struct nf_ct_frag6_queue
), GFP_ATOMIC
);
205 atomic_add(sizeof(struct nf_ct_frag6_queue
), &nf_ct_frag6_mem
);
209 /* Destruction primitives. */
211 /* Complete destruction of fq. */
212 static void nf_ct_frag6_destroy(struct nf_ct_frag6_queue
*fq
,
217 BUG_TRAP(fq
->last_in
&COMPLETE
);
218 BUG_TRAP(del_timer(&fq
->timer
) == 0);
220 /* Release all fragment data. */
223 struct sk_buff
*xp
= fp
->next
;
225 frag_kfree_skb(fp
, work
);
229 frag_free_queue(fq
, work
);
232 static __inline__
void fq_put(struct nf_ct_frag6_queue
*fq
, unsigned int *work
)
234 if (atomic_dec_and_test(&fq
->refcnt
))
235 nf_ct_frag6_destroy(fq
, work
);
238 /* Kill fq entry. It is not destroyed immediately,
239 * because caller (and someone more) holds reference count.
241 static __inline__
void fq_kill(struct nf_ct_frag6_queue
*fq
)
243 if (del_timer(&fq
->timer
))
244 atomic_dec(&fq
->refcnt
);
246 if (!(fq
->last_in
& COMPLETE
)) {
248 atomic_dec(&fq
->refcnt
);
249 fq
->last_in
|= COMPLETE
;
253 static void nf_ct_frag6_evictor(void)
255 struct nf_ct_frag6_queue
*fq
;
256 struct list_head
*tmp
;
259 work
= atomic_read(&nf_ct_frag6_mem
);
260 if (work
<= nf_ct_frag6_low_thresh
)
263 work
-= nf_ct_frag6_low_thresh
;
265 read_lock(&nf_ct_frag6_lock
);
266 if (list_empty(&nf_ct_frag6_lru_list
)) {
267 read_unlock(&nf_ct_frag6_lock
);
270 tmp
= nf_ct_frag6_lru_list
.next
;
272 fq
= list_entry(tmp
, struct nf_ct_frag6_queue
, lru_list
);
273 atomic_inc(&fq
->refcnt
);
274 read_unlock(&nf_ct_frag6_lock
);
276 spin_lock(&fq
->lock
);
277 if (!(fq
->last_in
&COMPLETE
))
279 spin_unlock(&fq
->lock
);
285 static void nf_ct_frag6_expire(unsigned long data
)
287 struct nf_ct_frag6_queue
*fq
= (struct nf_ct_frag6_queue
*) data
;
289 spin_lock(&fq
->lock
);
291 if (fq
->last_in
& COMPLETE
)
297 spin_unlock(&fq
->lock
);
301 /* Creation primitives. */
303 static struct nf_ct_frag6_queue
*nf_ct_frag6_intern(unsigned int hash
,
304 struct nf_ct_frag6_queue
*fq_in
)
306 struct nf_ct_frag6_queue
*fq
;
308 struct hlist_node
*n
;
311 write_lock(&nf_ct_frag6_lock
);
313 hlist_for_each_entry(fq
, n
, &nf_ct_frag6_hash
[hash
], list
) {
314 if (fq
->id
== fq_in
->id
&&
315 ipv6_addr_equal(&fq_in
->saddr
, &fq
->saddr
) &&
316 ipv6_addr_equal(&fq_in
->daddr
, &fq
->daddr
)) {
317 atomic_inc(&fq
->refcnt
);
318 write_unlock(&nf_ct_frag6_lock
);
319 fq_in
->last_in
|= COMPLETE
;
327 if (!mod_timer(&fq
->timer
, jiffies
+ nf_ct_frag6_timeout
))
328 atomic_inc(&fq
->refcnt
);
330 atomic_inc(&fq
->refcnt
);
331 hlist_add_head(&fq
->list
, &nf_ct_frag6_hash
[hash
]);
332 INIT_LIST_HEAD(&fq
->lru_list
);
333 list_add_tail(&fq
->lru_list
, &nf_ct_frag6_lru_list
);
334 nf_ct_frag6_nqueues
++;
335 write_unlock(&nf_ct_frag6_lock
);
340 static struct nf_ct_frag6_queue
*
341 nf_ct_frag6_create(unsigned int hash
, __be32 id
, struct in6_addr
*src
, struct in6_addr
*dst
)
343 struct nf_ct_frag6_queue
*fq
;
345 if ((fq
= frag_alloc_queue()) == NULL
) {
346 DEBUGP("Can't alloc new queue\n");
350 memset(fq
, 0, sizeof(struct nf_ct_frag6_queue
));
353 ipv6_addr_copy(&fq
->saddr
, src
);
354 ipv6_addr_copy(&fq
->daddr
, dst
);
356 init_timer(&fq
->timer
);
357 fq
->timer
.function
= nf_ct_frag6_expire
;
358 fq
->timer
.data
= (long) fq
;
359 spin_lock_init(&fq
->lock
);
360 atomic_set(&fq
->refcnt
, 1);
362 return nf_ct_frag6_intern(hash
, fq
);
368 static __inline__
struct nf_ct_frag6_queue
*
369 fq_find(__be32 id
, struct in6_addr
*src
, struct in6_addr
*dst
)
371 struct nf_ct_frag6_queue
*fq
;
372 struct hlist_node
*n
;
373 unsigned int hash
= ip6qhashfn(id
, src
, dst
);
375 read_lock(&nf_ct_frag6_lock
);
376 hlist_for_each_entry(fq
, n
, &nf_ct_frag6_hash
[hash
], list
) {
378 ipv6_addr_equal(src
, &fq
->saddr
) &&
379 ipv6_addr_equal(dst
, &fq
->daddr
)) {
380 atomic_inc(&fq
->refcnt
);
381 read_unlock(&nf_ct_frag6_lock
);
385 read_unlock(&nf_ct_frag6_lock
);
387 return nf_ct_frag6_create(hash
, id
, src
, dst
);
391 static int nf_ct_frag6_queue(struct nf_ct_frag6_queue
*fq
, struct sk_buff
*skb
,
392 struct frag_hdr
*fhdr
, int nhoff
)
394 struct sk_buff
*prev
, *next
;
397 if (fq
->last_in
& COMPLETE
) {
398 DEBUGP("Allready completed\n");
402 offset
= ntohs(fhdr
->frag_off
) & ~0x7;
403 end
= offset
+ (ntohs(ipv6_hdr(skb
)->payload_len
) -
404 ((u8
*)(fhdr
+ 1) - (u8
*)(ipv6_hdr(skb
) + 1)));
406 if ((unsigned int)end
> IPV6_MAXPLEN
) {
407 DEBUGP("offset is too large.\n");
411 if (skb
->ip_summed
== CHECKSUM_COMPLETE
) {
412 const unsigned char *nh
= skb_network_header(skb
);
413 skb
->csum
= csum_sub(skb
->csum
,
414 csum_partial(nh
, (u8
*)(fhdr
+ 1) - nh
,
418 /* Is this the final fragment? */
419 if (!(fhdr
->frag_off
& htons(IP6_MF
))) {
420 /* If we already have some bits beyond end
421 * or have different end, the segment is corrupted.
424 ((fq
->last_in
& LAST_IN
) && end
!= fq
->len
)) {
425 DEBUGP("already received last fragment\n");
428 fq
->last_in
|= LAST_IN
;
431 /* Check if the fragment is rounded to 8 bytes.
432 * Required by the RFC.
435 /* RFC2460 says always send parameter problem in
438 DEBUGP("the end of this fragment is not rounded to 8 bytes.\n");
442 /* Some bits beyond end -> corruption. */
443 if (fq
->last_in
& LAST_IN
) {
444 DEBUGP("last packet already reached.\n");
454 /* Point into the IP datagram 'data' part. */
455 if (!pskb_pull(skb
, (u8
*) (fhdr
+ 1) - skb
->data
)) {
456 DEBUGP("queue: message is too short.\n");
459 if (pskb_trim_rcsum(skb
, end
- offset
)) {
460 DEBUGP("Can't trim\n");
464 /* Find out which fragments are in front and at the back of us
465 * in the chain of fragments so far. We must know where to put
466 * this fragment, right?
469 for (next
= fq
->fragments
; next
!= NULL
; next
= next
->next
) {
470 if (NFCT_FRAG6_CB(next
)->offset
>= offset
)
475 /* We found where to put this one. Check for overlap with
476 * preceding fragment, and, if needed, align things so that
477 * any overlaps are eliminated.
480 int i
= (NFCT_FRAG6_CB(prev
)->offset
+ prev
->len
) - offset
;
488 if (!pskb_pull(skb
, i
)) {
489 DEBUGP("Can't pull\n");
492 if (skb
->ip_summed
!= CHECKSUM_UNNECESSARY
)
493 skb
->ip_summed
= CHECKSUM_NONE
;
497 /* Look for overlap with succeeding segments.
498 * If we can merge fragments, do it.
500 while (next
&& NFCT_FRAG6_CB(next
)->offset
< end
) {
501 /* overlap is 'i' bytes */
502 int i
= end
- NFCT_FRAG6_CB(next
)->offset
;
505 /* Eat head of the next overlapped fragment
506 * and leave the loop. The next ones cannot overlap.
508 DEBUGP("Eat head of the overlapped parts.: %d", i
);
509 if (!pskb_pull(next
, i
))
513 NFCT_FRAG6_CB(next
)->offset
+= i
;
515 if (next
->ip_summed
!= CHECKSUM_UNNECESSARY
)
516 next
->ip_summed
= CHECKSUM_NONE
;
519 struct sk_buff
*free_it
= next
;
521 /* Old fragmnet is completely overridden with
529 fq
->fragments
= next
;
531 fq
->meat
-= free_it
->len
;
532 frag_kfree_skb(free_it
, NULL
);
536 NFCT_FRAG6_CB(skb
)->offset
= offset
;
538 /* Insert this fragment in the chain of fragments. */
546 fq
->stamp
= skb
->tstamp
;
547 fq
->meat
+= skb
->len
;
548 atomic_add(skb
->truesize
, &nf_ct_frag6_mem
);
550 /* The first fragment.
551 * nhoffset is obtained from the first fragment, of course.
554 fq
->nhoffset
= nhoff
;
555 fq
->last_in
|= FIRST_IN
;
557 write_lock(&nf_ct_frag6_lock
);
558 list_move_tail(&fq
->lru_list
, &nf_ct_frag6_lru_list
);
559 write_unlock(&nf_ct_frag6_lock
);
567 * Check if this packet is complete.
568 * Returns NULL on failure by any reason, and pointer
569 * to current nexthdr field in reassembled frame.
571 * It is called with locked fq, and caller must check that
572 * queue is eligible for reassembly i.e. it is not COMPLETE,
573 * the last and the first frames arrived and all the bits are here.
575 static struct sk_buff
*
576 nf_ct_frag6_reasm(struct nf_ct_frag6_queue
*fq
, struct net_device
*dev
)
578 struct sk_buff
*fp
, *op
, *head
= fq
->fragments
;
583 BUG_TRAP(head
!= NULL
);
584 BUG_TRAP(NFCT_FRAG6_CB(head
)->offset
== 0);
586 /* Unfragmented part is taken from the first segment. */
587 payload_len
= ((head
->data
- skb_network_header(head
)) -
588 sizeof(struct ipv6hdr
) + fq
->len
-
589 sizeof(struct frag_hdr
));
590 if (payload_len
> IPV6_MAXPLEN
) {
591 DEBUGP("payload len is too large.\n");
595 /* Head of list must not be cloned. */
596 if (skb_cloned(head
) && pskb_expand_head(head
, 0, 0, GFP_ATOMIC
)) {
597 DEBUGP("skb is cloned but can't expand head");
601 /* If the first fragment is fragmented itself, we split
602 * it to two chunks: the first with data and paged part
603 * and the second, holding only fragments. */
604 if (skb_shinfo(head
)->frag_list
) {
605 struct sk_buff
*clone
;
608 if ((clone
= alloc_skb(0, GFP_ATOMIC
)) == NULL
) {
609 DEBUGP("Can't alloc skb\n");
612 clone
->next
= head
->next
;
614 skb_shinfo(clone
)->frag_list
= skb_shinfo(head
)->frag_list
;
615 skb_shinfo(head
)->frag_list
= NULL
;
616 for (i
=0; i
<skb_shinfo(head
)->nr_frags
; i
++)
617 plen
+= skb_shinfo(head
)->frags
[i
].size
;
618 clone
->len
= clone
->data_len
= head
->data_len
- plen
;
619 head
->data_len
-= clone
->len
;
620 head
->len
-= clone
->len
;
622 clone
->ip_summed
= head
->ip_summed
;
624 NFCT_FRAG6_CB(clone
)->orig
= NULL
;
625 atomic_add(clone
->truesize
, &nf_ct_frag6_mem
);
628 /* We have to remove fragment header from datagram and to relocate
629 * header in order to calculate ICV correctly. */
630 skb_network_header(head
)[fq
->nhoffset
] = skb_transport_header(head
)[0];
631 memmove(head
->head
+ sizeof(struct frag_hdr
), head
->head
,
632 (head
->data
- head
->head
) - sizeof(struct frag_hdr
));
633 head
->mac_header
+= sizeof(struct frag_hdr
);
634 head
->network_header
+= sizeof(struct frag_hdr
);
636 skb_shinfo(head
)->frag_list
= head
->next
;
637 skb_reset_transport_header(head
);
638 skb_push(head
, head
->data
- skb_network_header(head
));
639 atomic_sub(head
->truesize
, &nf_ct_frag6_mem
);
641 for (fp
=head
->next
; fp
; fp
= fp
->next
) {
642 head
->data_len
+= fp
->len
;
643 head
->len
+= fp
->len
;
644 if (head
->ip_summed
!= fp
->ip_summed
)
645 head
->ip_summed
= CHECKSUM_NONE
;
646 else if (head
->ip_summed
== CHECKSUM_COMPLETE
)
647 head
->csum
= csum_add(head
->csum
, fp
->csum
);
648 head
->truesize
+= fp
->truesize
;
649 atomic_sub(fp
->truesize
, &nf_ct_frag6_mem
);
654 head
->tstamp
= fq
->stamp
;
655 ipv6_hdr(head
)->payload_len
= htons(payload_len
);
657 /* Yes, and fold redundant checksum back. 8) */
658 if (head
->ip_summed
== CHECKSUM_COMPLETE
)
659 head
->csum
= csum_partial(skb_network_header(head
),
660 skb_network_header_len(head
),
663 fq
->fragments
= NULL
;
665 /* all original skbs are linked into the NFCT_FRAG6_CB(head).orig */
666 fp
= skb_shinfo(head
)->frag_list
;
667 if (NFCT_FRAG6_CB(fp
)->orig
== NULL
)
668 /* at above code, head skb is divided into two skbs. */
671 op
= NFCT_FRAG6_CB(head
)->orig
;
672 for (; fp
; fp
= fp
->next
) {
673 struct sk_buff
*orig
= NFCT_FRAG6_CB(fp
)->orig
;
677 NFCT_FRAG6_CB(fp
)->orig
= NULL
;
684 printk(KERN_DEBUG
"nf_ct_frag6_reasm: payload len = %d\n", payload_len
);
688 printk(KERN_DEBUG
"nf_ct_frag6_reasm: no memory for reassembly\n");
694 * find the header just before Fragment Header.
696 * if success return 0 and set ...
697 * (*prevhdrp): the value of "Next Header Field" in the header
698 * just before Fragment Header.
699 * (*prevhoff): the offset of "Next Header Field" in the header
700 * just before Fragment Header.
701 * (*fhoff) : the offset of Fragment Header.
703 * Based on ipv6_skip_hdr() in net/ipv6/exthdr.c
707 find_prev_fhdr(struct sk_buff
*skb
, u8
*prevhdrp
, int *prevhoff
, int *fhoff
)
709 u8 nexthdr
= ipv6_hdr(skb
)->nexthdr
;
710 u8 prev_nhoff
= (u8
*)&ipv6_hdr(skb
)->nexthdr
- skb
->data
;
711 int start
= (u8
*)(ipv6_hdr(skb
) + 1) - skb
->data
;
712 int len
= skb
->len
- start
;
713 u8 prevhdr
= NEXTHDR_IPV6
;
715 while (nexthdr
!= NEXTHDR_FRAGMENT
) {
716 struct ipv6_opt_hdr hdr
;
719 if (!ipv6_ext_hdr(nexthdr
)) {
722 if (len
< (int)sizeof(struct ipv6_opt_hdr
)) {
723 DEBUGP("too short\n");
726 if (nexthdr
== NEXTHDR_NONE
) {
727 DEBUGP("next header is none\n");
730 if (skb_copy_bits(skb
, start
, &hdr
, sizeof(hdr
)))
732 if (nexthdr
== NEXTHDR_AUTH
)
733 hdrlen
= (hdr
.hdrlen
+2)<<2;
735 hdrlen
= ipv6_optlen(&hdr
);
740 nexthdr
= hdr
.nexthdr
;
749 *prevhoff
= prev_nhoff
;
755 struct sk_buff
*nf_ct_frag6_gather(struct sk_buff
*skb
)
757 struct sk_buff
*clone
;
758 struct net_device
*dev
= skb
->dev
;
759 struct frag_hdr
*fhdr
;
760 struct nf_ct_frag6_queue
*fq
;
764 struct sk_buff
*ret_skb
= NULL
;
766 /* Jumbo payload inhibits frag. header */
767 if (ipv6_hdr(skb
)->payload_len
== 0) {
768 DEBUGP("payload len = 0\n");
772 if (find_prev_fhdr(skb
, &prevhdr
, &nhoff
, &fhoff
) < 0)
775 clone
= skb_clone(skb
, GFP_ATOMIC
);
777 DEBUGP("Can't clone skb\n");
781 NFCT_FRAG6_CB(clone
)->orig
= skb
;
783 if (!pskb_may_pull(clone
, fhoff
+ sizeof(*fhdr
))) {
784 DEBUGP("message is too short.\n");
788 skb_set_transport_header(clone
, fhoff
);
789 hdr
= ipv6_hdr(clone
);
790 fhdr
= (struct frag_hdr
*)skb_transport_header(clone
);
792 if (!(fhdr
->frag_off
& htons(0xFFF9))) {
793 DEBUGP("Invalid fragment offset\n");
794 /* It is not a fragmented frame */
798 if (atomic_read(&nf_ct_frag6_mem
) > nf_ct_frag6_high_thresh
)
799 nf_ct_frag6_evictor();
801 fq
= fq_find(fhdr
->identification
, &hdr
->saddr
, &hdr
->daddr
);
803 DEBUGP("Can't find and can't create new queue\n");
807 spin_lock(&fq
->lock
);
809 if (nf_ct_frag6_queue(fq
, clone
, fhdr
, nhoff
) < 0) {
810 spin_unlock(&fq
->lock
);
811 DEBUGP("Can't insert skb to queue\n");
816 if (fq
->last_in
== (FIRST_IN
|LAST_IN
) && fq
->meat
== fq
->len
) {
817 ret_skb
= nf_ct_frag6_reasm(fq
, dev
);
819 DEBUGP("Can't reassemble fragmented packets\n");
821 spin_unlock(&fq
->lock
);
831 void nf_ct_frag6_output(unsigned int hooknum
, struct sk_buff
*skb
,
832 struct net_device
*in
, struct net_device
*out
,
833 int (*okfn
)(struct sk_buff
*))
835 struct sk_buff
*s
, *s2
;
837 for (s
= NFCT_FRAG6_CB(skb
)->orig
; s
;) {
838 nf_conntrack_put_reasm(s
->nfct_reasm
);
839 nf_conntrack_get_reasm(skb
);
845 NF_HOOK_THRESH(PF_INET6
, hooknum
, s
, in
, out
, okfn
,
846 NF_IP6_PRI_CONNTRACK_DEFRAG
+ 1);
849 nf_conntrack_put_reasm(skb
);
852 int nf_ct_frag6_kfree_frags(struct sk_buff
*skb
)
854 struct sk_buff
*s
, *s2
;
856 for (s
= NFCT_FRAG6_CB(skb
)->orig
; s
; s
= s2
) {
867 int nf_ct_frag6_init(void)
869 nf_ct_frag6_hash_rnd
= (u32
) ((num_physpages
^ (num_physpages
>>7)) ^
870 (jiffies
^ (jiffies
>> 6)));
872 init_timer(&nf_ct_frag6_secret_timer
);
873 nf_ct_frag6_secret_timer
.function
= nf_ct_frag6_secret_rebuild
;
874 nf_ct_frag6_secret_timer
.expires
= jiffies
875 + nf_ct_frag6_secret_interval
;
876 add_timer(&nf_ct_frag6_secret_timer
);
881 void nf_ct_frag6_cleanup(void)
883 del_timer(&nf_ct_frag6_secret_timer
);
884 nf_ct_frag6_low_thresh
= 0;
885 nf_ct_frag6_evictor();