inet_frag.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef __NET_FRAG_H__
  2. #define __NET_FRAG_H__
  3. struct netns_frags {
  4. int nqueues;
  5. struct list_head lru_list;
  6. /* Its important for performance to keep lru_list and mem on
  7. * separate cachelines
  8. */
  9. atomic_t mem ____cacheline_aligned_in_smp;
  10. /* sysctls */
  11. int timeout;
  12. int high_thresh;
  13. int low_thresh;
  14. };
  15. struct inet_frag_queue {
  16. spinlock_t lock;
  17. struct timer_list timer; /* when will this queue expire? */
  18. struct list_head lru_list; /* lru list member */
  19. struct hlist_node list;
  20. atomic_t refcnt;
  21. struct sk_buff *fragments; /* list of received fragments */
  22. struct sk_buff *fragments_tail;
  23. ktime_t stamp;
  24. int len; /* total length of orig datagram */
  25. int meat;
  26. __u8 last_in; /* first/last segment arrived? */
  27. #define INET_FRAG_COMPLETE 4
  28. #define INET_FRAG_FIRST_IN 2
  29. #define INET_FRAG_LAST_IN 1
  30. u16 max_size;
  31. struct netns_frags *net;
  32. };
  33. #define INETFRAGS_HASHSZ 64
  34. struct inet_frags {
  35. struct hlist_head hash[INETFRAGS_HASHSZ];
  36. /* This rwlock is a global lock (seperate per IPv4, IPv6 and
  37. * netfilter). Important to keep this on a seperate cacheline.
  38. */
  39. rwlock_t lock ____cacheline_aligned_in_smp;
  40. int secret_interval;
  41. struct timer_list secret_timer;
  42. u32 rnd;
  43. int qsize;
  44. unsigned int (*hashfn)(struct inet_frag_queue *);
  45. bool (*match)(struct inet_frag_queue *q, void *arg);
  46. void (*constructor)(struct inet_frag_queue *q,
  47. void *arg);
  48. void (*destructor)(struct inet_frag_queue *);
  49. void (*skb_free)(struct sk_buff *);
  50. void (*frag_expire)(unsigned long data);
  51. };
  52. void inet_frags_init(struct inet_frags *);
  53. void inet_frags_fini(struct inet_frags *);
  54. void inet_frags_init_net(struct netns_frags *nf);
  55. void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
  56. void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  57. void inet_frag_destroy(struct inet_frag_queue *q,
  58. struct inet_frags *f, int *work);
  59. int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force);
  60. struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
  61. struct inet_frags *f, void *key, unsigned int hash)
  62. __releases(&f->lock);
  63. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  64. {
  65. if (atomic_dec_and_test(&q->refcnt))
  66. inet_frag_destroy(q, f, NULL);
  67. }
  68. #endif