inet_frag.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef __NET_FRAG_H__
  2. #define __NET_FRAG_H__
  3. struct netns_frags {
  4. int nqueues;
  5. atomic_t mem;
  6. };
  7. struct inet_frag_queue {
  8. struct hlist_node list;
  9. struct netns_frags *net;
  10. struct list_head lru_list; /* lru list member */
  11. spinlock_t lock;
  12. atomic_t refcnt;
  13. struct timer_list timer; /* when will this queue expire? */
  14. struct sk_buff *fragments; /* list of received fragments */
  15. ktime_t stamp;
  16. int len; /* total length of orig datagram */
  17. int meat;
  18. __u8 last_in; /* first/last segment arrived? */
  19. #define COMPLETE 4
  20. #define FIRST_IN 2
  21. #define LAST_IN 1
  22. };
  23. #define INETFRAGS_HASHSZ 64
  24. struct inet_frags_ctl {
  25. int high_thresh;
  26. int low_thresh;
  27. int timeout;
  28. int secret_interval;
  29. };
  30. struct inet_frags {
  31. struct list_head lru_list;
  32. struct hlist_head hash[INETFRAGS_HASHSZ];
  33. rwlock_t lock;
  34. u32 rnd;
  35. int qsize;
  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 netns_frags *nf, 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