inet_frag.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef __NET_FRAG_H__
  2. #define __NET_FRAG_H__
  3. struct netns_frags {
  4. int nqueues;
  5. atomic_t mem;
  6. struct list_head lru_list;
  7. /* sysctls */
  8. int timeout;
  9. int high_thresh;
  10. int low_thresh;
  11. };
  12. struct inet_frag_queue {
  13. struct hlist_node list;
  14. struct netns_frags *net;
  15. struct list_head lru_list; /* lru list member */
  16. spinlock_t lock;
  17. atomic_t refcnt;
  18. struct timer_list timer; /* when will this queue expire? */
  19. struct sk_buff *fragments; /* list of received fragments */
  20. struct sk_buff *fragments_tail;
  21. ktime_t stamp;
  22. int len; /* total length of orig datagram */
  23. int meat;
  24. __u8 last_in; /* first/last segment arrived? */
  25. #define INET_FRAG_COMPLETE 4
  26. #define INET_FRAG_FIRST_IN 2
  27. #define INET_FRAG_LAST_IN 1
  28. u16 max_size;
  29. };
  30. #define INETFRAGS_HASHSZ 64
  31. /* averaged:
  32. * max_depth = default ipfrag_high_thresh / INETFRAGS_HASHSZ /
  33. * rounded up (SKB_TRUELEN(0) + sizeof(struct ipq or
  34. * struct frag_queue))
  35. */
  36. #define INETFRAGS_MAXDEPTH 128
  37. struct inet_frags {
  38. struct hlist_head hash[INETFRAGS_HASHSZ];
  39. rwlock_t lock;
  40. u32 rnd;
  41. int qsize;
  42. int secret_interval;
  43. struct timer_list secret_timer;
  44. unsigned int (*hashfn)(struct inet_frag_queue *);
  45. void (*constructor)(struct inet_frag_queue *q,
  46. void *arg);
  47. void (*destructor)(struct inet_frag_queue *);
  48. void (*skb_free)(struct sk_buff *);
  49. int (*match)(struct inet_frag_queue *q,
  50. void *arg);
  51. void (*frag_expire)(unsigned long data);
  52. };
  53. void inet_frags_init(struct inet_frags *);
  54. void inet_frags_fini(struct inet_frags *);
  55. void inet_frags_init_net(struct netns_frags *nf);
  56. void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
  57. void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  58. void inet_frag_destroy(struct inet_frag_queue *q,
  59. struct inet_frags *f, int *work);
  60. int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
  61. struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
  62. struct inet_frags *f, void *key, unsigned int hash)
  63. __releases(&f->lock);
  64. void inet_frag_maybe_warn_overflow(struct inet_frag_queue *q,
  65. const char *prefix);
  66. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  67. {
  68. if (atomic_dec_and_test(&q->refcnt))
  69. inet_frag_destroy(q, f, NULL);
  70. }
  71. #endif