blob: 1917fbeb362bc67408e4fd000916b86d6350cb11 [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 Emelyanovb2fd5322008-01-22 06:09:37 -08007
8 /* sysctls */
9 int timeout;
Pavel Emelyanove31e0bdc72008-01-22 06:10:13 -080010 int high_thresh;
11 int low_thresh;
Pavel Emelyanovac18e752008-01-22 06:02:14 -080012};
13
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070014struct inet_frag_queue {
15 struct hlist_node list;
Pavel Emelyanovac18e752008-01-22 06:02:14 -080016 struct netns_frags *net;
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070017 struct list_head lru_list; /* lru list member */
18 spinlock_t lock;
19 atomic_t refcnt;
20 struct timer_list timer; /* when will this queue expire? */
21 struct sk_buff *fragments; /* list of received fragments */
22 ktime_t stamp;
23 int len; /* total length of orig datagram */
24 int meat;
25 __u8 last_in; /* first/last segment arrived? */
26
27#define COMPLETE 4
28#define FIRST_IN 2
29#define LAST_IN 1
30};
31
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070032#define INETFRAGS_HASHSZ 64
33
34struct inet_frags {
35 struct list_head lru_list;
36 struct hlist_head hash[INETFRAGS_HASHSZ];
37 rwlock_t lock;
38 u32 rnd;
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070039 int qsize;
Pavel Emelyanov3b4bc4a2008-01-22 06:11:04 -080040 int secret_interval;
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070041 struct timer_list secret_timer;
Pavel Emelyanov321a3a92007-10-15 02:38:08 -070042
43 unsigned int (*hashfn)(struct inet_frag_queue *);
Pavel Emelyanovc6fda282007-10-17 19:46:47 -070044 void (*constructor)(struct inet_frag_queue *q,
45 void *arg);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070046 void (*destructor)(struct inet_frag_queue *);
47 void (*skb_free)(struct sk_buff *);
Pavel Emelyanovabd65232007-10-17 19:47:21 -070048 int (*match)(struct inet_frag_queue *q,
49 void *arg);
Pavel Emelyanove521db92007-10-17 19:45:23 -070050 void (*frag_expire)(unsigned long data);
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070051};
52
53void inet_frags_init(struct inet_frags *);
54void inet_frags_fini(struct inet_frags *);
55
Pavel Emelyanove5a2bb82008-01-22 06:06:23 -080056void inet_frags_init_net(struct netns_frags *nf);
57
Pavel Emelyanov277e6502007-10-15 02:37:18 -070058void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070059void inet_frag_destroy(struct inet_frag_queue *q,
60 struct inet_frags *f, int *work);
Pavel Emelyanov6ddc0822008-01-22 06:07:25 -080061int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
Pavel Emelyanovac18e752008-01-22 06:02:14 -080062struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
63 struct inet_frags *f, void *key, unsigned int hash);
Pavel Emelyanov277e6502007-10-15 02:37:18 -070064
Pavel Emelyanov762cc402007-10-15 02:41:56 -070065static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
66{
67 if (atomic_dec_and_test(&q->refcnt))
68 inet_frag_destroy(q, f, NULL);
69}
70
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070071#endif