inet_frag.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __NET_FRAG_H__
  2. #define __NET_FRAG_H__
  3. struct inet_frag_queue {
  4. struct hlist_node list;
  5. struct list_head lru_list; /* lru list member */
  6. spinlock_t lock;
  7. atomic_t refcnt;
  8. struct timer_list timer; /* when will this queue expire? */
  9. struct sk_buff *fragments; /* list of received fragments */
  10. ktime_t stamp;
  11. int len; /* total length of orig datagram */
  12. int meat;
  13. __u8 last_in; /* first/last segment arrived? */
  14. #define COMPLETE 4
  15. #define FIRST_IN 2
  16. #define LAST_IN 1
  17. };
  18. #define INETFRAGS_HASHSZ 64
  19. struct inet_frags_ctl {
  20. int high_thresh;
  21. int low_thresh;
  22. int timeout;
  23. int secret_interval;
  24. };
  25. struct inet_frags {
  26. struct list_head lru_list;
  27. struct hlist_head hash[INETFRAGS_HASHSZ];
  28. rwlock_t lock;
  29. u32 rnd;
  30. int nqueues;
  31. int qsize;
  32. atomic_t mem;
  33. struct timer_list secret_timer;
  34. struct inet_frags_ctl *ctl;
  35. unsigned int (*hashfn)(struct inet_frag_queue *);
  36. void (*destructor)(struct inet_frag_queue *);
  37. void (*skb_free)(struct sk_buff *);
  38. };
  39. void inet_frags_init(struct inet_frags *);
  40. void inet_frags_fini(struct inet_frags *);
  41. void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  42. void inet_frag_destroy(struct inet_frag_queue *q,
  43. struct inet_frags *f, int *work);
  44. int inet_frag_evictor(struct inet_frags *f);
  45. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  46. {
  47. if (atomic_dec_and_test(&q->refcnt))
  48. inet_frag_destroy(q, f, NULL);
  49. }
  50. #endif