[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52D83DE3.40806@hp.com>
Date: Thu, 16 Jan 2014 15:15:31 -0500
From: Brian Haley <brian.haley@...com>
To: Jiri Pirko <jiri@...nulli.us>
CC: netdev@...r.kernel.org, fbl@...hat.com
Subject: Re: [PATCH net] ipv6: simplify detection of first operational link-local
address on interface
On 01/16/2014 02:13 PM, Hannes Frederic Sowa wrote:
> In commit 1ec047eb4751e3 ("ipv6: introduce per-interface counter for
> dad-completed ipv6 addresses") I build the detection of the first
> operational link-local address much to complex. Additionally this code
> now has a race condition.
>
> Replace it with a much simpler variant, which just scans the address
> list when duplicate address detection completes, to check if this is
> the first valid link local address and send RS and MLD reports then.
>
> Fixes: 1ec047eb4751e3 ("ipv6: introduce per-interface counter for dad-completed ipv6 addresses")
> Reported-by: Jiri Pirko <jiri@...nulli.us>
> Cc: Flavio Leitner <fbl@...hat.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@...essinduktion.org>
> ---
> +/* ifp->idev must be at least read locked */
> +static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp)
> +{
> + struct inet6_ifaddr *ifpiter;
> + struct inet6_dev *idev = ifp->idev;
> +
> + list_for_each_entry(ifpiter, &idev->addr_list, if_list) {
> + if (ifp != ifpiter && ifpiter->scope == IFA_LINK &&
> + (ifpiter->flags & (IFA_F_PERMANENT|IFA_F_TENTATIVE|
> + IFA_F_OPTIMISTIC|IFA_F_DADFAILED)) ==
> + IFA_F_PERMANENT)
> + return false;
> + }
> + return true;
> +}
Just a nit, but the idev->addr_list is sorted by scope, so you could use
list_for_each_entry_reverse(), and break out once the scope is > IFA_LINK to
reduce the number of compares.
-Brian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists