~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ipv6/netfilter/nf_conntrack_reasm.c

Version: ~ [ linux-5.6 ] ~ [ linux-5.5.13 ] ~ [ linux-5.4.28 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.113 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.82 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 static const char nf_frags_cache_name[] = "nf-frags";
 54 
 55 static struct inet_frags nf_frags;
 56 
 57 #ifdef CONFIG_SYSCTL
 58 
 59 static struct ctl_table nf_ct_frag6_sysctl_table[] = {
 60         {
 61                 .procname       = "nf_conntrack_frag6_timeout",
 62                 .data           = &init_net.nf_frag.frags.timeout,
 63                 .maxlen         = sizeof(unsigned int),
 64                 .mode           = 0644,
 65                 .proc_handler   = proc_dointvec_jiffies,
 66         },
 67         {
 68                 .procname       = "nf_conntrack_frag6_low_thresh",
 69                 .data           = &init_net.nf_frag.frags.low_thresh,
 70                 .maxlen         = sizeof(unsigned long),
 71                 .mode           = 0644,
 72                 .proc_handler   = proc_doulongvec_minmax,
 73                 .extra2         = &init_net.nf_frag.frags.high_thresh
 74         },
 75         {
 76                 .procname       = "nf_conntrack_frag6_high_thresh",
 77                 .data           = &init_net.nf_frag.frags.high_thresh,
 78                 .maxlen         = sizeof(unsigned long),
 79                 .mode           = 0644,
 80                 .proc_handler   = proc_doulongvec_minmax,
 81                 .extra1         = &init_net.nf_frag.frags.low_thresh
 82         },
 83         { }
 84 };
 85 
 86 static int nf_ct_frag6_sysctl_register(struct net *net)
 87 {
 88         struct ctl_table *table;
 89         struct ctl_table_header *hdr;
 90 
 91         table = nf_ct_frag6_sysctl_table;
 92         if (!net_eq(net, &init_net)) {
 93                 table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
 94                                 GFP_KERNEL);
 95                 if (table == NULL)
 96                         goto err_alloc;
 97 
 98                 table[0].data = &net->nf_frag.frags.timeout;
 99                 table[1].data = &net->nf_frag.frags.low_thresh;
100                 table[1].extra2 = &net->nf_frag.frags.high_thresh;
101                 table[2].data = &net->nf_frag.frags.high_thresh;
102                 table[2].extra1 = &net->nf_frag.frags.low_thresh;
103                 table[2].extra2 = &init_net.nf_frag.frags.high_thresh;
104         }
105 
106         hdr = register_net_sysctl(net, "net/netfilter", table);
107         if (hdr == NULL)
108                 goto err_reg;
109 
110         net->nf_frag_frags_hdr = hdr;
111         return 0;
112 
113 err_reg:
114         if (!net_eq(net, &init_net))
115                 kfree(table);
116 err_alloc:
117         return -ENOMEM;
118 }
119 
120 static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
121 {
122         struct ctl_table *table;
123 
124         table = net->nf_frag_frags_hdr->ctl_table_arg;
125         unregister_net_sysctl_table(net->nf_frag_frags_hdr);
126         if (!net_eq(net, &init_net))
127                 kfree(table);
128 }
129 
130 #else
131 static int nf_ct_frag6_sysctl_register(struct net *net)
132 {
133         return 0;
134 }
135 static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
136 {
137 }
138 #endif
139 
140 static inline u8 ip6_frag_ecn(const struct ipv6hdr *ipv6h)
141 {
142         return 1 << (ipv6_get_dsfield(ipv6h) & INET_ECN_MASK);
143 }
144 
145 static void nf_ct_frag6_expire(struct timer_list *t)
146 {
147         struct inet_frag_queue *frag = from_timer(frag, t, timer);
148         struct frag_queue *fq;
149         struct net *net;
150 
151         fq = container_of(frag, struct frag_queue, q);
152         net = container_of(fq->q.net, struct net, nf_frag.frags);
153 
154         ip6_expire_frag_queue(net, fq);
155 }
156 
157 /* Creation primitives. */
158 static struct frag_queue *fq_find(struct net *net, __be32 id, u32 user,
159                                   const struct ipv6hdr *hdr, int iif)
160 {
161         struct frag_v6_compare_key key = {
162                 .id = id,
163                 .saddr = hdr->saddr,
164                 .daddr = hdr->daddr,
165                 .user = user,
166                 .iif = iif,
167         };
168         struct inet_frag_queue *q;
169 
170         q = inet_frag_find(&net->nf_frag.frags, &key);
171         if (!q)
172                 return NULL;
173 
174         return container_of(q, struct frag_queue, q);
175 }
176 
177 
178 static int nf_ct_frag6_queue(struct frag_queue *fq, struct sk_buff *skb,
179                              const struct frag_hdr *fhdr, int nhoff)
180 {
181         struct sk_buff *prev, *next;
182         unsigned int payload_len;
183         int offset, end;
184         u8 ecn;
185 
186         if (fq->q.flags & INET_FRAG_COMPLETE) {
187                 pr_debug("Already completed\n");
188                 goto err;
189         }
190 
191         payload_len = ntohs(ipv6_hdr(skb)->payload_len);
192 
193         offset = ntohs(fhdr->frag_off) & ~0x7;
194         end = offset + (payload_len -
195                         ((u8 *)(fhdr + 1) - (u8 *)(ipv6_hdr(skb) + 1)));
196 
197         if ((unsigned int)end > IPV6_MAXPLEN) {
198                 pr_debug("offset is too large.\n");
199                 return -EINVAL;
200         }
201 
202         ecn = ip6_frag_ecn(ipv6_hdr(skb));
203 
204         if (skb->ip_summed == CHECKSUM_COMPLETE) {
205                 const unsigned char *nh = skb_network_header(skb);
206                 skb->csum = csum_sub(skb->csum,
207                                      csum_partial(nh, (u8 *)(fhdr + 1) - nh,
208                                                   0));
209         }
210 
211         /* Is this the final fragment? */
212         if (!(fhdr->frag_off & htons(IP6_MF))) {
213                 /* If we already have some bits beyond end
214                  * or have different end, the segment is corrupted.
215                  */
216                 if (end < fq->q.len ||
217                     ((fq->q.flags & INET_FRAG_LAST_IN) && end != fq->q.len)) {
218                         pr_debug("already received last fragment\n");
219                         goto err;
220                 }
221                 fq->q.flags |= INET_FRAG_LAST_IN;
222                 fq->q.len = end;
223         } else {
224                 /* Check if the fragment is rounded to 8 bytes.
225                  * Required by the RFC.
226                  */
227                 if (end & 0x7) {
228                         /* RFC2460 says always send parameter problem in
229                          * this case. -DaveM
230                          */
231                         pr_debug("end of fragment not rounded to 8 bytes.\n");
232                         inet_frag_kill(&fq->q);
233                         return -EPROTO;
234                 }
235                 if (end > fq->q.len) {
236                         /* Some bits beyond end -> corruption. */
237                         if (fq->q.flags & INET_FRAG_LAST_IN) {
238                                 pr_debug("last packet already reached.\n");
239                                 goto err;
240                         }
241                         fq->q.len = end;
242                 }
243         }
244 
245         if (end == offset)
246                 goto err;
247 
248         /* Point into the IP datagram 'data' part. */
249         if (!pskb_pull(skb, (u8 *) (fhdr + 1) - skb->data)) {
250                 pr_debug("queue: message is too short.\n");
251                 goto err;
252         }
253         if (pskb_trim_rcsum(skb, end - offset)) {
254                 pr_debug("Can't trim\n");
255                 goto err;
256         }
257 
258         /* Find out which fragments are in front and at the back of us
259          * in the chain of fragments so far.  We must know where to put
260          * this fragment, right?
261          */
262         prev = fq->q.fragments_tail;
263         if (!prev || prev->ip_defrag_offset < offset) {
264                 next = NULL;
265                 goto found;
266         }
267         prev = NULL;
268         for (next = fq->q.fragments; next != NULL; next = next->next) {
269                 if (next->ip_defrag_offset >= offset)
270                         break;  /* bingo! */
271                 prev = next;
272         }
273 
274 found:
275         /* RFC5722, Section 4:
276          *                                  When reassembling an IPv6 datagram, if
277          *   one or more its constituent fragments is determined to be an
278          *   overlapping fragment, the entire datagram (and any constituent
279          *   fragments, including those not yet received) MUST be silently
280          *   discarded.
281          */
282 
283         /* Check for overlap with preceding fragment. */
284         if (prev &&
285             (prev->ip_defrag_offset + prev->len) > offset)
286                 goto discard_fq;
287 
288         /* Look for overlap with succeeding segment. */
289         if (next && next->ip_defrag_offset < end)
290                 goto discard_fq;
291 
292         /* Note : skb->ip_defrag_offset and skb->dev share the same location */
293         if (skb->dev)
294                 fq->iif = skb->dev->ifindex;
295         /* Makes sure compiler wont do silly aliasing games */
296         barrier();
297         skb->ip_defrag_offset = offset;
298 
299         /* Insert this fragment in the chain of fragments. */
300         skb->next = next;
301         if (!next)
302                 fq->q.fragments_tail = skb;
303         if (prev)
304                 prev->next = skb;
305         else
306                 fq->q.fragments = skb;
307 
308         fq->q.stamp = skb->tstamp;
309         fq->q.meat += skb->len;
310         fq->ecn |= ecn;
311         if (payload_len > fq->q.max_size)
312                 fq->q.max_size = payload_len;
313         add_frag_mem_limit(fq->q.net, skb->truesize);
314 
315         /* The first fragment.
316          * nhoffset is obtained from the first fragment, of course.
317          */
318         if (offset == 0) {
319                 fq->nhoffset = nhoff;
320                 fq->q.flags |= INET_FRAG_FIRST_IN;
321         }
322 
323         return 0;
324 
325 discard_fq:
326         inet_frag_kill(&fq->q);
327 err:
328         return -EINVAL;
329 }
330 
331 /*
332  *      Check if this packet is complete.
333  *
334  *      It is called with locked fq, and caller must check that
335  *      queue is eligible for reassembly i.e. it is not COMPLETE,
336  *      the last and the first frames arrived and all the bits are here.
337  *
338  *      returns true if *prev skb has been transformed into the reassembled
339  *      skb, false otherwise.
340  */
341 static bool
342 nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *prev,  struct net_device *dev)
343 {
344         struct sk_buff *fp, *head = fq->q.fragments;
345         int    payload_len;
346         u8 ecn;
347 
348         inet_frag_kill(&fq->q);
349 
350         WARN_ON(head == NULL);
351         WARN_ON(head->ip_defrag_offset != 0);
352 
353         ecn = ip_frag_ecn_table[fq->ecn];
354         if (unlikely(ecn == 0xff))
355                 return false;
356 
357         /* Unfragmented part is taken from the first segment. */
358         payload_len = ((head->data - skb_network_header(head)) -
359                        sizeof(struct ipv6hdr) + fq->q.len -
360                        sizeof(struct frag_hdr));
361         if (payload_len > IPV6_MAXPLEN) {
362                 net_dbg_ratelimited("nf_ct_frag6_reasm: payload len = %d\n",
363                                     payload_len);
364                 return false;
365         }
366 
367         /* Head of list must not be cloned. */
368         if (skb_unclone(head, GFP_ATOMIC))
369                 return false;
370 
371         /* If the first fragment is fragmented itself, we split
372          * it to two chunks: the first with data and paged part
373          * and the second, holding only fragments. */
374         if (skb_has_frag_list(head)) {
375                 struct sk_buff *clone;
376                 int i, plen = 0;
377 
378                 clone = alloc_skb(0, GFP_ATOMIC);
379                 if (clone == NULL)
380                         return false;
381 
382                 clone->next = head->next;
383                 head->next = clone;
384                 skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list;
385                 skb_frag_list_init(head);
386                 for (i = 0; i < skb_shinfo(head)->nr_frags; i++)
387                         plen += skb_frag_size(&skb_shinfo(head)->frags[i]);
388                 clone->len = clone->data_len = head->data_len - plen;
389                 head->data_len -= clone->len;
390                 head->len -= clone->len;
391                 clone->csum = 0;
392                 clone->ip_summed = head->ip_summed;
393 
394                 add_frag_mem_limit(fq->q.net, clone->truesize);
395         }
396 
397         /* morph head into last received skb: prev.
398          *
399          * This allows callers of ipv6 conntrack defrag to continue
400          * to use the last skb(frag) passed into the reasm engine.
401          * The last skb frag 'silently' turns into the full reassembled skb.
402          *
403          * Since prev is also part of q->fragments we have to clone it first.
404          */
405         if (head != prev) {
406                 struct sk_buff *iter;
407 
408                 fp = skb_clone(prev, GFP_ATOMIC);
409                 if (!fp)
410                         return false;
411 
412                 fp->next = prev->next;
413 
414                 iter = head;
415                 while (iter) {
416                         if (iter->next == prev) {
417                                 iter->next = fp;
418                                 break;
419                         }
420                         iter = iter->next;
421                 }
422 
423                 skb_morph(prev, head);
424                 prev->next = head->next;
425                 consume_skb(head);
426                 head = prev;
427         }
428 
429         /* We have to remove fragment header from datagram and to relocate
430          * header in order to calculate ICV correctly. */
431         skb_network_header(head)[fq->nhoffset] = skb_transport_header(head)[0];
432         memmove(head->head + sizeof(struct frag_hdr), head->head,
433                 (head->data - head->head) - sizeof(struct frag_hdr));
434         head->mac_header += sizeof(struct frag_hdr);
435         head->network_header += sizeof(struct frag_hdr);
436 
437         skb_shinfo(head)->frag_list = head->next;
438         skb_reset_transport_header(head);
439         skb_push(head, head->data - skb_network_header(head));
440 
441         for (fp = head->next; fp; fp = fp->next) {
442                 head->data_len += fp->len;
443                 head->len += fp->len;
444                 if (head->ip_summed != fp->ip_summed)
445                         head->ip_summed = CHECKSUM_NONE;
446                 else if (head->ip_summed == CHECKSUM_COMPLETE)
447                         head->csum = csum_add(head->csum, fp->csum);
448                 head->truesize += fp->truesize;
449         }
450         sub_frag_mem_limit(fq->q.net, head->truesize);
451 
452         head->ignore_df = 1;
453         head->next = NULL;
454         head->dev = dev;
455         head->tstamp = fq->q.stamp;
456         ipv6_hdr(head)->payload_len = htons(payload_len);
457         ipv6_change_dsfield(ipv6_hdr(head), 0xff, ecn);
458         IP6CB(head)->frag_max_size = sizeof(struct ipv6hdr) + fq->q.max_size;
459 
460         /* Yes, and fold redundant checksum back. 8) */
461         if (head->ip_summed == CHECKSUM_COMPLETE)
462                 head->csum = csum_partial(skb_network_header(head),
463                                           skb_network_header_len(head),
464                                           head->csum);
465 
466         fq->q.fragments = NULL;
467         fq->q.fragments_tail = NULL;
468 
469         return true;
470 }
471 
472 /*
473  * find the header just before Fragment Header.
474  *
475  * if success return 0 and set ...
476  * (*prevhdrp): the value of "Next Header Field" in the header
477  *              just before Fragment Header.
478  * (*prevhoff): the offset of "Next Header Field" in the header
479  *              just before Fragment Header.
480  * (*fhoff)   : the offset of Fragment Header.
481  *
482  * Based on ipv6_skip_hdr() in net/ipv6/exthdr.c
483  *
484  */
485 static int
486 find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff)
487 {
488         u8 nexthdr = ipv6_hdr(skb)->nexthdr;
489         const int netoff = skb_network_offset(skb);
490         u8 prev_nhoff = netoff + offsetof(struct ipv6hdr, nexthdr);
491         int start = netoff + sizeof(struct ipv6hdr);
492         int len = skb->len - start;
493         u8 prevhdr = NEXTHDR_IPV6;
494 
495         while (nexthdr != NEXTHDR_FRAGMENT) {
496                 struct ipv6_opt_hdr hdr;
497                 int hdrlen;
498 
499                 if (!ipv6_ext_hdr(nexthdr)) {
500                         return -1;
501                 }
502                 if (nexthdr == NEXTHDR_NONE) {
503                         pr_debug("next header is none\n");
504                         return -1;
505                 }
506                 if (len < (int)sizeof(struct ipv6_opt_hdr)) {
507                         pr_debug("too short\n");
508                         return -1;
509                 }
510                 if (skb_copy_bits(skb, start, &hdr, sizeof(hdr)))
511                         BUG();
512                 if (nexthdr == NEXTHDR_AUTH)
513                         hdrlen = (hdr.hdrlen+2)<<2;
514                 else
515                         hdrlen = ipv6_optlen(&hdr);
516 
517                 prevhdr = nexthdr;
518                 prev_nhoff = start;
519 
520                 nexthdr = hdr.nexthdr;
521                 len -= hdrlen;
522                 start += hdrlen;
523         }
524 
525         if (len < 0)
526                 return -1;
527 
528         *prevhdrp = prevhdr;
529         *prevhoff = prev_nhoff;
530         *fhoff = start;
531 
532         return 0;
533 }
534 
535 int nf_ct_frag6_gather(struct net *net, struct sk_buff *skb, u32 user)
536 {
537         u16 savethdr = skb->transport_header;
538         struct net_device *dev = skb->dev;
539         int fhoff, nhoff, ret;
540         struct frag_hdr *fhdr;
541         struct frag_queue *fq;
542         struct ipv6hdr *hdr;
543         u8 prevhdr;
544 
545         /* Jumbo payload inhibits frag. header */
546         if (ipv6_hdr(skb)->payload_len == 0) {
547                 pr_debug("payload len = 0\n");
548                 return 0;
549         }
550 
551         if (find_prev_fhdr(skb, &prevhdr, &nhoff, &fhoff) < 0)
552                 return 0;
553 
554         if (!pskb_may_pull(skb, fhoff + sizeof(*fhdr)))
555                 return -ENOMEM;
556 
557         skb_set_transport_header(skb, fhoff);
558         hdr = ipv6_hdr(skb);
559         fhdr = (struct frag_hdr *)skb_transport_header(skb);
560 
561         skb_orphan(skb);
562         fq = fq_find(net, fhdr->identification, user, hdr,
563                      skb->dev ? skb->dev->ifindex : 0);
564         if (fq == NULL) {
565                 pr_debug("Can't find and can't create new queue\n");
566                 return -ENOMEM;
567         }
568 
569         spin_lock_bh(&fq->q.lock);
570 
571         ret = nf_ct_frag6_queue(fq, skb, fhdr, nhoff);
572         if (ret < 0) {
573                 if (ret == -EPROTO) {
574                         skb->transport_header = savethdr;
575                         ret = 0;
576                 }
577                 goto out_unlock;
578         }
579 
580         /* after queue has assumed skb ownership, only 0 or -EINPROGRESS
581          * must be returned.
582          */
583         ret = -EINPROGRESS;
584         if (fq->q.flags == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
585             fq->q.meat == fq->q.len &&
586             nf_ct_frag6_reasm(fq, skb, dev))
587                 ret = 0;
588 
589 out_unlock:
590         spin_unlock_bh(&fq->q.lock);
591         inet_frag_put(&fq->q);
592         return ret;
593 }
594 EXPORT_SYMBOL_GPL(nf_ct_frag6_gather);
595 
596 static int nf_ct_net_init(struct net *net)
597 {
598         int res;
599 
600         net->nf_frag.frags.high_thresh = IPV6_FRAG_HIGH_THRESH;
601         net->nf_frag.frags.low_thresh = IPV6_FRAG_LOW_THRESH;
602         net->nf_frag.frags.timeout = IPV6_FRAG_TIMEOUT;
603         net->nf_frag.frags.f = &nf_frags;
604 
605         res = inet_frags_init_net(&net->nf_frag.frags);
606         if (res < 0)
607                 return res;
608         res = nf_ct_frag6_sysctl_register(net);
609         if (res < 0)
610                 inet_frags_exit_net(&net->nf_frag.frags);
611         return res;
612 }
613 
614 static void nf_ct_net_exit(struct net *net)
615 {
616         nf_ct_frags6_sysctl_unregister(net);
617         inet_frags_exit_net(&net->nf_frag.frags);
618 }
619 
620 static struct pernet_operations nf_ct_net_ops = {
621         .init = nf_ct_net_init,
622         .exit = nf_ct_net_exit,
623 };
624 
625 int nf_ct_frag6_init(void)
626 {
627         int ret = 0;
628 
629         nf_frags.constructor = ip6_frag_init;
630         nf_frags.destructor = NULL;
631         nf_frags.qsize = sizeof(struct frag_queue);
632         nf_frags.frag_expire = nf_ct_frag6_expire;
633         nf_frags.frags_cache_name = nf_frags_cache_name;
634         nf_frags.rhash_params = ip6_rhash_params;
635         ret = inet_frags_init(&nf_frags);
636         if (ret)
637                 goto out;
638         ret = register_pernet_subsys(&nf_ct_net_ops);
639         if (ret)
640                 inet_frags_fini(&nf_frags);
641 
642 out:
643         return ret;
644 }
645 
646 void nf_ct_frag6_cleanup(void)
647 {
648         unregister_pernet_subsys(&nf_ct_net_ops);
649         inet_frags_fini(&nf_frags);
650 }
651 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp