Date: Fri, 23 Dec 2011 20:51:30 +0000 From: "Bjoern A. Zeeb" <bz@freebsd.org> To: John Baldwin <jhb@freebsd.org> Cc: net@freebsd.org Subject: Re: [PATCH] Minor fixes to netinet6/icmp6.c Message-ID: <80A26A17-4524-4CAE-9672-0B760E55908F@freebsd.org> In-Reply-To: <201112231446.38057.jhb@freebsd.org> References: <201112231446.38057.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 23. Dec 2011, at 19:46 , John Baldwin wrote:
> I found these nits while working on the patches to convert if_addr_mtx to an
> rwlock. The first change is cosmetic, it just un-inlines a TAILQ_FOREACH().
> The second change is an actual bug. The code is currently reading
> TAILQ_FIRST(&V_ifnet) without holding the appropriate lock.
I think they should be good; may I ask you to fix the locking in one commit and
the "style" foreach one in another?
/bz
> Index: icmp6.c
> ===================================================================
> --- icmp6.c (revision 228777)
> +++ icmp6.c (working copy)
> @@ -1780,7 +1780,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf
> }
>
> IFNET_RLOCK_NOSLEEP();
> - for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) {
> + TAILQ_FOREACH(ifp, &V_ifnet, if_list) {
> addrsofif = 0;
> IF_ADDR_LOCK(ifp);
> TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
> @@ -1851,7 +1851,7 @@ static int
> ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6,
> struct ifnet *ifp0, int resid)
> {
> - struct ifnet *ifp = ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet);
> + struct ifnet *ifp;
> struct in6_ifaddr *ifa6;
> struct ifaddr *ifa;
> struct ifnet *ifp_dep = NULL;
> @@ -1864,6 +1864,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct
> return (0); /* needless to copy */
>
> IFNET_RLOCK_NOSLEEP();
> + ifp = ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet);
> again:
>
> for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) {
>
> --
> John Baldwin
--
Bjoern A. Zeeb You have to have visions!
Stop bit received. Insert coin for new address family.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?80A26A17-4524-4CAE-9672-0B760E55908F>
