inet_frag.h 1.7 KB

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