inet_frag.h 1.8 KB

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