inet_frag.h 1.9 KB

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