inet_frag.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. int (*equal)(struct inet_frag_queue *q1,
  39. struct inet_frag_queue *q2);
  40. void (*frag_expire)(unsigned long data);
  41. };
  42. void inet_frags_init(struct inet_frags *);
  43. void inet_frags_fini(struct inet_frags *);
  44. void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  45. void inet_frag_destroy(struct inet_frag_queue *q,
  46. struct inet_frags *f, int *work);
  47. int inet_frag_evictor(struct inet_frags *f);
  48. struct inet_frag_queue *inet_frag_intern(struct inet_frag_queue *q,
  49. struct inet_frags *f, unsigned int hash);
  50. struct inet_frag_queue *inet_frag_alloc(struct inet_frags *f);
  51. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  52. {
  53. if (atomic_dec_and_test(&q->refcnt))
  54. inet_frag_destroy(q, f, NULL);
  55. }
  56. #endif