compat: Detect and use upstream ip_fragment().
[cascardo/ovs.git] / datapath / linux / compat / inet_fragment.c
index 741a055..10db99f 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <linux/version.h>
 
-#ifdef OVS_FRAGMENT_BACKPORT
+#if !defined(HAVE_CORRECT_MRU_HANDLING) && defined(OVS_FRAGMENT_BACKPORT)
 
 #include <linux/list.h>
 #include <linux/spinlock.h>
@@ -130,7 +130,7 @@ static bool inet_fragq_should_evict(const struct inet_frag_queue *q)
 static unsigned int
 inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb)
 {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
+#ifndef HAVE_INET_FRAG_QUEUE_WITH_LIST_EVICTOR
        struct ovs_inet_frag_queue *ofq;
 #endif
        struct inet_frag_queue *fq;
@@ -147,23 +147,23 @@ inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb)
                if (!del_timer(&fq->timer))
                        continue;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
+#ifdef HAVE_INET_FRAG_QUEUE_WITH_LIST_EVICTOR
+               hlist_add_head(&fq->list_evictor, &expired);
+#else
                ofq = (struct ovs_inet_frag_queue *)fq;
                hlist_add_head(&ofq->list_evictor, &expired);
-#else
-               hlist_add_head(&fq->list_evictor, &expired);
 #endif
                ++evicted;
        }
 
        spin_unlock(&hb->chain_lock);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0)
-       hlist_for_each_entry_safe(ofq, n, &expired, list_evictor)
-               f->frag_expire((unsigned long) &ofq->fq);
-#else
+#ifdef HAVE_INET_FRAG_QUEUE_WITH_LIST_EVICTOR
        hlist_for_each_entry_safe(fq, n, &expired, list_evictor)
                f->frag_expire((unsigned long) fq);
+#else
+       hlist_for_each_entry_safe(ofq, n, &expired, list_evictor)
+               f->frag_expire((unsigned long) &ofq->fq);
 #endif
 
        return evicted;
@@ -557,4 +557,4 @@ void inet_frag_maybe_warn_overflow(struct inet_frag_queue *q,
                net_dbg_ratelimited("%s%s", prefix, msg);
 }
 
-#endif /* OVS_FRAGMENT_BACKPORT */
+#endif /* !HAVE_CORRECT_MRU_HANDLING && OVS_FRAGMENT_BACKPORT */