Skip to contentSkip to conversation

ipv6: fix inconsistent prefix route handling

PATCH Superseded Steven Barth 2 participants 8 messages Feb 16, 2014 – Feb 17, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: fix inconsistent prefix route handling

When temporary addresses are created in userspace an accompanying on-link prefix-route is created alongside. However when said address is afterwards removed in userspace the respective prefix route remains until it expires. Similarly when userspace turns a permanent address into a temporary one the prefix route remains and is not removed when the address expires and is thus dangling until removed manually.

This behavior is inconsistent with the addition and removal of permanent addresses and can potentially cause lots of dangling routes on downstream interfaces on an IPv6-router with changing prefixes.

This patch runs the on-link prefix removal check also when a temporary address is removed and thus unifies the prefix route handling.

---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/addrconf.c +1 -0
index ad23569..55c35d5 100644
@@ -1013,7 +1013,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 		__in6_ifa_put(ifp);
 	}
 -	if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE))
+	if (!(ifp->flags & IFA_F_NOPREFIXROUTE))
 		action = check_cleanup_prefix_route(ifp, &expires);
  	list_del_init(&ifp->if_list);
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/1 ipv6: fix inconsistent prefix route handling

When temporary addresses are created in userspace an accompanying on-link prefix-route is created alongside. However when said address is afterwards removed in userspace the respective prefix route remains until it expires. Similarly when userspace turns a permanent address into a temporary one the prefix route remains and is not removed when the address expires and is thus dangling until removed manually.

This behavior is inconsistent with the addition and removal of permanent addresses and can potentially cause lots of dangling routes on downstream interfaces on an IPv6-router with changing prefixes.

This patch runs the on-link prefix removal check also when a temporary address is removed and thus unifies the prefix route handling.

---
 net/ipv6/addrconf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/addrconf.c +1 -1
index ad23569..55c35d5 100644
@@ -1013,7 +1013,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
 		__in6_ifa_put(ifp);
 	}
 
-	if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE))
+	if (!(ifp->flags & IFA_F_NOPREFIXROUTE))
 		action = check_cleanup_prefix_route(ifp, &expires);
 
 	list_del_init(&ifp->if_list);
Signature · 1 line
1.8.3.2
#2 lore raw

net/ipv6/addrconf.c static void ipv6_del_addr(struct inet6_ifaddr *ifp) · line 1017

Quoted 3 lines · Steven Barth
net/ipv6/addrconf.c +1 -1
-	if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE))
+	if (!(ifp->flags & IFA_F_NOPREFIXROUTE))
 		action = check_cleanup_prefix_route(ifp, &expires);

This could too easily clean up valid on-link information if the address just happens to be in the same subnet. Would (ifp-flags & (IFA_F_PERMANENET|IFA_F_TEMPORARY) && !(...)) solve the problem, too?

Greetings,

Hannes

#3 lore raw
Quoted 3 lines · Hannes Frederic Sowa

This could too easily clean up valid on-link information if the address just happens to be in the same subnet. Would (ifp-flags & (IFA_F_PERMANENET|IFA_F_TEMPORARY) && !(...)) solve the problem, too?

No, that doesn't do the trick unfortunately. Seems that the (non-permanent) address created by "ip" don't have IFA_F_TEMPORARY set. Any other good ideas?

Cheers,

Steven

#4 lore raw
Quoted 8 lines · Steven Barth
Quoted 3 lines · Hannes Frederic Sowa

This could too easily clean up valid on-link information if the address just happens to be in the same subnet. Would (ifp-flags & (IFA_F_PERMANENET|IFA_F_TEMPORARY) && !(...)) solve the problem, too?

No, that doesn't do the trick unfortunately. Seems that the (non-permanent) address created by "ip" don't have IFA_F_TEMPORARY set. Any other good ideas?

We are talking about managed temp addresses, no? What ip command do you use?

Bye,

Hannes

#5 lore raw

Ah sorry, maybe I was a bit unclear about this. With temporary addresses I meant addresses created like this:

ip address add 2001:db8::1/64 dev eth0 valid_lft 1234 preferred_lft 1001

or the equivalent netlink-calls and with permanent addresses i was referring to addresses created similarly but with an infinite lifetime (e.g. through ip without giving valid_lft or preferred_lft arguments).

Hope that makes it clear.

Cheers,

Steven

Quoted 18 lines · Hannes Frederic Sowa
Quoted 7 lines · Steven Barth
Quoted 3 lines · Hannes Frederic Sowa

This could too easily clean up valid on-link information if the address just happens to be in the same subnet. Would (ifp-flags & (IFA_F_PERMANENET|IFA_F_TEMPORARY) && !(...)) solve the problem, too?

No, that doesn't do the trick unfortunately. Seems that the (non-permanent) address created by "ip" don't have IFA_F_TEMPORARY set. Any other good ideas?

We are talking about managed temp addresses, no? What ip command do you use?

Bye,

Hannes

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 10 lines · Steven Barth

Ah sorry, maybe I was a bit unclear about this. With temporary addresses I meant addresses created like this:

ip address add 2001:db8::1/64 dev eth0 valid_lft 1234 preferred_lft 1001

or the equivalent netlink-calls and with permanent addresses i was referring to addresses created similarly but with an infinite lifetime (e.g. through ip without giving valid_lft or preferred_lft arguments).

Hope that makes it clear.

Yes, makes sense, thanks!

I fear there is currently no combination of ifp->flags which can test for that. Your first patch seems to be too dangerous in removing neighbour discovery brought in on-link state, I fear. It may even be a problem for permanent ones, but that's how it is done, currently.

Best option would be to fully decouple prefix routes from address handling, but that would break current userspace.

Current iproute has support for no-prefix-route address addition (see iproute2 commit 58c69b226fb3a ("add support for IFA_F_NOPREFIXROUTE")), so you could manage those address and route combination directly from user space.

So if we want to clean up those routes we either must set IFA_F_PERMANENT to the ifp flags of the address in inet6_addr_add and really make sure nothing breaks because of this. Or introduce a new flag, like IFA_F_USERINSTALLED e.g.

Current ifp flags handling is really complex and we had some bad bugs in recent changes, so I guess, it is not a trivial task (I reviewed the last patches changing code in that for hours and they still had bugs :/), so I am unsure what is the right approach. Both ways (adding PERMANENT) and adding a new IFP_P_USERINSTALLED would need to be considered and reviewed.

Thanks,

Hannes

#7 lore raw
Quoted 5 lines · Hannes Frederic Sowa

I fear there is currently no combination of ifp->flags which can test for that. Your first patch seems to be too dangerous in removing neighbour discovery brought in on-link state, I fear. It may even be a problem for permanent ones, but that's how it is done, currently.

Yeah the kernel neighbor discovery support is a bit tricky in itself and I found myself working around it more often then actually using it (at least when doing router-stuff).

Quoted 7 lines

Best option would be to fully decouple prefix routes from address handling, but that would break current userspace.

Current iproute has support for no-prefix-route address addition (see iproute2 commit 58c69b226fb3a ("add support for IFA_F_NOPREFIXROUTE")), so you could manage those address and route combination directly from user space.

OK, I will use a workaround for now that removes and readds addresses when they should be deprecated instead of just converting permanents to non-permanents and maybe later use that new NOPREFIXROUTE feature which should come in handy.

Quoted 4 lines

So if we want to clean up those routes we either must set IFA_F_PERMANENT to the ifp flags of the address in inet6_addr_add and really make sure nothing breaks because of this. Or introduce a new flag, like IFA_F_USERINSTALLED e.g.

OK, I will try to think about this when I have some more time to spare on this. Thanks for your help so far.

Steven