inet_frag.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. ktime_t stamp;
  21. int len; /* total length of orig datagram */
  22. int meat;
  23. __u8 last_in; /* first/last segment arrived? */
  24. #define INET_FRAG_COMPLETE 4
  25. #define INET_FRAG_FIRST_IN 2
  26. #define INET_FRAG_LAST_IN 1
  27. };
  28. #define INETFRAGS_HASHSZ 64
  29. struct inet_frags {
  30. struct hlist_head hash[INETFRAGS_HASHSZ];
  31. rwlock_t lock;
  32. u32 rnd;
  33. int qsize;
  34. int secret_interval;
  35. struct timer_list secret_timer;
  36. unsigned int (*hashfn)(struct inet_frag_queue *);
  37. void (*constructor)(struct inet_frag_queue *q,
  38. void *arg);
  39. void (*destructor)(struct inet_frag_queue *);
  40. void (*skb_free)(struct sk_buff *);
  41. int (*match)(struct inet_frag_queue *q,
  42. void *arg);
  43. void (*frag_expire)(unsigned long data);
  44. };
  45. void inet_frags_init(struct inet_frags *);
  46. void inet_frags_fini(struct inet_frags *);
  47. void inet_frags_init_net(struct netns_frags *nf);
  48. void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
  49. void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  50. void inet_frag_destroy(struct inet_frag_queue *q,
  51. struct inet_frags *f, int *work);
  52. int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
  53. struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
  54. struct inet_frags *f, void *key, unsigned int hash)
  55. __releases(&f->lock);
  56. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  57. {
  58. if (atomic_dec_and_test(&q->refcnt))
  59. inet_frag_destroy(q, f, NULL);
  60. }
  61. #endif