netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gao feng <gaofeng@cn.fujitsu.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH v3] ipv6: Fix problem with expired dst cache
Date: Thu, 01 Mar 2012 08:43:20 +0800	[thread overview]
Message-ID: <4F4EC628.1030402@cn.fujitsu.com> (raw)
In-Reply-To: <1330517659.2610.31.camel@edumazet-laptop>

Hi Eric:

于 2012年02月29日 20:14, Eric Dumazet 写道:
> Le mercredi 29 février 2012 à 18:07 +0800, Gao feng a écrit :

>> diff --git a/include/net/dst.h b/include/net/dst.h
>> index 344c8dd..5147839 100644
>> --- a/include/net/dst.h
>> +++ b/include/net/dst.h
>> @@ -35,7 +35,16 @@ struct dst_entry {
>>  	struct net_device       *dev;
>>  	struct  dst_ops	        *ops;
>>  	unsigned long		_metrics;
>> -	unsigned long		expires;
>> +
>> +	union {
>> +		unsigned long		expires;
>> +		/*
>> +		 * from is used only for dst cache witch copy form
> 
> 
>> +		 * the dst generated by ipv6 RA.
>> +		 * from is set only when rt6_info has no RTF_EXPIRES flag.
> 
> 
> I am not an english native but really this comment should be reworded...
> 

Sorry...I will reworded it.
> 
>> +		 */
>> +		void			*from;
>> +	};
>>  	struct dst_entry	*path;
>>  	struct neighbour __rcu	*_neighbour;
>>  #ifdef CONFIG_XFRM
>> diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
>> index b26bb81..86cf1ac 100644
>> --- a/include/net/ip6_fib.h
>> +++ b/include/net/ip6_fib.h
>> @@ -123,6 +123,47 @@ static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
>>  	return ((struct rt6_info *)dst)->rt6i_idev;
>>  }
>>  
>> +static inline void rt6_clean_expires(struct rt6_info *rt)
>> +{
>> +	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
>> +		dst_release(&rt->dst);
>> +
>> +	rt->rt6i_flags &= ~RTF_EXPIRES;
>> +	rt->dst.expires = 0;
>> +}
>> +
>> +static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires)
>> +{
>> +	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
>> +		dst_release(&rt->dst);
>> +
>> +	rt->rt6i_flags |= RTF_EXPIRES;
>> +	rt->dst.expires = expires;
>> +}
>> +
>> +static inline void rt6_update_expires(struct rt6_info *rt, int timeout)
>> +{
>> +	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from)
>> +		dst_release(&rt->dst);
>> +
>> +	dst_set_expires(&rt->dst, timeout);
>> +	rt->rt6i_flags |= RTF_EXPIRES;
>> +}
> 
> why rt6_update_expires() takes an "int timeout", promoted to "unsigned
> long expires" ? Do you have a 32bit machine by any chance ?

Because dst_set_expires takes an "int timeout".
rt6_update_expires provides an interface to change rt->rt6i_flags and rt->dst.expires together.
Just like rt6_clean_expires,rt6_set_expires...

> 
> Why is it needed at all, it seems rt6_update_expires() is redundant with
> dst_set_expires()
> 
>> +
>> +static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from)
>> +{
>> +	if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) {
>> +		if (from == rt->dst.from)
>> +			return;
> 
> after a "return;" you dont need an "else" 
> 
>> +		else
>> +			dst_release((struct dst_entry *) &rt->dst.from);
> 
> Really this cast hides a real bug... Was this patch tested ?
> 

I am very sorry for this,it's my fault.

>> +	}
>> +
>> +	rt->rt6i_flags &= ~RTF_EXPIRES;
>> +	rt->dst.from = (void *) from;
>> +	dst_hold(&from->dst);
> 
> You hold a reference on the "from" dst, which is fine, but some previous
> releases are done on dst_release(&rt->dst). So you dont release the
> right dst and bad things happen.
> 
> I am not really convinced by this patch, too many issues in it.
> 
> Please take the time to make sure you submit a nice one on your next
> submission. This part of the code is complex and need top quality
> patches.
> 


Thanks Eric,I will change this patch carefully,and resend it after test.

  reply	other threads:[~2012-03-01  0:42 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24  6:20 [PATCH] ipv6: Fix problem with expired dst cache Gao feng
2012-02-24  6:47 ` David Miller
2012-02-24  7:10   ` Gao feng
2012-02-24  9:27   ` Gao feng
2012-02-24  6:51 ` Eric Dumazet
2012-02-24  7:21   ` Gao feng
2012-02-27  6:36 ` [PATCH V2] " Gao feng
2012-02-29  9:26   ` Gao feng
2012-02-29  9:45     ` [PATCH] " Gao feng
2012-02-29  9:52       ` Gao feng
2012-02-29 10:07     ` [PATCH v3] " Gao feng
2012-02-29 12:14       ` Eric Dumazet
2012-03-01  0:43         ` Gao feng [this message]
2012-03-05  3:53 ` [PATCH v4] " Gao feng
2012-03-05  5:05   ` David Miller
2012-03-05  7:10     ` Gao feng
2012-03-05  7:16 ` [PATCH v5] " Gao feng
2012-03-06  7:01   ` RongQing Li
2012-03-06  7:10     ` RongQing Li
2012-03-17  5:33   ` David Miller
2012-03-19  0:49     ` Gao feng
2012-03-22  2:47       ` David Miller
2012-04-06 10:13 ` [PATCH v6] ipv6: fix " Gao feng
2012-04-13 16:58   ` David Miller
2012-04-16 13:34     ` [PATCH] ipv6: fix rt6_update_expires Jiri Bohac
2012-04-18  2:24       ` Gao feng
2012-04-18  2:32         ` David Miller
2012-04-16 13:35     ` [PATCH] ipv6: clean up rt6_clean_expires Jiri Bohac
2012-04-18  2:32       ` David Miller

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=4F4EC628.1030402@cn.fujitsu.com \
    --to=gaofeng@cn.fujitsu.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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).