* [PATCH v2] ipv6: Reparent temporary address(es) if global address was, deleted from userspace
@ 2014-04-07 5:43 Heiner Kallweit
2014-04-07 10:22 ` Hannes Frederic Sowa
0 siblings, 1 reply; 3+ messages in thread
From: Heiner Kallweit @ 2014-04-07 5:43 UTC (permalink / raw)
To: netdev@vger.kernel.org
If the kernel takes care of global and temporary addresses it can happen
that the global address is deleted from userspace,
e.g. by network managers in case the link goes (temporarily) down.
In addition to the then orphaned temporary address(es) the next RA will
create a new temporary address. Therefore we might end up with more than
one non-deprecated temporary address for the same prefix for a longer
period of time (>regen_advance). According to RfC4941 sect. 3.4 this
should not happen.
Fix this by reparenting orphaned temporary addresses.
v2: style fixes
Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>
---
net/ipv6/addrconf.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6c7fa08..8072968 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2077,14 +2077,33 @@ static void manage_tempaddrs(struct inet6_dev *idev,
{
u32 flags;
struct inet6_ifaddr *ift;
+ unsigned long regen_advance;
read_lock_bh(&idev->lock);
+ regen_advance = idev->cnf.regen_max_retry *
+ idev->cnf.dad_transmits *
+ NEIGH_VAR(idev->nd_parms, RETRANS_TIME) / HZ;
/* update all temporary addresses in the list */
list_for_each_entry(ift, &idev->tempaddr_list, tmp_list) {
int age, max_valid, max_prefered;
+ bool reparent = false;
- if (ifp != ift->ifpub)
- continue;
+ spin_lock(&ift->lock);
+ if (ifp != ift->ifpub) {
+ /* reparent if orphaned temporary address with same
+ * prefix is found
+ */
+ if (ipv6_prefix_equal(&ift->addr, &ifp->addr,
+ ift->prefix_len)) {
+ in6_ifa_hold(ifp);
+ in6_ifa_put(ift->ifpub);
+ ift->ifpub = ifp;
+ reparent = true;
+ } else {
+ spin_unlock(&ift->lock);
+ continue;
+ }
+ }
/* RFC 4941 section 3.3:
* If a received option will extend the lifetime of a public
@@ -2110,7 +2129,6 @@ static void manage_tempaddrs(struct inet6_dev *idev,
if (prefered_lft > max_prefered)
prefered_lft = max_prefered;
- spin_lock(&ift->lock);
flags = ift->flags;
ift->valid_lft = valid_lft;
ift->prefered_lft = prefered_lft;
@@ -2119,6 +2137,12 @@ static void manage_tempaddrs(struct inet6_dev *idev,
ift->flags &= ~IFA_F_DEPRECATED;
spin_unlock(&ift->lock);
+ /* Don't create a temporary address if we reparented one which
+ * is preferred more than regen_advance
+ */
+ if (reparent && prefered_lft > regen_advance)
+ create = false;
+
if (!(flags&IFA_F_TENTATIVE))
ipv6_ifa_notify(0, ift);
}
--
1.9.1.315.g3f09db0.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ipv6: Reparent temporary address(es) if global address was, deleted from userspace
2014-04-07 5:43 [PATCH v2] ipv6: Reparent temporary address(es) if global address was, deleted from userspace Heiner Kallweit
@ 2014-04-07 10:22 ` Hannes Frederic Sowa
2014-04-07 18:50 ` Heiner Kallweit
0 siblings, 1 reply; 3+ messages in thread
From: Hannes Frederic Sowa @ 2014-04-07 10:22 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: netdev@vger.kernel.org
On Mon, Apr 07, 2014 at 07:43:12AM +0200, Heiner Kallweit wrote:
> If the kernel takes care of global and temporary addresses it can happen
> that the global address is deleted from userspace,
> e.g. by network managers in case the link goes (temporarily) down.
> In addition to the then orphaned temporary address(es) the next RA will
> create a new temporary address. Therefore we might end up with more than
> one non-deprecated temporary address for the same prefix for a longer
> period of time (>regen_advance). According to RfC4941 sect. 3.4 this
> should not happen.
>
> Fix this by reparenting orphaned temporary addresses.
>
> v2: style fixes
>
> Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>
Looks good!
Btw. do you intend this as a bugfix for net or net-next? net-next is currently
closed and you would have to resubmit this patch as soon as net-next opens
back up. A notification will be send to this list.
Current kernels only print a warning if this happens, so IMHO net-next would
be ok?
Thanks,
Hannes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ipv6: Reparent temporary address(es) if global address was, deleted from userspace
2014-04-07 10:22 ` Hannes Frederic Sowa
@ 2014-04-07 18:50 ` Heiner Kallweit
0 siblings, 0 replies; 3+ messages in thread
From: Heiner Kallweit @ 2014-04-07 18:50 UTC (permalink / raw)
To: Hannes Frederic Sowa, netdev@vger.kernel.org
Am 07.04.2014 12:22, schrieb Hannes Frederic Sowa:
> On Mon, Apr 07, 2014 at 07:43:12AM +0200, Heiner Kallweit wrote:
>> If the kernel takes care of global and temporary addresses it can happen
>> that the global address is deleted from userspace,
>> e.g. by network managers in case the link goes (temporarily) down.
>> In addition to the then orphaned temporary address(es) the next RA will
>> create a new temporary address. Therefore we might end up with more than
>> one non-deprecated temporary address for the same prefix for a longer
>> period of time (>regen_advance). According to RfC4941 sect. 3.4 this
>> should not happen.
>>
>> Fix this by reparenting orphaned temporary addresses.
>>
>> v2: style fixes
>>
>> Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>
> Looks good!
>
> Btw. do you intend this as a bugfix for net or net-next? net-next is currently
> closed and you would have to resubmit this patch as soon as net-next opens
> back up. A notification will be send to this list.
>
> Current kernels only print a warning if this happens, so IMHO net-next would
> be ok?
>
> Thanks,
>
> Hannes
>
>
Even though the kernel doesn't fully follow RfC 4941 in this scenario I didn't notice any real harm.
Therefore I would agree and consider it more an improvement than a bugfix. I'll resubmit once net-next is open again.
Regards, Heiner
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-07 18:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-07 5:43 [PATCH v2] ipv6: Reparent temporary address(es) if global address was, deleted from userspace Heiner Kallweit
2014-04-07 10:22 ` Hannes Frederic Sowa
2014-04-07 18:50 ` Heiner Kallweit
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).