diff mbox

[RFC,06/10] ipv6: Avoid deleting RTF_CACHE route from ip6_route_del()

Message ID 1428717253-1006248-7-git-send-email-kafai@fb.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Martin KaFai Lau April 11, 2015, 1:54 a.m. UTC
Before patch 'Allow pmtu update on /128 via gateway route',
RTF_CACHE route was not created for DST_HOST.  It also requires changes on both
delete code path and rt6_select() code patch.

This patch fixes the delete code path to avoid deleting the RTF_CACHE
route by 'ip -6 r del...'

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 net/ipv6/route.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

David Miller April 20, 2015, 6:23 p.m. UTC | #1
From: Martin KaFai Lau <kafai@fb.com>
Date: Fri, 10 Apr 2015 18:54:09 -0700

> Before patch 'Allow pmtu update on /128 via gateway route',
> RTF_CACHE route was not created for DST_HOST.  It also requires changes on both
> delete code path and rt6_select() code patch.
> 
> This patch fixes the delete code path to avoid deleting the RTF_CACHE
> route by 'ip -6 r del...'
> 
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

If a cached route was created in response to say a PMTU event, and
it's a clone/copy/cow of the route we are being asked to delete,
it absolutely should be removed.

In fact this is a critically important aspect of removing routes
from the table.

So this change does not seem correct.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin KaFai Lau April 20, 2015, 7:33 p.m. UTC | #2
On Mon, Apr 20, 2015 at 02:23:05PM -0400, David Miller wrote:
> From: Martin KaFai Lau <kafai@fb.com>
> Date: Fri, 10 Apr 2015 18:54:09 -0700
> 
> > Before patch 'Allow pmtu update on /128 via gateway route',
> > RTF_CACHE route was not created for DST_HOST.  It also requires changes on both
> > delete code path and rt6_select() code patch.
> > 
> > This patch fixes the delete code path to avoid deleting the RTF_CACHE
> > route by 'ip -6 r del...'
> > 
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> 
> If a cached route was created in response to say a PMTU event, and
> it's a clone/copy/cow of the route we are being asked to delete,
> it absolutely should be removed.
> 
> In fact this is a critically important aspect of removing routes
> from the table.
When a non-clone routes are removed, its clones are removed together by
fib6_prune_clones() in fib6_del().

Hence, 'ip -6 r del' will remove a route and its clones.
'ip -6 r flush table cache will only remove RTF_CACHE routes.

I will fix up the commit message.

Thanks,
--Martin
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller April 20, 2015, 7:37 p.m. UTC | #3
From: Martin KaFai Lau <kafai@fb.com>
Date: Mon, 20 Apr 2015 12:33:05 -0700

> On Mon, Apr 20, 2015 at 02:23:05PM -0400, David Miller wrote:
>> From: Martin KaFai Lau <kafai@fb.com>
>> Date: Fri, 10 Apr 2015 18:54:09 -0700
>> 
>> > Before patch 'Allow pmtu update on /128 via gateway route',
>> > RTF_CACHE route was not created for DST_HOST.  It also requires changes on both
>> > delete code path and rt6_select() code patch.
>> > 
>> > This patch fixes the delete code path to avoid deleting the RTF_CACHE
>> > route by 'ip -6 r del...'
>> > 
>> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
>> > Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
>> 
>> If a cached route was created in response to say a PMTU event, and
>> it's a clone/copy/cow of the route we are being asked to delete,
>> it absolutely should be removed.
>> 
>> In fact this is a critically important aspect of removing routes
>> from the table.
> When a non-clone routes are removed, its clones are removed together by
> fib6_prune_clones() in fib6_del().
> 
> Hence, 'ip -6 r del' will remove a route and its clones.
> 'ip -6 r flush table cache will only remove RTF_CACHE routes.
> 
> I will fix up the commit message.

Ok, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 75f3b5d..5d0fd6c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1780,6 +1780,9 @@  static int ip6_route_del(struct fib6_config *cfg)
 
 	if (fn) {
 		for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) {
+			if ((rt->rt6i_flags & RTF_CACHE) &&
+			    !(cfg->fc_flags & RTF_CACHE))
+				continue;
 			if (cfg->fc_ifindex &&
 			    (!rt->dst.dev ||
 			     rt->dst.dev->ifindex != cfg->fc_ifindex))
@@ -2424,6 +2427,9 @@  static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 	if (rtm->rtm_type == RTN_LOCAL)
 		cfg->fc_flags |= RTF_LOCAL;
 
+	if (rtm->rtm_flags & RTM_F_CLONED)
+		cfg->fc_flags |= RTF_CACHE;
+
 	cfg->fc_nlinfo.portid = NETLINK_CB(skb).portid;
 	cfg->fc_nlinfo.nlh = nlh;
 	cfg->fc_nlinfo.nl_net = sock_net(skb->sk);