blob: 412b8582a6160dc256387a3f948b35f892fd6228 [file] [log] [blame]
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -07001#ifndef __NET_FRAG_H__
2#define __NET_FRAG_H__
3
4struct 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 Emelyanov7eb95152007-10-15 02:31:52 -070021#define INETFRAGS_HASHSZ 64
22
Pavel Emelyanov04128f22007-10-15 02:33:45 -070023struct inet_frags_ctl {
24 int high_thresh;
25 int low_thresh;
26 int timeout;
27 int secret_interval;
28};
29
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070030struct 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 Emelyanov1e4b8282007-10-15 02:39:14 -070036 int qsize;
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070037 atomic_t mem;
38 struct timer_list secret_timer;
Pavel Emelyanov04128f22007-10-15 02:33:45 -070039 struct inet_frags_ctl *ctl;
Pavel Emelyanov321a3a92007-10-15 02:38:08 -070040
41 unsigned int (*hashfn)(struct inet_frag_queue *);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070042 void (*destructor)(struct inet_frag_queue *);
43 void (*skb_free)(struct sk_buff *);
Pavel Emelyanov2588fe12007-10-17 19:44:34 -070044 int (*equal)(struct inet_frag_queue *q1,
45 struct inet_frag_queue *q2);
Pavel Emelyanove521db92007-10-17 19:45:23 -070046 void (*frag_expire)(unsigned long data);
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070047};
48
49void inet_frags_init(struct inet_frags *);
50void inet_frags_fini(struct inet_frags *);
51
Pavel Emelyanov277e6502007-10-15 02:37:18 -070052void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070053void inet_frag_destroy(struct inet_frag_queue *q,
54 struct inet_frags *f, int *work);
Pavel Emelyanov8e7999c2007-10-15 02:40:06 -070055int inet_frag_evictor(struct inet_frags *f);
Pavel Emelyanov2588fe12007-10-17 19:44:34 -070056struct inet_frag_queue *inet_frag_intern(struct inet_frag_queue *q,
57 struct inet_frags *f, unsigned int hash);
Pavel Emelyanove521db92007-10-17 19:45:23 -070058struct inet_frag_queue *inet_frag_alloc(struct inet_frags *f);
Pavel Emelyanov277e6502007-10-15 02:37:18 -070059
Pavel Emelyanov762cc402007-10-15 02:41:56 -070060static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
61{
62 if (atomic_dec_and_test(&q->refcnt))
63 inet_frag_destroy(q, f, NULL);
64}
65
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070066#endif