1 #ifndef __NET_INET_FRAG_WRAPPER_H
2 #define __NET_INET_FRAG_WRAPPER_H 1
4 #include <linux/version.h>
5 #include_next <net/inet_frag.h>
7 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
8 #define inet_frag_evictor(nf, f, force) \
10 if (force || atomic_read(&nf->mem) > nf->high_thresh) { \
11 inet_frag_evictor(nf, f); \
16 #ifdef OVS_FRAGMENT_BACKPORT
17 #ifdef HAVE_INET_FRAGS_LAST_IN
18 #define q_flags(q) (q->last_in)
19 #define qp_flags(qp) (qp->q.last_in)
21 #define q_flags(q) (q->flags)
22 #define qp_flags(qp) (qp->q.flags)
26 * struct ovs_inet_frag_queue - fragment queue
28 * Wrap the system inet_frag_queue to provide a list evictor.
30 * @list_evictor: list of queues to forcefully evict (e.g. due to low memory)
32 struct ovs_inet_frag_queue {
33 struct inet_frag_queue fq;
34 struct hlist_node list_evictor;
37 static inline bool rpl_inet_frag_evicting(struct inet_frag_queue *q)
39 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
40 return (q_flags(q) & INET_FRAG_FIRST_IN) && q->fragments != NULL;
42 struct ovs_inet_frag_queue *ofq = (struct ovs_inet_frag_queue *)q;
43 return !hlist_unhashed(&ofq->list_evictor);
46 #define inet_frag_evicting rpl_inet_frag_evicting
48 static unsigned int rpl_frag_percpu_counter_batch = 130000;
49 #define frag_percpu_counter_batch rpl_frag_percpu_counter_batch
51 static inline void rpl_sub_frag_mem_limit(struct netns_frags *nf, int i)
53 __percpu_counter_add(&nf->mem, -i, frag_percpu_counter_batch);
55 #define sub_frag_mem_limit rpl_sub_frag_mem_limit
57 static inline void rpl_add_frag_mem_limit(struct netns_frags *nf, int i)
59 __percpu_counter_add(&nf->mem, i, frag_percpu_counter_batch);
61 #define add_frag_mem_limit rpl_add_frag_mem_limit
63 int rpl_inet_frags_init(struct inet_frags *f);
64 #define inet_frags_init rpl_inet_frags_init
66 void rpl_inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
67 #define inet_frags_exit_net rpl_inet_frags_exit_net
69 void rpl_inet_frag_destroy(struct inet_frag_queue *q, struct inet_frags *f);
70 #define inet_frag_destroy(q, f, work) rpl_inet_frag_destroy(q, f)
71 #endif /* OVS_FRAGMENT_BACKPORT */
73 #endif /* inet_frag.h */