inet_frag.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __NET_FRAG_H__
  2. #define __NET_FRAG_H__
  3. struct netns_frags {
  4. };
  5. struct inet_frag_queue {
  6. struct hlist_node list;
  7. struct netns_frags *net;
  8. struct list_head lru_list; /* lru list member */
  9. spinlock_t lock;
  10. atomic_t refcnt;
  11. struct timer_list timer; /* when will this queue expire? */
  12. struct sk_buff *fragments; /* list of received fragments */
  13. ktime_t stamp;
  14. int len; /* total length of orig datagram */
  15. int meat;
  16. __u8 last_in; /* first/last segment arrived? */
  17. #define COMPLETE 4
  18. #define FIRST_IN 2
  19. #define LAST_IN 1
  20. };
  21. #define INETFRAGS_HASHSZ 64
  22. struct inet_frags_ctl {
  23. int high_thresh;
  24. int low_thresh;
  25. int timeout;
  26. int secret_interval;
  27. };
  28. struct inet_frags {
  29. struct list_head lru_list;
  30. struct hlist_head hash[INETFRAGS_HASHSZ];
  31. rwlock_t lock;
  32. u32 rnd;
  33. int nqueues;
  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_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
  50. void inet_frag_destroy(struct inet_frag_queue *q,
  51. struct inet_frags *f, int *work);
  52. int inet_frag_evictor(struct inet_frags *f);
  53. struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
  54. struct inet_frags *f, void *key, unsigned int hash);
  55. static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
  56. {
  57. if (atomic_dec_and_test(&q->refcnt))
  58. inet_frag_destroy(q, f, NULL);
  59. }
  60. #endif