compat: Detect and use inet_frags->lock.
authorJoe Stringer <joe@ovn.org>
Thu, 24 Dec 2015 19:06:18 +0000 (11:06 -0800)
committerJoe Stringer <joe@ovn.org>
Tue, 2 Feb 2016 22:26:45 +0000 (14:26 -0800)
Prior to ab1c724f6330 ("inet: frag: use seqlock for hash rebuild")
upstream, a rwlock was used when rebuilding inet_frags. Rather than
using a version check to detect this, search for it in the header and
enable the code based on whether it exists.

Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
acinclude.m4
datapath/linux/compat/inet_fragment.c

index 3e44abb..41284ea 100644 (file)
@@ -357,6 +357,8 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
                   [OVS_DEFINE([HAVE_INET_FRAGS_LAST_IN])])
   OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frags],
                         [frags_work])
+  OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frags],
+                        [rwlock])
 
   OVS_GREP_IFELSE([$KSRC/include/net/dst_metadata.h], [metadata_dst])
 
index 15321de..741a055 100644 (file)
@@ -272,7 +272,7 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f)
 
 static struct inet_frag_bucket *
 get_frag_bucket_locked(struct inet_frag_queue *fq, struct inet_frags *f)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_RWLOCK
 __acquires(f->lock)
 #endif
 __acquires(hb->chain_lock)
@@ -280,7 +280,7 @@ __acquires(hb->chain_lock)
        struct inet_frag_bucket *hb;
        unsigned int hash;
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_RWLOCK
        read_lock(&f->lock);
 #else
        unsigned int seq;
@@ -293,7 +293,7 @@ __acquires(hb->chain_lock)
 
        spin_lock(&hb->chain_lock);
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
+#ifndef HAVE_INET_FRAGS_WITH_RWLOCK
        if (read_seqretry(&f->rnd_seqlock, seq)) {
                spin_unlock(&hb->chain_lock);
                goto restart;
@@ -304,7 +304,7 @@ __acquires(hb->chain_lock)
 }
 
 static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_RWLOCK
 __releases(f->lock)
 #endif
 __releases(hb->chain_lock)
@@ -316,7 +316,7 @@ __releases(hb->chain_lock)
        q_flags(fq) |= INET_FRAG_COMPLETE;
        spin_unlock(&hb->chain_lock);
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_RWLOCK
        read_unlock(&f->lock);
 #endif
 }
@@ -433,7 +433,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
                if (qp->net == nf && f->match(qp, arg)) {
                        atomic_inc(&qp->refcnt);
                        spin_unlock(&hb->chain_lock);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_RWLOCK
                        read_unlock(&f->lock);
 #endif
                        q_flags(qp_in) |= INET_FRAG_COMPLETE;
@@ -450,7 +450,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
        hlist_add_head(&qp->list, &hb->chain);
 
        spin_unlock(&hb->chain_lock);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
+#ifdef HAVE_INET_FRAGS_WITH_RWLOCK
        read_unlock(&f->lock);
 #endif