blob: f56e296e62277fb3225ca6b6be4be8a9dae95fe5 [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 Emelyanovac18e752008-01-22 06:02:14 -080010};
11
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070012struct inet_frag_queue {
13 struct hlist_node list;
Pavel Emelyanovac18e752008-01-22 06:02:14 -080014 struct netns_frags *net;
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070015 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 Emelyanov7eb95152007-10-15 02:31:52 -070030#define INETFRAGS_HASHSZ 64
31
Pavel Emelyanov04128f22007-10-15 02:33:45 -070032struct inet_frags_ctl {
33 int high_thresh;
34 int low_thresh;
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