blob: 16ff29a7bb30cfbf5e1581c1388e321e9d9f2a1b [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 Emelyanove5a2bb8422008-01-22 06:06:23 -08005 int nqueues;
Pavel Emelyanov6ddc0822008-01-22 06:07:25 -08006 atomic_t mem;
Pavel Emelyanov3140c252008-01-22 06:11:48 -08007 struct list_head lru_list;
Pavel Emelyanovb2fd5322008-01-22 06:09:37 -08008
9 /* sysctls */
10 int timeout;
Pavel Emelyanove31e0bdc72008-01-22 06:10:13 -080011 int high_thresh;
12 int low_thresh;
Pavel Emelyanovac18e752008-01-22 06:02:14 -080013};
14
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070015struct inet_frag_queue {
16 struct hlist_node list;
Pavel Emelyanovac18e752008-01-22 06:02:14 -080017 struct netns_frags *net;
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070018 struct list_head lru_list; /* lru list member */
19 spinlock_t lock;
20 atomic_t refcnt;
21 struct timer_list timer; /* when will this queue expire? */
22 struct sk_buff *fragments; /* list of received fragments */
Changli Gaod6bebca2010-06-29 04:39:37 +000023 struct sk_buff *fragments_tail;
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070024 ktime_t stamp;
25 int len; /* total length of orig datagram */
26 int meat;
27 __u8 last_in; /* first/last segment arrived? */
28
Joe Perchesbc578a52008-03-28 16:35:27 -070029#define INET_FRAG_COMPLETE 4
30#define INET_FRAG_FIRST_IN 2
31#define INET_FRAG_LAST_IN 1
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070032};
33
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070034#define INETFRAGS_HASHSZ 64
35
36struct inet_frags {
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070037 struct hlist_head hash[INETFRAGS_HASHSZ];
38 rwlock_t lock;
39 u32 rnd;
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070040 int qsize;
Pavel Emelyanov3b4bc4a2008-01-22 06:11:04 -080041 int secret_interval;
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070042 struct timer_list secret_timer;
Pavel Emelyanov321a3a92007-10-15 02:38:08 -070043
44 unsigned int (*hashfn)(struct inet_frag_queue *);
Pavel Emelyanovc6fda282007-10-17 19:46:47 -070045 void (*constructor)(struct inet_frag_queue *q,
46 void *arg);
Pavel Emelyanov1e4b8282007-10-15 02:39:14 -070047 void (*destructor)(struct inet_frag_queue *);
48 void (*skb_free)(struct sk_buff *);
Pavel Emelyanovabd65232007-10-17 19:47:21 -070049 int (*match)(struct inet_frag_queue *q,
50 void *arg);
Pavel Emelyanove521db92007-10-17 19:45:23 -070051 void (*frag_expire)(unsigned long data);
Pavel Emelyanov7eb95152007-10-15 02:31:52 -070052};
53
54void inet_frags_init(struct inet_frags *);
55void inet_frags_fini(struct inet_frags *);
56
Pavel Emelyanove5a2bb8422008-01-22 06:06:23 -080057void inet_frags_init_net(struct netns_frags *nf);
Pavel Emelyanov81566e82008-01-22 06:12:39 -080058void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
Pavel Emelyanove5a2bb8422008-01-22 06:06:23 -080059
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,
Hannes Eder56bca312009-02-25 10:32:52 +000065 struct inet_frags *f, void *key, unsigned int hash)
66 __releases(&f->lock);
Pavel Emelyanov277e6502007-10-15 02:37:18 -070067
Pavel Emelyanov762cc402007-10-15 02:41:56 -070068static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
69{
70 if (atomic_dec_and_test(&q->refcnt))
71 inet_frag_destroy(q, f, NULL);
72}
73
Pavel Emelyanov5ab11c92007-10-15 02:24:19 -070074#endif