1 // SPDX-License-Identifier: GPL-2.0
3 * INET An implementation of the TCP/IP protocol suite for the LINUX
4 * operating system. INET is implemented using the BSD Socket
5 * interface as the means of communication with the user level.
7 * The IP fragmentation functionality.
9 * Authors: Fred N. van Kempen <waltje@uWalt.NL.Mugnet.ORG>
10 * Alan Cox <alan@lxorguk.ukuu.org.uk>
13 * Alan Cox : Split from ip.c , see ip_input.c for history.
14 * David S. Miller : Begin massive cleanup...
15 * Andi Kleen : Add sysctls.
16 * xxxx : Overlapfrag bug.
17 * Ultima : ip_expire() kernel panic.
18 * Bill Hawes : Frag accounting and evictor fixes.
19 * John McDonald : 0 length frag bug.
20 * Alexey Kuznetsov: SMP races, threading, cleanup.
21 * Patrick McHardy : LRU queue of frag heads for evictor.
24 #define pr_fmt(fmt) "IPv4: " fmt
26 #include <linux/compiler.h>
27 #include <linux/module.h>
28 #include <linux/types.h>
30 #include <linux/jiffies.h>
31 #include <linux/skbuff.h>
32 #include <linux/list.h>
34 #include <linux/icmp.h>
35 #include <linux/netdevice.h>
36 #include <linux/jhash.h>
37 #include <linux/random.h>
38 #include <linux/slab.h>
39 #include <net/route.h>
44 #include <net/checksum.h>
45 #include <net/inetpeer.h>
46 #include <net/inet_frag.h>
47 #include <linux/tcp.h>
48 #include <linux/udp.h>
49 #include <linux/inet.h>
50 #include <linux/netfilter_ipv4.h>
51 #include <net/inet_ecn.h>
52 #include <net/l3mdev.h>
54 /* NOTE. Logic of IP defragmentation is parallel to corresponding IPv6
55 * code now. If you change something here, _PLEASE_ update ipv6/reassembly.c
56 * as well. Or notify me, at least. --ANK
58 static const char ip_frag_cache_name
[] = "ip4-frags";
62 struct inet_skb_parm h
;
66 #define FRAG_CB(skb) ((struct ipfrag_skb_cb *)((skb)->cb))
68 /* Describe an entry in the "incomplete datagrams" queue. */
70 struct inet_frag_queue q
;
72 u8 ecn
; /* RFC3168 support */
73 u16 max_df_size
; /* largest frag with DF set seen */
76 struct inet_peer
*peer
;
79 static u8
ip4_frag_ecn(u8 tos
)
81 return 1 << (tos
& INET_ECN_MASK
);
84 static struct inet_frags ip4_frags
;
86 static int ip_frag_reasm(struct ipq
*qp
, struct sk_buff
*prev
,
87 struct net_device
*dev
);
90 static void ip4_frag_init(struct inet_frag_queue
*q
, const void *a
)
92 struct ipq
*qp
= container_of(q
, struct ipq
, q
);
93 struct netns_ipv4
*ipv4
= container_of(q
->net
, struct netns_ipv4
,
95 struct net
*net
= container_of(ipv4
, struct net
, ipv4
);
97 const struct frag_v4_compare_key
*key
= a
;
101 qp
->peer
= q
->net
->max_dist
?
102 inet_getpeer_v4(net
->ipv4
.peers
, key
->saddr
, key
->vif
, 1) :
106 static void ip4_frag_free(struct inet_frag_queue
*q
)
110 qp
= container_of(q
, struct ipq
, q
);
112 inet_putpeer(qp
->peer
);
116 /* Destruction primitives. */
118 static void ipq_put(struct ipq
*ipq
)
120 inet_frag_put(&ipq
->q
);
123 /* Kill ipq entry. It is not destroyed immediately,
124 * because caller (and someone more) holds reference count.
126 static void ipq_kill(struct ipq
*ipq
)
128 inet_frag_kill(&ipq
->q
);
131 static bool frag_expire_skip_icmp(u32 user
)
133 return user
== IP_DEFRAG_AF_PACKET
||
134 ip_defrag_user_in_between(user
, IP_DEFRAG_CONNTRACK_IN
,
135 __IP_DEFRAG_CONNTRACK_IN_END
) ||
136 ip_defrag_user_in_between(user
, IP_DEFRAG_CONNTRACK_BRIDGE_IN
,
137 __IP_DEFRAG_CONNTRACK_BRIDGE_IN
);
141 * Oops, a fragment queue timed out. Kill it and send an ICMP reply.
143 static void ip_expire(struct timer_list
*t
)
145 struct inet_frag_queue
*frag
= from_timer(frag
, t
, timer
);
146 struct sk_buff
*clone
, *head
;
147 const struct iphdr
*iph
;
152 qp
= container_of(frag
, struct ipq
, q
);
153 net
= container_of(qp
->q
.net
, struct net
, ipv4
.frags
);
156 spin_lock(&qp
->q
.lock
);
158 if (qp
->q
.flags
& INET_FRAG_COMPLETE
)
162 __IP_INC_STATS(net
, IPSTATS_MIB_REASMFAILS
);
164 head
= qp
->q
.fragments
;
166 __IP_INC_STATS(net
, IPSTATS_MIB_REASMTIMEOUT
);
168 if (!(qp
->q
.flags
& INET_FRAG_FIRST_IN
) || !head
)
171 head
->dev
= dev_get_by_index_rcu(net
, qp
->iif
);
176 /* skb has no dst, perform route lookup again */
178 err
= ip_route_input_noref(head
, iph
->daddr
, iph
->saddr
,
179 iph
->tos
, head
->dev
);
183 /* Only an end host needs to send an ICMP
184 * "Fragment Reassembly Timeout" message, per RFC792.
186 if (frag_expire_skip_icmp(qp
->q
.key
.v4
.user
) &&
187 (skb_rtable(head
)->rt_type
!= RTN_LOCAL
))
190 clone
= skb_clone(head
, GFP_ATOMIC
);
192 /* Send an ICMP "Fragment Reassembly Timeout" message. */
194 spin_unlock(&qp
->q
.lock
);
195 icmp_send(clone
, ICMP_TIME_EXCEEDED
,
196 ICMP_EXC_FRAGTIME
, 0);
201 spin_unlock(&qp
->q
.lock
);
207 /* Find the correct entry in the "incomplete datagrams" queue for
208 * this IP datagram, and create new one, if nothing is found.
210 static struct ipq
*ip_find(struct net
*net
, struct iphdr
*iph
,
213 struct frag_v4_compare_key key
= {
219 .protocol
= iph
->protocol
,
221 struct inet_frag_queue
*q
;
223 q
= inet_frag_find(&net
->ipv4
.frags
, &key
);
224 if (IS_ERR_OR_NULL(q
)) {
225 inet_frag_maybe_warn_overflow(q
, pr_fmt());
228 return container_of(q
, struct ipq
, q
);
231 /* Is the fragment too far ahead to be part of ipq? */
232 static int ip_frag_too_far(struct ipq
*qp
)
234 struct inet_peer
*peer
= qp
->peer
;
235 unsigned int max
= qp
->q
.net
->max_dist
;
236 unsigned int start
, end
;
244 end
= atomic_inc_return(&peer
->rid
);
247 rc
= qp
->q
.fragments
&& (end
- start
) > max
;
252 net
= container_of(qp
->q
.net
, struct net
, ipv4
.frags
);
253 __IP_INC_STATS(net
, IPSTATS_MIB_REASMFAILS
);
259 static int ip_frag_reinit(struct ipq
*qp
)
262 unsigned int sum_truesize
= 0;
264 if (!mod_timer(&qp
->q
.timer
, jiffies
+ qp
->q
.net
->timeout
)) {
265 refcount_inc(&qp
->q
.refcnt
);
269 fp
= qp
->q
.fragments
;
271 struct sk_buff
*xp
= fp
->next
;
273 sum_truesize
+= fp
->truesize
;
277 sub_frag_mem_limit(qp
->q
.net
, sum_truesize
);
282 qp
->q
.fragments
= NULL
;
283 qp
->q
.fragments_tail
= NULL
;
290 /* Add new segment to existing queue. */
291 static int ip_frag_queue(struct ipq
*qp
, struct sk_buff
*skb
)
293 struct sk_buff
*prev
, *next
;
294 struct net_device
*dev
;
295 unsigned int fragsize
;
301 if (qp
->q
.flags
& INET_FRAG_COMPLETE
)
304 if (!(IPCB(skb
)->flags
& IPSKB_FRAG_COMPLETE
) &&
305 unlikely(ip_frag_too_far(qp
)) &&
306 unlikely(err
= ip_frag_reinit(qp
))) {
311 ecn
= ip4_frag_ecn(ip_hdr(skb
)->tos
);
312 offset
= ntohs(ip_hdr(skb
)->frag_off
);
313 flags
= offset
& ~IP_OFFSET
;
315 offset
<<= 3; /* offset is in 8-byte chunks */
316 ihl
= ip_hdrlen(skb
);
318 /* Determine the position of this fragment. */
319 end
= offset
+ skb
->len
- skb_network_offset(skb
) - ihl
;
322 /* Is this the final fragment? */
323 if ((flags
& IP_MF
) == 0) {
324 /* If we already have some bits beyond end
325 * or have different end, the segment is corrupted.
327 if (end
< qp
->q
.len
||
328 ((qp
->q
.flags
& INET_FRAG_LAST_IN
) && end
!= qp
->q
.len
))
330 qp
->q
.flags
|= INET_FRAG_LAST_IN
;
335 if (skb
->ip_summed
!= CHECKSUM_UNNECESSARY
)
336 skb
->ip_summed
= CHECKSUM_NONE
;
338 if (end
> qp
->q
.len
) {
339 /* Some bits beyond end -> corruption. */
340 if (qp
->q
.flags
& INET_FRAG_LAST_IN
)
349 if (!pskb_pull(skb
, skb_network_offset(skb
) + ihl
))
352 err
= pskb_trim_rcsum(skb
, end
- offset
);
356 /* Find out which fragments are in front and at the back of us
357 * in the chain of fragments so far. We must know where to put
358 * this fragment, right?
360 prev
= qp
->q
.fragments_tail
;
361 if (!prev
|| FRAG_CB(prev
)->offset
< offset
) {
366 for (next
= qp
->q
.fragments
; next
!= NULL
; next
= next
->next
) {
367 if (FRAG_CB(next
)->offset
>= offset
)
373 /* We found where to put this one. Check for overlap with
374 * preceding fragment, and, if needed, align things so that
375 * any overlaps are eliminated.
378 int i
= (FRAG_CB(prev
)->offset
+ prev
->len
) - offset
;
386 if (!pskb_pull(skb
, i
))
388 if (skb
->ip_summed
!= CHECKSUM_UNNECESSARY
)
389 skb
->ip_summed
= CHECKSUM_NONE
;
395 while (next
&& FRAG_CB(next
)->offset
< end
) {
396 int i
= end
- FRAG_CB(next
)->offset
; /* overlap is 'i' bytes */
399 int delta
= -next
->truesize
;
401 /* Eat head of the next overlapped fragment
402 * and leave the loop. The next ones cannot overlap.
404 if (!pskb_pull(next
, i
))
406 delta
+= next
->truesize
;
408 add_frag_mem_limit(qp
->q
.net
, delta
);
409 FRAG_CB(next
)->offset
+= i
;
411 if (next
->ip_summed
!= CHECKSUM_UNNECESSARY
)
412 next
->ip_summed
= CHECKSUM_NONE
;
415 struct sk_buff
*free_it
= next
;
417 /* Old fragment is completely overridden with
425 qp
->q
.fragments
= next
;
427 qp
->q
.meat
-= free_it
->len
;
428 sub_frag_mem_limit(qp
->q
.net
, free_it
->truesize
);
433 FRAG_CB(skb
)->offset
= offset
;
435 /* Insert this fragment in the chain of fragments. */
438 qp
->q
.fragments_tail
= skb
;
442 qp
->q
.fragments
= skb
;
446 qp
->iif
= dev
->ifindex
;
449 qp
->q
.stamp
= skb
->tstamp
;
450 qp
->q
.meat
+= skb
->len
;
452 add_frag_mem_limit(qp
->q
.net
, skb
->truesize
);
454 qp
->q
.flags
|= INET_FRAG_FIRST_IN
;
456 fragsize
= skb
->len
+ ihl
;
458 if (fragsize
> qp
->q
.max_size
)
459 qp
->q
.max_size
= fragsize
;
461 if (ip_hdr(skb
)->frag_off
& htons(IP_DF
) &&
462 fragsize
> qp
->max_df_size
)
463 qp
->max_df_size
= fragsize
;
465 if (qp
->q
.flags
== (INET_FRAG_FIRST_IN
| INET_FRAG_LAST_IN
) &&
466 qp
->q
.meat
== qp
->q
.len
) {
467 unsigned long orefdst
= skb
->_skb_refdst
;
469 skb
->_skb_refdst
= 0UL;
470 err
= ip_frag_reasm(qp
, prev
, dev
);
471 skb
->_skb_refdst
= orefdst
;
484 /* Build a new IP datagram from all its fragments. */
486 static int ip_frag_reasm(struct ipq
*qp
, struct sk_buff
*prev
,
487 struct net_device
*dev
)
489 struct net
*net
= container_of(qp
->q
.net
, struct net
, ipv4
.frags
);
491 struct sk_buff
*fp
, *head
= qp
->q
.fragments
;
499 ecn
= ip_frag_ecn_table
[qp
->ecn
];
500 if (unlikely(ecn
== 0xff)) {
504 /* Make the one we just received the head. */
507 fp
= skb_clone(head
, GFP_ATOMIC
);
511 fp
->next
= head
->next
;
513 qp
->q
.fragments_tail
= fp
;
516 skb_morph(head
, qp
->q
.fragments
);
517 head
->next
= qp
->q
.fragments
->next
;
519 consume_skb(qp
->q
.fragments
);
520 qp
->q
.fragments
= head
;
524 WARN_ON(FRAG_CB(head
)->offset
!= 0);
526 /* Allocate a new buffer for the datagram. */
527 ihlen
= ip_hdrlen(head
);
528 len
= ihlen
+ qp
->q
.len
;
534 /* Head of list must not be cloned. */
535 if (skb_unclone(head
, GFP_ATOMIC
))
538 /* If the first fragment is fragmented itself, we split
539 * it to two chunks: the first with data and paged part
540 * and the second, holding only fragments. */
541 if (skb_has_frag_list(head
)) {
542 struct sk_buff
*clone
;
545 clone
= alloc_skb(0, GFP_ATOMIC
);
548 clone
->next
= head
->next
;
550 skb_shinfo(clone
)->frag_list
= skb_shinfo(head
)->frag_list
;
551 skb_frag_list_init(head
);
552 for (i
= 0; i
< skb_shinfo(head
)->nr_frags
; i
++)
553 plen
+= skb_frag_size(&skb_shinfo(head
)->frags
[i
]);
554 clone
->len
= clone
->data_len
= head
->data_len
- plen
;
555 head
->data_len
-= clone
->len
;
556 head
->len
-= clone
->len
;
558 clone
->ip_summed
= head
->ip_summed
;
559 add_frag_mem_limit(qp
->q
.net
, clone
->truesize
);
562 skb_shinfo(head
)->frag_list
= head
->next
;
563 skb_push(head
, head
->data
- skb_network_header(head
));
565 for (fp
=head
->next
; fp
; fp
= fp
->next
) {
566 head
->data_len
+= fp
->len
;
567 head
->len
+= fp
->len
;
568 if (head
->ip_summed
!= fp
->ip_summed
)
569 head
->ip_summed
= CHECKSUM_NONE
;
570 else if (head
->ip_summed
== CHECKSUM_COMPLETE
)
571 head
->csum
= csum_add(head
->csum
, fp
->csum
);
572 head
->truesize
+= fp
->truesize
;
574 sub_frag_mem_limit(qp
->q
.net
, head
->truesize
);
578 head
->tstamp
= qp
->q
.stamp
;
579 IPCB(head
)->frag_max_size
= max(qp
->max_df_size
, qp
->q
.max_size
);
582 iph
->tot_len
= htons(len
);
585 /* When we set IP_DF on a refragmented skb we must also force a
586 * call to ip_fragment to avoid forwarding a DF-skb of size s while
587 * original sender only sent fragments of size f (where f < s).
589 * We only set DF/IPSKB_FRAG_PMTU if such DF fragment was the largest
590 * frag seen to avoid sending tiny DF-fragments in case skb was built
591 * from one very small df-fragment and one large non-df frag.
593 if (qp
->max_df_size
== qp
->q
.max_size
) {
594 IPCB(head
)->flags
|= IPSKB_FRAG_PMTU
;
595 iph
->frag_off
= htons(IP_DF
);
602 __IP_INC_STATS(net
, IPSTATS_MIB_REASMOKS
);
603 qp
->q
.fragments
= NULL
;
604 qp
->q
.fragments_tail
= NULL
;
608 net_dbg_ratelimited("queue_glue: no memory for gluing queue %p\n", qp
);
612 net_info_ratelimited("Oversized IP packet from %pI4\n", &qp
->q
.key
.v4
.saddr
);
614 __IP_INC_STATS(net
, IPSTATS_MIB_REASMFAILS
);
618 /* Process an incoming IP datagram fragment. */
619 int ip_defrag(struct net
*net
, struct sk_buff
*skb
, u32 user
)
621 struct net_device
*dev
= skb
->dev
? : skb_dst(skb
)->dev
;
622 int vif
= l3mdev_master_ifindex_rcu(dev
);
625 __IP_INC_STATS(net
, IPSTATS_MIB_REASMREQDS
);
628 /* Lookup (or create) queue header */
629 qp
= ip_find(net
, ip_hdr(skb
), user
, vif
);
633 spin_lock(&qp
->q
.lock
);
635 ret
= ip_frag_queue(qp
, skb
);
637 spin_unlock(&qp
->q
.lock
);
642 __IP_INC_STATS(net
, IPSTATS_MIB_REASMFAILS
);
646 EXPORT_SYMBOL(ip_defrag
);
648 struct sk_buff
*ip_check_defrag(struct net
*net
, struct sk_buff
*skb
, u32 user
)
654 if (skb
->protocol
!= htons(ETH_P_IP
))
657 netoff
= skb_network_offset(skb
);
659 if (skb_copy_bits(skb
, netoff
, &iph
, sizeof(iph
)) < 0)
662 if (iph
.ihl
< 5 || iph
.version
!= 4)
665 len
= ntohs(iph
.tot_len
);
666 if (skb
->len
< netoff
+ len
|| len
< (iph
.ihl
* 4))
669 if (ip_is_fragment(&iph
)) {
670 skb
= skb_share_check(skb
, GFP_ATOMIC
);
672 if (!pskb_may_pull(skb
, netoff
+ iph
.ihl
* 4))
674 if (pskb_trim_rcsum(skb
, netoff
+ len
))
676 memset(IPCB(skb
), 0, sizeof(struct inet_skb_parm
));
677 if (ip_defrag(net
, skb
, user
))
684 EXPORT_SYMBOL(ip_check_defrag
);
689 static struct ctl_table ip4_frags_ns_ctl_table
[] = {
691 .procname
= "ipfrag_high_thresh",
692 .data
= &init_net
.ipv4
.frags
.high_thresh
,
693 .maxlen
= sizeof(int),
695 .proc_handler
= proc_dointvec_minmax
,
696 .extra1
= &init_net
.ipv4
.frags
.low_thresh
699 .procname
= "ipfrag_low_thresh",
700 .data
= &init_net
.ipv4
.frags
.low_thresh
,
701 .maxlen
= sizeof(int),
703 .proc_handler
= proc_dointvec_minmax
,
705 .extra2
= &init_net
.ipv4
.frags
.high_thresh
708 .procname
= "ipfrag_time",
709 .data
= &init_net
.ipv4
.frags
.timeout
,
710 .maxlen
= sizeof(int),
712 .proc_handler
= proc_dointvec_jiffies
,
715 .procname
= "ipfrag_max_dist",
716 .data
= &init_net
.ipv4
.frags
.max_dist
,
717 .maxlen
= sizeof(int),
719 .proc_handler
= proc_dointvec_minmax
,
725 /* secret interval has been deprecated */
726 static int ip4_frags_secret_interval_unused
;
727 static struct ctl_table ip4_frags_ctl_table
[] = {
729 .procname
= "ipfrag_secret_interval",
730 .data
= &ip4_frags_secret_interval_unused
,
731 .maxlen
= sizeof(int),
733 .proc_handler
= proc_dointvec_jiffies
,
738 static int __net_init
ip4_frags_ns_ctl_register(struct net
*net
)
740 struct ctl_table
*table
;
741 struct ctl_table_header
*hdr
;
743 table
= ip4_frags_ns_ctl_table
;
744 if (!net_eq(net
, &init_net
)) {
745 table
= kmemdup(table
, sizeof(ip4_frags_ns_ctl_table
), GFP_KERNEL
);
749 table
[0].data
= &net
->ipv4
.frags
.high_thresh
;
750 table
[0].extra1
= &net
->ipv4
.frags
.low_thresh
;
751 table
[0].extra2
= &init_net
.ipv4
.frags
.high_thresh
;
752 table
[1].data
= &net
->ipv4
.frags
.low_thresh
;
753 table
[1].extra2
= &net
->ipv4
.frags
.high_thresh
;
754 table
[2].data
= &net
->ipv4
.frags
.timeout
;
755 table
[3].data
= &net
->ipv4
.frags
.max_dist
;
758 hdr
= register_net_sysctl(net
, "net/ipv4", table
);
762 net
->ipv4
.frags_hdr
= hdr
;
766 if (!net_eq(net
, &init_net
))
772 static void __net_exit
ip4_frags_ns_ctl_unregister(struct net
*net
)
774 struct ctl_table
*table
;
776 table
= net
->ipv4
.frags_hdr
->ctl_table_arg
;
777 unregister_net_sysctl_table(net
->ipv4
.frags_hdr
);
781 static void __init
ip4_frags_ctl_register(void)
783 register_net_sysctl(&init_net
, "net/ipv4", ip4_frags_ctl_table
);
786 static int ip4_frags_ns_ctl_register(struct net
*net
)
791 static void ip4_frags_ns_ctl_unregister(struct net
*net
)
795 static void __init
ip4_frags_ctl_register(void)
800 static int __net_init
ipv4_frags_init_net(struct net
*net
)
805 * Fragment cache limits. We will commit 256K at one time. Should we
806 * cross that limit we will prune down to 192K. This should cope with
807 * even the most extreme cases without allowing an attacker to
808 * measurably harm machine performance.
810 net
->ipv4
.frags
.high_thresh
= 256 * 1024;
811 net
->ipv4
.frags
.low_thresh
= 192 * 1024;
813 * Important NOTE! Fragment queue must be destroyed before MSL expires.
814 * RFC791 is wrong proposing to prolongate timer each fragment arrival
817 net
->ipv4
.frags
.timeout
= IP_FRAG_TIME
;
819 net
->ipv4
.frags
.max_dist
= 64;
820 net
->ipv4
.frags
.f
= &ip4_frags
;
822 res
= inet_frags_init_net(&net
->ipv4
.frags
);
825 res
= ip4_frags_ns_ctl_register(net
);
827 inet_frags_exit_net(&net
->ipv4
.frags
);
831 static void __net_exit
ipv4_frags_exit_net(struct net
*net
)
833 ip4_frags_ns_ctl_unregister(net
);
834 inet_frags_exit_net(&net
->ipv4
.frags
);
837 static struct pernet_operations ip4_frags_ops
= {
838 .init
= ipv4_frags_init_net
,
839 .exit
= ipv4_frags_exit_net
,
843 static u32
ip4_key_hashfn(const void *data
, u32 len
, u32 seed
)
846 sizeof(struct frag_v4_compare_key
) / sizeof(u32
), seed
);
849 static u32
ip4_obj_hashfn(const void *data
, u32 len
, u32 seed
)
851 const struct inet_frag_queue
*fq
= data
;
853 return jhash2((const u32
*)&fq
->key
.v4
,
854 sizeof(struct frag_v4_compare_key
) / sizeof(u32
), seed
);
857 static int ip4_obj_cmpfn(struct rhashtable_compare_arg
*arg
, const void *ptr
)
859 const struct frag_v4_compare_key
*key
= arg
->key
;
860 const struct inet_frag_queue
*fq
= ptr
;
862 return !!memcmp(&fq
->key
, key
, sizeof(*key
));
865 static const struct rhashtable_params ip4_rhash_params
= {
866 .head_offset
= offsetof(struct inet_frag_queue
, node
),
867 .key_offset
= offsetof(struct inet_frag_queue
, key
),
868 .key_len
= sizeof(struct frag_v4_compare_key
),
869 .hashfn
= ip4_key_hashfn
,
870 .obj_hashfn
= ip4_obj_hashfn
,
871 .obj_cmpfn
= ip4_obj_cmpfn
,
872 .automatic_shrinking
= true,
875 void __init
ipfrag_init(void)
877 ip4_frags
.constructor
= ip4_frag_init
;
878 ip4_frags
.destructor
= ip4_frag_free
;
879 ip4_frags
.qsize
= sizeof(struct ipq
);
880 ip4_frags
.frag_expire
= ip_expire
;
881 ip4_frags
.frags_cache_name
= ip_frag_cache_name
;
882 ip4_frags
.rhash_params
= ip4_rhash_params
;
883 if (inet_frags_init(&ip4_frags
))
884 panic("IP: failed to allocate ip4_frags cache\n");
885 ip4_frags_ctl_register();
886 register_pernet_subsys(&ip4_frags_ops
);