Pavel Emelyanov | 5ab11c9 | 2007-10-15 02:24:19 -0700 | [diff] [blame] | 1 | #ifndef __NET_FRAG_H__ |
| 2 | #define __NET_FRAG_H__ |
| 3 | |
| 4 | struct inet_frag_queue { |
| 5 | struct hlist_node list; |
| 6 | struct list_head lru_list; /* lru list member */ |
| 7 | spinlock_t lock; |
| 8 | atomic_t refcnt; |
| 9 | struct timer_list timer; /* when will this queue expire? */ |
| 10 | struct sk_buff *fragments; /* list of received fragments */ |
| 11 | ktime_t stamp; |
| 12 | int len; /* total length of orig datagram */ |
| 13 | int meat; |
| 14 | __u8 last_in; /* first/last segment arrived? */ |
| 15 | |
| 16 | #define COMPLETE 4 |
| 17 | #define FIRST_IN 2 |
| 18 | #define LAST_IN 1 |
| 19 | }; |
| 20 | |
Pavel Emelyanov | 7eb9515 | 2007-10-15 02:31:52 -0700 | [diff] [blame] | 21 | #define INETFRAGS_HASHSZ 64 |
| 22 | |
Pavel Emelyanov | 04128f2 | 2007-10-15 02:33:45 -0700 | [diff] [blame] | 23 | struct inet_frags_ctl { |
| 24 | int high_thresh; |
| 25 | int low_thresh; |
| 26 | int timeout; |
| 27 | int secret_interval; |
| 28 | }; |
| 29 | |
Pavel Emelyanov | 7eb9515 | 2007-10-15 02:31:52 -0700 | [diff] [blame] | 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 nqueues; |
Pavel Emelyanov | 1e4b828 | 2007-10-15 02:39:14 -0700 | [diff] [blame] | 36 | int qsize; |
Pavel Emelyanov | 7eb9515 | 2007-10-15 02:31:52 -0700 | [diff] [blame] | 37 | atomic_t mem; |
| 38 | struct timer_list secret_timer; |
Pavel Emelyanov | 04128f2 | 2007-10-15 02:33:45 -0700 | [diff] [blame] | 39 | struct inet_frags_ctl *ctl; |
Pavel Emelyanov | 321a3a9 | 2007-10-15 02:38:08 -0700 | [diff] [blame] | 40 | |
| 41 | unsigned int (*hashfn)(struct inet_frag_queue *); |
Pavel Emelyanov | c6fda28 | 2007-10-17 19:46:47 -0700 | [diff] [blame] | 42 | void (*constructor)(struct inet_frag_queue *q, |
| 43 | void *arg); |
Pavel Emelyanov | 1e4b828 | 2007-10-15 02:39:14 -0700 | [diff] [blame] | 44 | void (*destructor)(struct inet_frag_queue *); |
| 45 | void (*skb_free)(struct sk_buff *); |
Pavel Emelyanov | 2588fe1 | 2007-10-17 19:44:34 -0700 | [diff] [blame] | 46 | int (*equal)(struct inet_frag_queue *q1, |
| 47 | struct inet_frag_queue *q2); |
Pavel Emelyanov | abd6523 | 2007-10-17 19:47:21 -0700 | [diff] [blame^] | 48 | int (*match)(struct inet_frag_queue *q, |
| 49 | void *arg); |
Pavel Emelyanov | e521db9 | 2007-10-17 19:45:23 -0700 | [diff] [blame] | 50 | void (*frag_expire)(unsigned long data); |
Pavel Emelyanov | 7eb9515 | 2007-10-15 02:31:52 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | void inet_frags_init(struct inet_frags *); |
| 54 | void inet_frags_fini(struct inet_frags *); |
| 55 | |
Pavel Emelyanov | 277e650 | 2007-10-15 02:37:18 -0700 | [diff] [blame] | 56 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); |
Pavel Emelyanov | 1e4b828 | 2007-10-15 02:39:14 -0700 | [diff] [blame] | 57 | void inet_frag_destroy(struct inet_frag_queue *q, |
| 58 | struct inet_frags *f, int *work); |
Pavel Emelyanov | 8e7999c | 2007-10-15 02:40:06 -0700 | [diff] [blame] | 59 | int inet_frag_evictor(struct inet_frags *f); |
Pavel Emelyanov | abd6523 | 2007-10-17 19:47:21 -0700 | [diff] [blame^] | 60 | struct inet_frag_queue *inet_frag_find(struct inet_frags *f, void *key, |
| 61 | unsigned int hash); |
Pavel Emelyanov | 277e650 | 2007-10-15 02:37:18 -0700 | [diff] [blame] | 62 | |
Pavel Emelyanov | 762cc40 | 2007-10-15 02:41:56 -0700 | [diff] [blame] | 63 | static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f) |
| 64 | { |
| 65 | if (atomic_dec_and_test(&q->refcnt)) |
| 66 | inet_frag_destroy(q, f, NULL); |
| 67 | } |
| 68 | |
Pavel Emelyanov | 5ab11c9 | 2007-10-15 02:24:19 -0700 | [diff] [blame] | 69 | #endif |