Skip to content

Commit

Permalink
compat: Detect and use inet_frags->lock.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
joestringer committed Feb 2, 2016
1 parent 1efdc8a commit 55764d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions acinclude.m4
Expand Up @@ -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])
Expand Down
14 changes: 7 additions & 7 deletions datapath/linux/compat/inet_fragment.c
Expand Up @@ -272,15 +272,15 @@ 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)
{
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;
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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
}
Expand Down Expand Up @@ -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;
Expand All @@ -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

Expand Down

0 comments on commit 55764d9

Please sign in to comment.