return f->hashfn(q) & (INETFRAGS_HASHSZ - 1);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
static bool inet_frag_may_rebuild(struct inet_frags *f)
{
return time_after(jiffies,
{
int i;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
INIT_WORK(&f->frags_work, inet_frag_worker);
#endif
INIT_HLIST_HEAD(&hb->chain);
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
- rwlock_init(&f->lock);
- f->secret_timer.expires = jiffies + f->secret_interval;
-#else
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
seqlock_init(&f->rnd_seqlock);
f->last_rebuild_jiffies = 0;
f->frags_cachep = kmem_cache_create(f->frags_cache_name, f->qsize, 0, 0,
NULL);
if (!f->frags_cachep)
return -ENOMEM;
+#else
+ rwlock_init(&f->lock);
+ f->secret_timer.expires = jiffies + f->secret_interval;
#endif
return 0;
void inet_frags_fini(struct inet_frags *f)
{
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
cancel_work_sync(&f->frags_work);
kmem_cache_destroy(f->frags_cachep);
#endif
int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
-void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
-{
- read_lock_bh(&f->lock);
- inet_frag_evictor(nf, f, true);
- read_unlock_bh(&f->lock);
-}
-#else
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
{
unsigned int seq;
percpu_counter_sum(&nf->mem))
goto evict_again;
}
+#else
+void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
+{
+ read_lock_bh(&f->lock);
+ inet_frag_evictor(nf, f, true);
+ read_unlock_bh(&f->lock);
+}
#endif
static struct inet_frag_bucket *
if (f->destructor)
f->destructor(q);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
- kfree(q);
-#else
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
kmem_cache_free(f->frags_cachep, q);
+#else
+ kfree(q);
#endif
sub_frag_mem_limit(nf, sum);
int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
+ int i;
+
+ for (i = 0; i < INETFRAGS_HASHSZ ; i++)
+ inet_evict_bucket(f, &f->hash[i]);
+
+ return 0;
+#else
struct inet_frag_queue *q;
int work, evicted = 0;
}
return evicted;
-#else
- int i;
-
- for (i = 0; i < INETFRAGS_HASHSZ ; i++)
- inet_evict_bucket(f, &f->hash[i]);
-
- return 0;
#endif
}
struct inet_frag_queue *q;
if (frag_mem_limit(nf) > nf->high_thresh) {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
inet_frag_schedule_worker(f);
#endif
return NULL;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
- q = kzalloc(f->qsize, GFP_ATOMIC);
-#else
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
q = kmem_cache_zalloc(f->frags_cachep, GFP_ATOMIC);
+#else
+ q = kzalloc(f->qsize, GFP_ATOMIC);
#endif
if (!q)
return NULL;
struct inet_frag_queue *q;
int depth = 0;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
- if (frag_mem_limit(nf) > nf->high_thresh)
- inet_frag_evictor(nf, f, false);
-#else
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
if (frag_mem_limit(nf) > nf->low_thresh)
inet_frag_schedule_worker(f);
+#else
+ if (frag_mem_limit(nf) > nf->high_thresh)
+ inet_frag_evictor(nf, f, false);
#endif
hash &= (INETFRAGS_HASHSZ - 1);
if (depth <= INETFRAGS_MAXDEPTH)
return inet_frag_create(nf, f, key);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_FRAGS_WORK
if (inet_frag_may_rebuild(f)) {
if (!f->rebuild)
f->rebuild = true;