blob: 6edce7b2ff13af583a9dedd7d8b865b221236845 [file] [log] [blame]
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -07001#ifndef __NET_FRAG_H__
2#define __NET_FRAG_H__
3
Pavel Emelyanovac18e752008-01-22 06:02:14 -08004struct netns_frags {
Pavel Emelyanove5a2bb82008-01-22 06:06:23 -08005 int nqueues;
Pavel Emelyanov6ddc0822008-01-22 06:07:25 -08006 atomic_t mem;
Pavel Emelyanovac18e752008-01-22 06:02:14 -08007};
8
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -07009struct inet_frag_queue {
10 struct hlist_node list;
Pavel Emelyanovac18e752008-01-22 06:02:14 -080011 struct netns_frags *net;
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070012 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
22#define COMPLETE 4
23#define FIRST_IN 2
24#define LAST_IN 1
25};
26
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070027#define INETFRAGS_HASHSZ 64
28
Pavel Emelyanov04128f22007-10-15 02:33:45 -070029struct inet_frags_ctl {
30 int high_thresh;
31 int low_thresh;
32 int timeout;
33 int secret_interval;
34};
35
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070036struct inet_frags {
37 struct list_head lru_list;
38 struct hlist_head hash[INETFRAGS_HASHSZ];
39 rwlock_t lock;
40 u32 rnd;
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070041 int qsize;
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070042 struct timer_list secret_timer;
Pavel Emelyanov04128f22007-10-15 02:33:45 -070043 struct inet_frags_ctl *ctl;
Pavel Emelyanov321a3a92007-10-15 02:38:08 -070044
45 unsigned int (*hashfn)(struct inet_frag_queue *);
Pavel Emelyanovc6fda282007-10-17 19:46:47 -070046 void (*constructor)(struct inet_frag_queue *q,
47 void *arg);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070048 void (*destructor)(struct inet_frag_queue *);
49 void (*skb_free)(struct sk_buff *);
Pavel Emelyanovabd65232007-10-17 19:47:21 -070050 int (*match)(struct inet_frag_queue *q,
51 void *arg);
Pavel Emelyanove521db92007-10-17 19:45:23 -070052 void (*frag_expire)(unsigned long data);
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070053};
54
55void inet_frags_init(struct inet_frags *);
56void inet_frags_fini(struct inet_frags *);
57
Pavel Emelyanove5a2bb82008-01-22 06:06:23 -080058void inet_frags_init_net(struct netns_frags *nf);
59
Pavel Emelyanov277e6502007-10-15 02:37:18 -070060void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070061void inet_frag_destroy(struct inet_frag_queue *q,
62 struct inet_frags *f, int *work);
Pavel Emelyanov6ddc0822008-01-22 06:07:25 -080063int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
Pavel Emelyanovac18e752008-01-22 06:02:14 -080064struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
65 struct inet_frags *f, void *key, unsigned int hash);
Pavel Emelyanov277e6502007-10-15 02:37:18 -070066
Pavel Emelyanov762cc402007-10-15 02:41:56 -070067static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
68{
69 if (atomic_dec_and_test(&q->refcnt))
70 inet_frag_destroy(q, f, NULL);
71}
72
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070073#endif