From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH] ipv6: Fix problem with expired dst cache Date: Fri, 24 Feb 2012 07:51:08 +0100 Message-ID: <1330066268.15610.48.camel@edumazet-laptop> References: <1330064404-24763-1-git-send-email-gaofeng@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: davem@davemloft.net, netdev@vger.kernel.org To: Gao feng Return-path: Received: from mail-we0-f174.google.com ([74.125.82.174]:49280 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266Ab2BXGvS (ORCPT ); Fri, 24 Feb 2012 01:51:18 -0500 Received: by werb13 with SMTP id b13so1226773wer.19 for ; Thu, 23 Feb 2012 22:51:16 -0800 (PST) In-Reply-To: <1330064404-24763-1-git-send-email-gaofeng@cn.fujitsu.com> Sender: netdev-owner@vger.kernel.org List-ID: Le vendredi 24 f=C3=A9vrier 2012 =C3=A0 14:20 +0800, Gao feng a =C3=A9c= rit : > if the ipv6 dst cache copy from the dst witch generated by ICMPV6 RA = packet. > this dst cache will not be checked expire because it has no RTF_EXPIR= ES flag > So this dst cache always be used until the dst gc run. >=20 > add a pointer in struct rt6_info,point to where the dst cache copy fr= om. > in func rt6_check_expired check if rt6->info->rt6i_copy is expired. >=20 Sorry, I really dont understand what you are saying. Also, adding a pointer to a structure without holding a reference on it is suspicious. > Signed-off-by: Gao feng > --- > include/net/ip6_fib.h | 1 + > net/ipv6/route.c | 16 ++++++++++++++-- > 2 files changed, 15 insertions(+), 2 deletions(-) >=20 > diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h > index b26bb81..3da4d58c 100644 > --- a/include/net/ip6_fib.h > +++ b/include/net/ip6_fib.h > @@ -106,6 +106,7 @@ struct rt6_info { > u32 rt6i_metric; > u32 rt6i_peer_genid; > =20 > + struct rt6_info *rt6i_copy; > struct inet6_dev *rt6i_idev; > struct inet_peer *rt6i_peer; > =20 > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index 8c2e3ab..939d06a 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -316,8 +316,15 @@ static void ip6_dst_ifdown(struct dst_entry *dst= , struct net_device *dev, > =20 > static __inline__ int rt6_check_expired(const struct rt6_info *rt) > { > - return (rt->rt6i_flags & RTF_EXPIRES) && > - time_after(jiffies, rt->dst.expires); > + if ((rt->rt6i_flags & RTF_EXPIRES) && > + time_after(jiffies, rt->dst.expires)) > + return 1; > + > + if (rt->rt6i_copy && (rt->rt6i_copy->rt6i_flags & RTF_EXPIRES) && > + time_after(jiffies, rt->rt6i_copy->dst.expires)) > + return 1; > + > + return 0; > } > =20 > static inline int rt6_need_strict(const struct in6_addr *daddr) > @@ -1804,6 +1811,11 @@ static struct rt6_info *ip6_rt_copy(const stru= ct rt6_info *ort, > rt->rt6i_gateway =3D ort->rt6i_gateway; > rt->rt6i_flags =3D ort->rt6i_flags & ~RTF_EXPIRES; > rt->rt6i_metric =3D 0; > + > + if (ort->rt6i_copy) > + rt->rt6i_copy =3D ort->rt6i_copy; > + else > + rt->rt6i_copy =3D ort; > =20 > #ifdef CONFIG_IPV6_SUBTREES > memcpy(&rt->rt6i_src, &ort->rt6i_src, sizeof(struct rt6key));