ip_fragment.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. * INET An implementation of the TCP/IP protocol suite for the LINUX
  3. * operating system. INET is implemented using the BSD Socket
  4. * interface as the means of communication with the user level.
  5. *
  6. * The IP fragmentation functionality.
  7. *
  8. * Version: $Id: ip_fragment.c,v 1.59 2002/01/12 07:54:56 davem Exp $
  9. *
  10. * Authors: Fred N. van Kempen <waltje@uWalt.NL.Mugnet.ORG>
  11. * Alan Cox <Alan.Cox@linux.org>
  12. *
  13. * Fixes:
  14. * Alan Cox : Split from ip.c , see ip_input.c for history.
  15. * David S. Miller : Begin massive cleanup...
  16. * Andi Kleen : Add sysctls.
  17. * xxxx : Overlapfrag bug.
  18. * Ultima : ip_expire() kernel panic.
  19. * Bill Hawes : Frag accounting and evictor fixes.
  20. * John McDonald : 0 length frag bug.
  21. * Alexey Kuznetsov: SMP races, threading, cleanup.
  22. * Patrick McHardy : LRU queue of frag heads for evictor.
  23. */
  24. #include <linux/compiler.h>
  25. #include <linux/module.h>
  26. #include <linux/types.h>
  27. #include <linux/mm.h>
  28. #include <linux/jiffies.h>
  29. #include <linux/skbuff.h>
  30. #include <linux/list.h>
  31. #include <linux/ip.h>
  32. #include <linux/icmp.h>
  33. #include <linux/netdevice.h>
  34. #include <linux/jhash.h>
  35. #include <linux/random.h>
  36. #include <net/sock.h>
  37. #include <net/ip.h>
  38. #include <net/icmp.h>
  39. #include <net/checksum.h>
  40. #include <net/inetpeer.h>
  41. #include <net/inet_frag.h>
  42. #include <linux/tcp.h>
  43. #include <linux/udp.h>
  44. #include <linux/inet.h>
  45. #include <linux/netfilter_ipv4.h>
  46. /* NOTE. Logic of IP defragmentation is parallel to corresponding IPv6
  47. * code now. If you change something here, _PLEASE_ update ipv6/reassembly.c
  48. * as well. Or notify me, at least. --ANK
  49. */
  50. int sysctl_ipfrag_max_dist __read_mostly = 64;
  51. struct ipfrag_skb_cb
  52. {
  53. struct inet_skb_parm h;
  54. int offset;
  55. };
  56. #define FRAG_CB(skb) ((struct ipfrag_skb_cb*)((skb)->cb))
  57. /* Describe an entry in the "incomplete datagrams" queue. */
  58. struct ipq {
  59. struct inet_frag_queue q;
  60. u32 user;
  61. __be32 saddr;
  62. __be32 daddr;
  63. __be16 id;
  64. u8 protocol;
  65. int iif;
  66. unsigned int rid;
  67. struct inet_peer *peer;
  68. };
  69. struct inet_frags_ctl ip4_frags_ctl __read_mostly = {
  70. /*
  71. * Fragment cache limits. We will commit 256K at one time. Should we
  72. * cross that limit we will prune down to 192K. This should cope with
  73. * even the most extreme cases without allowing an attacker to
  74. * measurably harm machine performance.
  75. */
  76. .high_thresh = 256 * 1024,
  77. .low_thresh = 192 * 1024,
  78. /*
  79. * Important NOTE! Fragment queue must be destroyed before MSL expires.
  80. * RFC791 is wrong proposing to prolongate timer each fragment arrival
  81. * by TTL.
  82. */
  83. .timeout = IP_FRAG_TIME,
  84. .secret_interval = 10 * 60 * HZ,
  85. };
  86. static struct inet_frags ip4_frags;
  87. int ip_frag_nqueues(void)
  88. {
  89. return ip4_frags.nqueues;
  90. }
  91. int ip_frag_mem(void)
  92. {
  93. return atomic_read(&ip4_frags.mem);
  94. }
  95. static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
  96. struct net_device *dev);
  97. static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
  98. {
  99. return jhash_3words((__force u32)id << 16 | prot,
  100. (__force u32)saddr, (__force u32)daddr,
  101. ip4_frags.rnd) & (INETFRAGS_HASHSZ - 1);
  102. }
  103. static unsigned int ip4_hashfn(struct inet_frag_queue *q)
  104. {
  105. struct ipq *ipq;
  106. ipq = container_of(q, struct ipq, q);
  107. return ipqhashfn(ipq->id, ipq->saddr, ipq->daddr, ipq->protocol);
  108. }
  109. /* Memory Tracking Functions. */
  110. static __inline__ void frag_kfree_skb(struct sk_buff *skb, int *work)
  111. {
  112. if (work)
  113. *work -= skb->truesize;
  114. atomic_sub(skb->truesize, &ip4_frags.mem);
  115. kfree_skb(skb);
  116. }
  117. static __inline__ void ip4_frag_free(struct inet_frag_queue *q)
  118. {
  119. struct ipq *qp;
  120. qp = container_of(q, struct ipq, q);
  121. if (qp->peer)
  122. inet_putpeer(qp->peer);
  123. kfree(qp);
  124. }
  125. static __inline__ struct ipq *frag_alloc_queue(void)
  126. {
  127. struct ipq *qp = kzalloc(sizeof(struct ipq), GFP_ATOMIC);
  128. if (!qp)
  129. return NULL;
  130. atomic_add(sizeof(struct ipq), &ip4_frags.mem);
  131. return qp;
  132. }
  133. /* Destruction primitives. */
  134. static __inline__ void ipq_put(struct ipq *ipq)
  135. {
  136. inet_frag_put(&ipq->q, &ip4_frags);
  137. }
  138. /* Kill ipq entry. It is not destroyed immediately,
  139. * because caller (and someone more) holds reference count.
  140. */
  141. static void ipq_kill(struct ipq *ipq)
  142. {
  143. inet_frag_kill(&ipq->q, &ip4_frags);
  144. }
  145. /* Memory limiting on fragments. Evictor trashes the oldest
  146. * fragment queue until we are back under the threshold.
  147. */
  148. static void ip_evictor(void)
  149. {
  150. int evicted;
  151. evicted = inet_frag_evictor(&ip4_frags);
  152. if (evicted)
  153. IP_ADD_STATS_BH(IPSTATS_MIB_REASMFAILS, evicted);
  154. }
  155. /*
  156. * Oops, a fragment queue timed out. Kill it and send an ICMP reply.
  157. */
  158. static void ip_expire(unsigned long arg)
  159. {
  160. struct ipq *qp = (struct ipq *) arg;
  161. spin_lock(&qp->q.lock);
  162. if (qp->q.last_in & COMPLETE)
  163. goto out;
  164. ipq_kill(qp);
  165. IP_INC_STATS_BH(IPSTATS_MIB_REASMTIMEOUT);
  166. IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
  167. if ((qp->q.last_in&FIRST_IN) && qp->q.fragments != NULL) {
  168. struct sk_buff *head = qp->q.fragments;
  169. /* Send an ICMP "Fragment Reassembly Timeout" message. */
  170. if ((head->dev = dev_get_by_index(&init_net, qp->iif)) != NULL) {
  171. icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0);
  172. dev_put(head->dev);
  173. }
  174. }
  175. out:
  176. spin_unlock(&qp->q.lock);
  177. ipq_put(qp);
  178. }
  179. /* Creation primitives. */
  180. static struct ipq *ip_frag_intern(struct ipq *qp_in)
  181. {
  182. struct ipq *qp;
  183. #ifdef CONFIG_SMP
  184. struct hlist_node *n;
  185. #endif
  186. unsigned int hash;
  187. write_lock(&ip4_frags.lock);
  188. hash = ipqhashfn(qp_in->id, qp_in->saddr, qp_in->daddr,
  189. qp_in->protocol);
  190. #ifdef CONFIG_SMP
  191. /* With SMP race we have to recheck hash table, because
  192. * such entry could be created on other cpu, while we
  193. * promoted read lock to write lock.
  194. */
  195. hlist_for_each_entry(qp, n, &ip4_frags.hash[hash], q.list) {
  196. if (qp->id == qp_in->id &&
  197. qp->saddr == qp_in->saddr &&
  198. qp->daddr == qp_in->daddr &&
  199. qp->protocol == qp_in->protocol &&
  200. qp->user == qp_in->user) {
  201. atomic_inc(&qp->q.refcnt);
  202. write_unlock(&ip4_frags.lock);
  203. qp_in->q.last_in |= COMPLETE;
  204. ipq_put(qp_in);
  205. return qp;
  206. }
  207. }
  208. #endif
  209. qp = qp_in;
  210. if (!mod_timer(&qp->q.timer, jiffies + ip4_frags_ctl.timeout))
  211. atomic_inc(&qp->q.refcnt);
  212. atomic_inc(&qp->q.refcnt);
  213. hlist_add_head(&qp->q.list, &ip4_frags.hash[hash]);
  214. INIT_LIST_HEAD(&qp->q.lru_list);
  215. list_add_tail(&qp->q.lru_list, &ip4_frags.lru_list);
  216. ip4_frags.nqueues++;
  217. write_unlock(&ip4_frags.lock);
  218. return qp;
  219. }
  220. /* Add an entry to the 'ipq' queue for a newly received IP datagram. */
  221. static struct ipq *ip_frag_create(struct iphdr *iph, u32 user)
  222. {
  223. struct ipq *qp;
  224. if ((qp = frag_alloc_queue()) == NULL)
  225. goto out_nomem;
  226. qp->protocol = iph->protocol;
  227. qp->id = iph->id;
  228. qp->saddr = iph->saddr;
  229. qp->daddr = iph->daddr;
  230. qp->user = user;
  231. qp->peer = sysctl_ipfrag_max_dist ? inet_getpeer(iph->saddr, 1) : NULL;
  232. /* Initialize a timer for this entry. */
  233. init_timer(&qp->q.timer);
  234. qp->q.timer.data = (unsigned long) qp; /* pointer to queue */
  235. qp->q.timer.function = ip_expire; /* expire function */
  236. spin_lock_init(&qp->q.lock);
  237. atomic_set(&qp->q.refcnt, 1);
  238. return ip_frag_intern(qp);
  239. out_nomem:
  240. LIMIT_NETDEBUG(KERN_ERR "ip_frag_create: no memory left !\n");
  241. return NULL;
  242. }
  243. /* Find the correct entry in the "incomplete datagrams" queue for
  244. * this IP datagram, and create new one, if nothing is found.
  245. */
  246. static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
  247. {
  248. __be16 id = iph->id;
  249. __be32 saddr = iph->saddr;
  250. __be32 daddr = iph->daddr;
  251. __u8 protocol = iph->protocol;
  252. unsigned int hash;
  253. struct ipq *qp;
  254. struct hlist_node *n;
  255. read_lock(&ip4_frags.lock);
  256. hash = ipqhashfn(id, saddr, daddr, protocol);
  257. hlist_for_each_entry(qp, n, &ip4_frags.hash[hash], q.list) {
  258. if (qp->id == id &&
  259. qp->saddr == saddr &&
  260. qp->daddr == daddr &&
  261. qp->protocol == protocol &&
  262. qp->user == user) {
  263. atomic_inc(&qp->q.refcnt);
  264. read_unlock(&ip4_frags.lock);
  265. return qp;
  266. }
  267. }
  268. read_unlock(&ip4_frags.lock);
  269. return ip_frag_create(iph, user);
  270. }
  271. /* Is the fragment too far ahead to be part of ipq? */
  272. static inline int ip_frag_too_far(struct ipq *qp)
  273. {
  274. struct inet_peer *peer = qp->peer;
  275. unsigned int max = sysctl_ipfrag_max_dist;
  276. unsigned int start, end;
  277. int rc;
  278. if (!peer || !max)
  279. return 0;
  280. start = qp->rid;
  281. end = atomic_inc_return(&peer->rid);
  282. qp->rid = end;
  283. rc = qp->q.fragments && (end - start) > max;
  284. if (rc) {
  285. IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
  286. }
  287. return rc;
  288. }
  289. static int ip_frag_reinit(struct ipq *qp)
  290. {
  291. struct sk_buff *fp;
  292. if (!mod_timer(&qp->q.timer, jiffies + ip4_frags_ctl.timeout)) {
  293. atomic_inc(&qp->q.refcnt);
  294. return -ETIMEDOUT;
  295. }
  296. fp = qp->q.fragments;
  297. do {
  298. struct sk_buff *xp = fp->next;
  299. frag_kfree_skb(fp, NULL);
  300. fp = xp;
  301. } while (fp);
  302. qp->q.last_in = 0;
  303. qp->q.len = 0;
  304. qp->q.meat = 0;
  305. qp->q.fragments = NULL;
  306. qp->iif = 0;
  307. return 0;
  308. }
  309. /* Add new segment to existing queue. */
  310. static int ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
  311. {
  312. struct sk_buff *prev, *next;
  313. struct net_device *dev;
  314. int flags, offset;
  315. int ihl, end;
  316. int err = -ENOENT;
  317. if (qp->q.last_in & COMPLETE)
  318. goto err;
  319. if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) &&
  320. unlikely(ip_frag_too_far(qp)) &&
  321. unlikely(err = ip_frag_reinit(qp))) {
  322. ipq_kill(qp);
  323. goto err;
  324. }
  325. offset = ntohs(ip_hdr(skb)->frag_off);
  326. flags = offset & ~IP_OFFSET;
  327. offset &= IP_OFFSET;
  328. offset <<= 3; /* offset is in 8-byte chunks */
  329. ihl = ip_hdrlen(skb);
  330. /* Determine the position of this fragment. */
  331. end = offset + skb->len - ihl;
  332. err = -EINVAL;
  333. /* Is this the final fragment? */
  334. if ((flags & IP_MF) == 0) {
  335. /* If we already have some bits beyond end
  336. * or have different end, the segment is corrrupted.
  337. */
  338. if (end < qp->q.len ||
  339. ((qp->q.last_in & LAST_IN) && end != qp->q.len))
  340. goto err;
  341. qp->q.last_in |= LAST_IN;
  342. qp->q.len = end;
  343. } else {
  344. if (end&7) {
  345. end &= ~7;
  346. if (skb->ip_summed != CHECKSUM_UNNECESSARY)
  347. skb->ip_summed = CHECKSUM_NONE;
  348. }
  349. if (end > qp->q.len) {
  350. /* Some bits beyond end -> corruption. */
  351. if (qp->q.last_in & LAST_IN)
  352. goto err;
  353. qp->q.len = end;
  354. }
  355. }
  356. if (end == offset)
  357. goto err;
  358. err = -ENOMEM;
  359. if (pskb_pull(skb, ihl) == NULL)
  360. goto err;
  361. err = pskb_trim_rcsum(skb, end - offset);
  362. if (err)
  363. goto err;
  364. /* Find out which fragments are in front and at the back of us
  365. * in the chain of fragments so far. We must know where to put
  366. * this fragment, right?
  367. */
  368. prev = NULL;
  369. for (next = qp->q.fragments; next != NULL; next = next->next) {
  370. if (FRAG_CB(next)->offset >= offset)
  371. break; /* bingo! */
  372. prev = next;
  373. }
  374. /* We found where to put this one. Check for overlap with
  375. * preceding fragment, and, if needed, align things so that
  376. * any overlaps are eliminated.
  377. */
  378. if (prev) {
  379. int i = (FRAG_CB(prev)->offset + prev->len) - offset;
  380. if (i > 0) {
  381. offset += i;
  382. err = -EINVAL;
  383. if (end <= offset)
  384. goto err;
  385. err = -ENOMEM;
  386. if (!pskb_pull(skb, i))
  387. goto err;
  388. if (skb->ip_summed != CHECKSUM_UNNECESSARY)
  389. skb->ip_summed = CHECKSUM_NONE;
  390. }
  391. }
  392. err = -ENOMEM;
  393. while (next && FRAG_CB(next)->offset < end) {
  394. int i = end - FRAG_CB(next)->offset; /* overlap is 'i' bytes */
  395. if (i < next->len) {
  396. /* Eat head of the next overlapped fragment
  397. * and leave the loop. The next ones cannot overlap.
  398. */
  399. if (!pskb_pull(next, i))
  400. goto err;
  401. FRAG_CB(next)->offset += i;
  402. qp->q.meat -= i;
  403. if (next->ip_summed != CHECKSUM_UNNECESSARY)
  404. next->ip_summed = CHECKSUM_NONE;
  405. break;
  406. } else {
  407. struct sk_buff *free_it = next;
  408. /* Old fragment is completely overridden with
  409. * new one drop it.
  410. */
  411. next = next->next;
  412. if (prev)
  413. prev->next = next;
  414. else
  415. qp->q.fragments = next;
  416. qp->q.meat -= free_it->len;
  417. frag_kfree_skb(free_it, NULL);
  418. }
  419. }
  420. FRAG_CB(skb)->offset = offset;
  421. /* Insert this fragment in the chain of fragments. */
  422. skb->next = next;
  423. if (prev)
  424. prev->next = skb;
  425. else
  426. qp->q.fragments = skb;
  427. dev = skb->dev;
  428. if (dev) {
  429. qp->iif = dev->ifindex;
  430. skb->dev = NULL;
  431. }
  432. qp->q.stamp = skb->tstamp;
  433. qp->q.meat += skb->len;
  434. atomic_add(skb->truesize, &ip4_frags.mem);
  435. if (offset == 0)
  436. qp->q.last_in |= FIRST_IN;
  437. if (qp->q.last_in == (FIRST_IN | LAST_IN) && qp->q.meat == qp->q.len)
  438. return ip_frag_reasm(qp, prev, dev);
  439. write_lock(&ip4_frags.lock);
  440. list_move_tail(&qp->q.lru_list, &ip4_frags.lru_list);
  441. write_unlock(&ip4_frags.lock);
  442. return -EINPROGRESS;
  443. err:
  444. kfree_skb(skb);
  445. return err;
  446. }
  447. /* Build a new IP datagram from all its fragments. */
  448. static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
  449. struct net_device *dev)
  450. {
  451. struct iphdr *iph;
  452. struct sk_buff *fp, *head = qp->q.fragments;
  453. int len;
  454. int ihlen;
  455. int err;
  456. ipq_kill(qp);
  457. /* Make the one we just received the head. */
  458. if (prev) {
  459. head = prev->next;
  460. fp = skb_clone(head, GFP_ATOMIC);
  461. if (!fp)
  462. goto out_nomem;
  463. fp->next = head->next;
  464. prev->next = fp;
  465. skb_morph(head, qp->q.fragments);
  466. head->next = qp->q.fragments->next;
  467. kfree_skb(qp->q.fragments);
  468. qp->q.fragments = head;
  469. }
  470. BUG_TRAP(head != NULL);
  471. BUG_TRAP(FRAG_CB(head)->offset == 0);
  472. /* Allocate a new buffer for the datagram. */
  473. ihlen = ip_hdrlen(head);
  474. len = ihlen + qp->q.len;
  475. err = -E2BIG;
  476. if (len > 65535)
  477. goto out_oversize;
  478. /* Head of list must not be cloned. */
  479. err = -ENOMEM;
  480. if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC))
  481. goto out_nomem;
  482. /* If the first fragment is fragmented itself, we split
  483. * it to two chunks: the first with data and paged part
  484. * and the second, holding only fragments. */
  485. if (skb_shinfo(head)->frag_list) {
  486. struct sk_buff *clone;
  487. int i, plen = 0;
  488. if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL)
  489. goto out_nomem;
  490. clone->next = head->next;
  491. head->next = clone;
  492. skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list;
  493. skb_shinfo(head)->frag_list = NULL;
  494. for (i=0; i<skb_shinfo(head)->nr_frags; i++)
  495. plen += skb_shinfo(head)->frags[i].size;
  496. clone->len = clone->data_len = head->data_len - plen;
  497. head->data_len -= clone->len;
  498. head->len -= clone->len;
  499. clone->csum = 0;
  500. clone->ip_summed = head->ip_summed;
  501. atomic_add(clone->truesize, &ip4_frags.mem);
  502. }
  503. skb_shinfo(head)->frag_list = head->next;
  504. skb_push(head, head->data - skb_network_header(head));
  505. atomic_sub(head->truesize, &ip4_frags.mem);
  506. for (fp=head->next; fp; fp = fp->next) {
  507. head->data_len += fp->len;
  508. head->len += fp->len;
  509. if (head->ip_summed != fp->ip_summed)
  510. head->ip_summed = CHECKSUM_NONE;
  511. else if (head->ip_summed == CHECKSUM_COMPLETE)
  512. head->csum = csum_add(head->csum, fp->csum);
  513. head->truesize += fp->truesize;
  514. atomic_sub(fp->truesize, &ip4_frags.mem);
  515. }
  516. head->next = NULL;
  517. head->dev = dev;
  518. head->tstamp = qp->q.stamp;
  519. iph = ip_hdr(head);
  520. iph->frag_off = 0;
  521. iph->tot_len = htons(len);
  522. IP_INC_STATS_BH(IPSTATS_MIB_REASMOKS);
  523. qp->q.fragments = NULL;
  524. return 0;
  525. out_nomem:
  526. LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing "
  527. "queue %p\n", qp);
  528. goto out_fail;
  529. out_oversize:
  530. if (net_ratelimit())
  531. printk(KERN_INFO
  532. "Oversized IP packet from %d.%d.%d.%d.\n",
  533. NIPQUAD(qp->saddr));
  534. out_fail:
  535. IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
  536. return err;
  537. }
  538. /* Process an incoming IP datagram fragment. */
  539. int ip_defrag(struct sk_buff *skb, u32 user)
  540. {
  541. struct ipq *qp;
  542. IP_INC_STATS_BH(IPSTATS_MIB_REASMREQDS);
  543. /* Start by cleaning up the memory. */
  544. if (atomic_read(&ip4_frags.mem) > ip4_frags_ctl.high_thresh)
  545. ip_evictor();
  546. /* Lookup (or create) queue header */
  547. if ((qp = ip_find(ip_hdr(skb), user)) != NULL) {
  548. int ret;
  549. spin_lock(&qp->q.lock);
  550. ret = ip_frag_queue(qp, skb);
  551. spin_unlock(&qp->q.lock);
  552. ipq_put(qp);
  553. return ret;
  554. }
  555. IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
  556. kfree_skb(skb);
  557. return -ENOMEM;
  558. }
  559. void __init ipfrag_init(void)
  560. {
  561. ip4_frags.ctl = &ip4_frags_ctl;
  562. ip4_frags.hashfn = ip4_hashfn;
  563. ip4_frags.destructor = ip4_frag_free;
  564. ip4_frags.skb_free = NULL;
  565. ip4_frags.qsize = sizeof(struct ipq);
  566. inet_frags_init(&ip4_frags);
  567. }
  568. EXPORT_SYMBOL(ip_defrag);