inet_frag.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 (*constructor)(struct inet_frag_queue *q,
  37. void *arg);
  38. void (*destructor)(struct inet_frag_queue *);
  39. void (*skb_free)(struct sk_buff *);
  40. int (*equal)(struct inet_frag_queue *q1,
  41. struct inet_frag_queue *q2);
  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_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  49. void inet_frag_destroy(struct inet_frag_queue *q,
  50. struct inet_frags *f, int *work);
  51. int inet_frag_evictor(struct inet_frags *f);
  52. struct inet_frag_queue *inet_frag_find(struct inet_frags *f, void *key,
  53. unsigned int hash);
  54. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  55. {
  56. if (atomic_dec_and_test(&q->refcnt))
  57. inet_frag_destroy(q, f, NULL);
  58. }
  59. #endif