From: Gao feng <gaofeng@cn.fujitsu.com>
To: Sabrina Dubroca <sd@queasysnail.net>,
netdev@vger.kernel.org,
Hannes Frederic Sowa <hannes@stressinduktion.org>
Subject: Re: [RFC PATCH net] IPv6: Fix broken IPv6 routing table after loopback down-up
Date: Thu, 23 Jan 2014 08:56:37 +0800 [thread overview]
Message-ID: <52E068C5.2050405@cn.fujitsu.com> (raw)
In-Reply-To: <20140122213446.GD7269@order.stressinduktion.org>
On 01/23/2014 05:34 AM, Hannes Frederic Sowa wrote:
> On Wed, Jan 22, 2014 at 04:35:08PM +0100, Sabrina Dubroca wrote:
>> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>> index 4b6b720..b2eb653 100644
>> --- a/net/ipv6/addrconf.c
>> +++ b/net/ipv6/addrconf.c
>> @@ -2578,6 +2578,23 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
>> }
>> #endif
>>
>> +struct rt6_info *addrconf_dst_alloc_once(struct inet6_dev *idev,
>> + const struct in6_addr *addr,
>> + bool anycast)
>> +{
>> + struct net *net = dev_net(idev->dev);
>> + struct rt6_info *rt = rt6_lookup(net, addr, NULL, 0, 0);
>
> We should use addrconf_get_prefix_route here. Eric's comment applies
> here, too, we do a dst_hold in addrconf_get_prefix_route and thus must
> decrease the reference counter with ip6_rt_put then, too.
>
>> + if (rt == NULL)
>> + return addrconf_dst_alloc(idev, addr, anycast);
>> + else if (!(rt->rt6i_flags & RTF_NONEXTHOP &&
>> + ((anycast && rt->rt6i_flags & RTF_ANYCAST) ||
>> + (!anycast && rt->rt6i_flags & RTF_LOCAL))))
>> + return addrconf_dst_alloc(idev, addr, anycast);
>
> The necessary flags can be given to addrconf_get_prefix_route, then.
>
>> + return ERR_PTR(-EEXIST);
>> +}
>> +
>> static void init_loopback(struct net_device *dev)
>> {
>> struct inet6_dev *idev;
>> @@ -2611,10 +2628,7 @@ static void init_loopback(struct net_device *dev)
>> if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
>> continue;
>>
>> - if (sp_ifa->rt)
>> - continue;
>
> We should try to clean sp_ifa->rt on ifdown so we don't have dangling
> pointer to it if it is already in dst gc queue and obsolete. So even if
> we leave this code in there we would never hit the continue (it seems we
> have to decrease the reference counter in addrconf_ifdown before setting
> sp_ifa->rt to NULL).
>
>> -
>> - sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, false);
>> + sp_rt = addrconf_dst_alloc_once(idev, &sp_ifa->addr, false);
>>
>> /* Failure cases are ignored */
>> if (!IS_ERR(sp_rt)) {
>
> I am fine if we get this fix in for 3.14 because it solves a real problem.
> I'll already work on the full route preserving logic on ifdown/up and
> would build this on this patch then.
>
> I currently wonder if we need the relookup logic at all as we currently
> remove the prefix routes in all cases (in rt6_ifdown, which iterates
> over all routing tables). So we always have a obsolete dst which we
> just need to clean up in addrconf_ifdown and just allocate the prefix
> route in init_loopback in all cases. We just have to steal some code
> from inet6_rtm_newaddr to calculate the appropriate flags from the
> inet6_ifaddr's ifa_flags (e.g. RTF_EXPIRES).
>
I still prefer the patch I send before. I don't like the rt6i_flags,
it is not clear and easy to misunderstand.
But if you all think this one is good, I'm ok, but I don't have enough
time to review it deeply.
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 1a341f7..4dca886 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2610,8 +2610,16 @@ static void init_loopback(struct net_device *dev)
if (sp_ifa->flags & (IFA_F_DADFAILED | IFA_F_TENTATIVE))
continue;
- if (sp_ifa->rt)
- continue;
+ if (sp_ifa->rt) {
+ /* This dst has been added to garbage list when
+ * lo device down, delete this obsolete dst and
+ * reallocate new router for ifa. */
+ if (sp_ifa->rt->dst.obsolete > 0) {
+ ip6_del_rt(sp_ifa->rt);
+ sp_ifa->rt = NULL;
+ } else
+ continue;
+ }
sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, false);
next prev parent reply other threads:[~2014-01-23 0:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-22 15:35 [RFC PATCH net] IPv6: Fix broken IPv6 routing table after loopback down-up Sabrina Dubroca
2014-01-22 16:20 ` Eric Dumazet
2014-01-22 21:34 ` Hannes Frederic Sowa
2014-01-23 0:56 ` Gao feng [this message]
2014-01-23 1:01 ` Hannes Frederic Sowa
2014-01-23 6:23 ` Gao feng
2014-01-23 14:11 ` Hannes Frederic Sowa
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=52E068C5.2050405@cn.fujitsu.com \
--to=gaofeng@cn.fujitsu.com \
--cc=hannes@stressinduktion.org \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.