From: Florian Westphal <fw@strlen•de>
To: Nicolas Dichtel <nicolas.dichtel@6wind•com>
Cc: Florian Westphal <fw@strlen•de>,
netdev@vger•kernel.org,
Steffen Klassert <steffen.klassert@secunet•com>
Subject: Re: [PATCH ipsec-next 6/8] xfrm: policy: only use rcu in xfrm_sk_policy_lookup
Date: Wed, 16 Nov 2016 18:30:28 +0100 [thread overview]
Message-ID: <20161116173028.GI30581@breakpoint.cc> (raw)
In-Reply-To: <0e235471-cb63-2376-c42d-5872e78e4c98@6wind.com>
Nicolas Dichtel <nicolas.dichtel@6wind•com> wrote:
> Le 11/08/2016 à 15:17, Florian Westphal a écrit :
> > Don't acquire the readlock anymore and rely on rcu alone.
> >
> > In case writer on other CPU changed policy at the wrong moment (after we
> > obtained sk policy pointer but before we could obtain the reference)
> > just repeat the lookup.
> >
> > Signed-off-by: Florian Westphal <fw@strlen•de>
> Since this patch, our IKEv1 Transport tests (using charon) fail to establish the
> connection. If I revert it, the IKE negociation is ok again.
> charon logs are enclosed.
>
> I didn't had time to investigate now, but any idea is welcomed ;-)
I'm an idiot. Thanks for figuring out the faulty commit!
This should fix it (if we succeed grabbing the refcount, then if (err && !xfrm_pol_hold_rcu
evaluates to false and we hit last else branch and set pol to ERR_PTR(0)...
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index fd6986634e6f..5bf7e1bfeac7 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
err = security_xfrm_policy_lookup(pol->security,
fl->flowi_secid,
policy_to_flow_dir(dir));
- if (!err && !xfrm_pol_hold_rcu(pol))
- goto again;
- else if (err == -ESRCH)
+ if (!err) {
+ if (!xfrm_pol_hold_rcu(pol))
+ goto again;
+ } else if (err == -ESRCH) {
pol = NULL;
- else
+ } else {
pol = ERR_PTR(err);
+ }
} else
next prev parent reply other threads:[~2016-11-16 17:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 13:17 Subject: [PATCH ipsec-next 0/8] xfrm: policy: convert lookups to rcu Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 1/8] xfrm: policy: use rcu versions for iteration and list add/del Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 2/8] xfrm: policy: prepare policy_bydst hash for rcu lookups Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 3/8] xfrm: policy: add sequence count to sync with hash resize Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 4/8] xfrm: policy: use atomic_inc_not_zero in rcu section Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 5/8] xfrm: policy: make xfrm_policy_lookup_bytype lockless Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 6/8] xfrm: policy: only use rcu in xfrm_sk_policy_lookup Florian Westphal
2016-11-16 16:43 ` Nicolas Dichtel
2016-11-16 17:30 ` Florian Westphal [this message]
2016-11-17 8:55 ` Nicolas Dichtel
2016-08-11 13:17 ` [PATCH ipsec-next 7/8] xfrm: policy: don't acquire policy lock in xfrm_spd_getinfo Florian Westphal
2016-08-11 13:17 ` [PATCH ipsec-next 8/8] xfrm: policy: convert policy_lock to spinlock Florian Westphal
2016-08-24 11:28 ` Steffen Klassert
2016-08-24 11:30 ` Florian Westphal
2016-08-12 8:22 ` Subject: [PATCH ipsec-next 0/8] xfrm: policy: convert lookups to rcu Steffen Klassert
2016-08-22 5:15 ` Steffen Klassert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161116173028.GI30581@breakpoint.cc \
--to=fw@strlen$(echo .)de \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.dichtel@6wind$(echo .)com \
--cc=steffen.klassert@secunet$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox