From owner-freebsd-net Wed Jan 8 14: 3:12 2003 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C561A37B401; Wed, 8 Jan 2003 14:03:10 -0800 (PST) Received: from mel-rto6.wanadoo.fr (smtp-out-6.wanadoo.fr [193.252.19.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id F30A843ED8; Wed, 8 Jan 2003 14:03:09 -0800 (PST) (envelope-from vjardin@wanadoo.fr) Received: from mel-rta7.wanadoo.fr (193.252.19.61) by mel-rto6.wanadoo.fr (6.7.015) id 3E0C343F006924B8; Wed, 8 Jan 2003 23:03:09 +0100 Received: from there (217.128.206.18) by mel-rta7.wanadoo.fr (6.7.015) id 3E075B1B006D4334; Wed, 8 Jan 2003 23:03:09 +0100 Message-ID: <3E075B1B006D4334@mel-rta7.wanadoo.fr> (added by postmaster@wanadoo.fr) Content-Type: text/plain; charset="iso-8859-1" From: Vincent Jardin To: Jeffrey Hsu Subject: Re: rt_refcnt and rtentry protection ?? Date: Wed, 8 Jan 2003 23:22:22 +0100 X-Mailer: KMail [version 1.3.2] Cc: net@freebsd.org References: <0H8E00ASUXB1HW@mta5.snfc21.pbi.net> In-Reply-To: <0H8E00ASUXB1HW@mta5.snfc21.pbi.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > > The roadmap for locking up the IP stack looks like roughly like ifaddr > ref counts, ifnet list, routing radix tree, ARP, ifaddr uses, and rtentry. However, it seems that the rtentries' rt_refcnt are not used like ifaddr, ifnet, ... It looks like something dirty has been done a long time ago. For example, the following lines: rt = rtalloc1((struct sockaddr *)&sin, create, 0UL); if (rt == 0) return (0); rt->rt_refcnt--; if (rt->rt_flags & RTF_GATEWAY) why = "host is not on local network"; else if ((rt->rt_flags & RTF_LLINFO) == 0) why = "could not allocate llinfo"; else if (rt->rt_gateway->sa_family != AF_LINK) why = "gateway route is not ours"; [...] return ((struct llinfo_arp *)rt->rt_llinfo); Why is rt_refnt decreased so early and not later ? I would think that it would be more correct to have: rt = rtalloc1((struct sockaddr *)&sin, create, 0UL); if (rt == 0) return (0); if (rt->rt_flags & RTF_GATEWAY) why = "host is not on local network"; else if ((rt->rt_flags & RTF_LLINFO) == 0) why = "could not allocate llinfo"; else if (rt->rt_gateway->sa_family != AF_LINK) why = "gateway route is not ours"; [...] rt->rt_refcnt--; return ((struct llinfo_arp *)rt->rt_llinfo); It looks like rt_refcnt is decreased just after many rtalloc() in order just to be sure that it won't be forgotten later, doesn'it ? > I'm a little over 3/5 of the way done along this path. Good luck, Vincent To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message