netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Gao feng <gaofeng@cn.fujitsu.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
	Jiri Bohac <jbohac@suse.cz>
Subject: Re: [RFC PATCH] ipv6: Split from and expires field in dst_entry out of union [net-next]
Date: Wed, 20 Feb 2013 19:02:42 +0900	[thread overview]
Message-ID: <51249F42.3030908@linux-ipv6.org> (raw)
In-Reply-To: <1361343610.19353.177.camel@edumazet-glaptop>

Eric Dumazet wrote:
> On Wed, 2013-02-20 at 14:33 +0800, Gao feng wrote:
> 
>> How can we?
>> one usage of rt6_update_expires and rt6_set_expires
>> is changing rt6->dst.from to rt6->dst.expires, we should release the
>> already holded reference of rt6->dst.from.
>>
> 
> Just don't union the two fields, as Neil did.
> 
> Setting the dst.expires value should not change dst.from at all.
> 
> Something like the (untested, because its too late here) patch ?
> 
>  include/net/dst.h     |   11 +++++------
>  include/net/ip6_fib.h |   21 +++------------------
>  net/ipv6/route.c      |    3 +--
>  3 files changed, 9 insertions(+), 26 deletions(-)
> 
> diff --git a/include/net/dst.h b/include/net/dst.h
> index 3da47e0..3f31a48 100644
> --- a/include/net/dst.h
> +++ b/include/net/dst.h
> @@ -36,13 +36,12 @@ struct dst_entry {
>  	struct net_device       *dev;
>  	struct  dst_ops	        *ops;
>  	unsigned long		_metrics;
> -	union {
> -		unsigned long           expires;
> -		/* point to where the dst_entry copied from */
> -		struct dst_entry        *from;
> -	};
> +	unsigned long           expires;
> +
> +	/* point to where the dst_entry copied from */
> +	struct dst_entry        *from;
> +
>  	struct dst_entry	*path;
> -	void			*__pad0;
>  #ifdef CONFIG_XFRM
>  	struct xfrm_state	*xfrm;
>  #else

Initialize "from" in dst_alloc().

> @@ -199,13 +185,12 @@ static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
>  {
>  	struct dst_entry *new = (struct dst_entry *) from;
>  
> -	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) {
> +	if (rt->dst.from) {
>  		if (new == rt->dst.from)
>  			return;
>  		dst_release(rt->dst.from);
>  	}
>  
> -	rt->rt6i_flags &= ~RTF_EXPIRES;
>  	rt->dst.from = new;
>  	dst_hold(new);
>  }

rt6_set_from can work only for fresh entries.

In fact, I have very similar patch.

--yoshfuji

  parent reply	other threads:[~2013-02-20 10:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 23:55 [RFC] ipv6: rt6_update_expires() seems racy Eric Dumazet
2013-02-19 20:28 ` [RFC PATCH] ipv6: Split from and expires field in dst_entry out of union [net-next] Neil Horman
2013-02-19 21:17   ` Eric Dumazet
2013-02-19 21:49     ` Neil Horman
2013-02-19 21:55       ` Eric Dumazet
2013-02-20  6:33         ` Gao feng
2013-02-20  7:00           ` Eric Dumazet
2013-02-20  9:31             ` Gao feng
2013-02-20 10:02             ` YOSHIFUJI Hideaki [this message]
2013-02-20 10:17               ` [PATCH] ipv6: fix race condition regarding dst->expires and dst->from YOSHIFUJI Hideaki
2013-02-20 10:25                 ` YOSHIFUJI Hideaki
2013-02-20 10:29                   ` [PATCH V2] " YOSHIFUJI Hideaki
2013-02-20 16:12                     ` Eric Dumazet
2013-02-20 16:34                       ` Neil Horman
2013-02-20 20:12                     ` David Miller
2013-02-20 10:55   ` [RFC PATCH] ipv6: Split from and expires field in dst_entry out of union [net-next] David Laight
2013-02-20 12:02     ` Neil Horman
2013-02-20 12:08       ` David Laight

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=51249F42.3030908@linux-ipv6.org \
    --to=yoshfuji@linux-ipv6.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=gaofeng@cn.fujitsu.com \
    --cc=jbohac@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).