inet_frag.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. };
  29. #define INETFRAGS_HASHSZ 64
  30. struct inet_frags {
  31. struct hlist_head hash[INETFRAGS_HASHSZ];
  32. rwlock_t lock;
  33. u32 rnd;
  34. int qsize;
  35. int secret_interval;
  36. struct timer_list secret_timer;
  37. unsigned int (*hashfn)(struct inet_frag_queue *);
  38. void (*constructor)(struct inet_frag_queue *q,
  39. void *arg);
  40. void (*destructor)(struct inet_frag_queue *);
  41. void (*skb_free)(struct sk_buff *);
  42. int (*match)(struct inet_frag_queue *q,
  43. void *arg);
  44. void (*frag_expire)(unsigned long data);
  45. };
  46. void inet_frags_init(struct inet_frags *);
  47. void inet_frags_fini(struct inet_frags *);
  48. void inet_frags_init_net(struct netns_frags *nf);
  49. void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
  50. void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  51. void inet_frag_destroy(struct inet_frag_queue *q,
  52. struct inet_frags *f, int *work);
  53. int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
  54. struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
  55. struct inet_frags *f, void *key, unsigned int hash)
  56. __releases(&f->lock);
  57. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  58. {
  59. if (atomic_dec_and_test(&q->refcnt))
  60. inet_frag_destroy(q, f, NULL);
  61. }
  62. #endif