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