From: Daniel Borkmann <dborkman@redhat.com>
To: Heiner Kallweit <heiner.kallweit@web.de>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Hannes Frederic Sowa <hannes@stressinduktion.org>
Subject: Re: [PATCH] ipv6: Reparent temporary address(es) if global address was deleted from userspace
Date: Sun, 06 Apr 2014 22:27:03 +0200 [thread overview]
Message-ID: <5341B897.1080105@redhat.com> (raw)
In-Reply-To: <5341A52B.2070207@web.de>
On 04/06/2014 09:04 PM, 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 RfC 4941 sect. 3.4 this should not happen.
Nit: your commit description should only be ~75 chars wide max
> Fix this by reparenting orphaned temporary addresses.
>
> Signed-off-by: Heiner Kallweit <heiner.kallweit@web.de>
> ---
> net/ipv6/addrconf.c | 34 +++++++++++++++++++++++++++++++---
> 1 file changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 6c7fa08..4d5595b 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -2077,14 +2077,34 @@ 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;
>
> - if (ifp != ift->ifpub)
> - continue;
> + reparent = false;
You can collapse initialization where you declare the variable.
> + 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 +2130,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 +2138,15 @@ 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 prefered more than regen_advance
Nit: s/prefered/preferred/
> + */
> + if (reparent && prefered_lft > regen_advance) {
> + create = false;
> + pr_info("%s: reparent orphaned temporary address\n",
> + __func__);
The pr_info() should ideally be removed (or at least made pr_debug()).
> + }
> +
> if (!(flags&IFA_F_TENTATIVE))
> ipv6_ifa_notify(0, ift);
> }
>
next prev parent reply other threads:[~2014-04-06 20:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-06 19:04 [PATCH] ipv6: Reparent temporary address(es) if global address was deleted from userspace Heiner Kallweit
2014-04-06 20:27 ` Daniel Borkmann [this message]
2014-04-07 5:18 ` Heiner Kallweit
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=5341B897.1080105@redhat.com \
--to=dborkman@redhat.com \
--cc=hannes@stressinduktion.org \
--cc=heiner.kallweit@web.de \
--cc=netdev@vger.kernel.org \
/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 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).