Subject: Re: [PATCH] ipv6: rework the lock in addrconf_permanent_addr

From: Sergei Shtylyov <[email-masked]>
Date: Fri, 8 Apr 2016 14:50:02 +0300

Hello.

On 4/8/2016 12:22 PM, [email-masked] wrote:

> From: Li RongQing <[email-masked]>
>
> 1. nothing of idev is changed, so read lock is enough
> 2. ifp is changed, so used ifp->lock or cmpxchg to protect it
>
> Signed-off-by: Li RongQing <[email-masked]>
> ---
>   net/ipv6/addrconf.c | 26 ++++++++++++++++++++------
>   1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 27aed1a..f6e7605b 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
[...]
> @@ -3212,7 +3221,12 @@ static int fixup_permanent_addr(struct inet6_dev *idev,
>   		if (unlikely(IS_ERR(rt)))
>   			return PTR_ERR(rt);
>
> -		ifp->rt = rt;
> +		prev = cmpxchg(&ifp->rt, NULL, rt);
> +
> +		/*if cmpxchg failed*/

    Please add spaces after /* and before */

> +		if (prev) {
> +			ip6_rt_put(rt);
> +		}

    {} not needed here, please remove.

[...]

MBR, Sergei