blob: de41359254907867d0cf809b2ca9e143ffba3a2b [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
Pavel Emelyanov04128f22007-10-15 02:33:45 -070034struct inet_frags_ctl {
Pavel Emelyanov04128f22007-10-15 02:33:45 -070035 int secret_interval;
36};
37
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070038struct inet_frags {
39 struct list_head lru_list;
40 struct hlist_head hash[INETFRAGS_HASHSZ];
41 rwlock_t lock;
42 u32 rnd;
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070043 int qsize;
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070044 struct timer_list secret_timer;
Pavel Emelyanov04128f22007-10-15 02:33:45 -070045 struct inet_frags_ctl *ctl;
Pavel Emelyanov321a3a92007-10-15 02:38:08 -070046
47 unsigned int (*hashfn)(struct inet_frag_queue *);
Pavel Emelyanovc6fda282007-10-17 19:46:47 -070048 void (*constructor)(struct inet_frag_queue *q,
49 void *arg);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070050 void (*destructor)(struct inet_frag_queue *);
51 void (*skb_free)(struct sk_buff *);
Pavel Emelyanovabd65232007-10-17 19:47:21 -070052 int (*match)(struct inet_frag_queue *q,
53 void *arg);
Pavel Emelyanove521db92007-10-17 19:45:23 -070054 void (*frag_expire)(unsigned long data);
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070055};
56
57void inet_frags_init(struct inet_frags *);
58void inet_frags_fini(struct inet_frags *);
59
Pavel Emelyanove5a2bb82008-01-22 06:06:23 -080060void inet_frags_init_net(struct netns_frags *nf);
61
Pavel Emelyanov277e6502007-10-15 02:37:18 -070062void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070063void inet_frag_destroy(struct inet_frag_queue *q,
64 struct inet_frags *f, int *work);
Pavel Emelyanov6ddc0822008-01-22 06:07:25 -080065int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
Pavel Emelyanovac18e752008-01-22 06:02:14 -080066struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
67 struct inet_frags *f, void *key, unsigned int hash);
Pavel Emelyanov277e6502007-10-15 02:37:18 -070068
Pavel Emelyanov762cc402007-10-15 02:41:56 -070069static 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 Emelyanov5ab11c92007-10-15 02:24:19 -070075#endif