From owner-p4-projects@FreeBSD.ORG Thu Oct 30 08:38:43 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 80BC216A4D0; Thu, 30 Oct 2003 08:38:43 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3A87416A4CF for ; Thu, 30 Oct 2003 08:38:43 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7288943FBD for ; Thu, 30 Oct 2003 08:38:42 -0800 (PST) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id h9UGcgXJ043942 for ; Thu, 30 Oct 2003 08:38:42 -0800 (PST) (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id h9UGcf6B043939 for perforce@freebsd.org; Thu, 30 Oct 2003 08:38:41 -0800 (PST) (envelope-from sam@freebsd.org) Date: Thu, 30 Oct 2003 08:38:41 -0800 (PST) Message-Id: <200310301638.h9UGcf6B043939@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Subject: PERFORCE change 40838 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2003 16:38:44 -0000 http://perforce.freebsd.org/chv.cgi?CH=40838 Change 40838 by sam@sam_ebb on 2003/10/30 08:38:35 o change rtexpunge to not assume the entry is in the radix table (a la RTM_DELETE normal behaviour) so callers can invoke it w/o worries o change rtexpunge to return an error code to indicate if a change was done o use rtexpunage to eliminate a recursive lock when deleting a route on an icmp redirect Affected files ... .. //depot/projects/netperf/sys/net/route.c#23 edit .. //depot/projects/netperf/sys/net/route.h#11 edit Differences ... ==== //depot/projects/netperf/sys/net/route.c#23 (text+ko) ==== @@ -538,12 +538,13 @@ * Expunges references to a route that's about to be reclaimed. * The route must be locked. */ -void +int rtexpunge(struct rtentry *rt) { struct radix_node *rn; struct radix_node_head *rnh; struct ifaddr *ifa; + int error = 0; RT_LOCK_ASSERT(rt); #if 0 @@ -558,7 +559,8 @@ * Find the correct routing tree to use for this Address Family */ rnh = rt_tables[rt_key(rt)->sa_family]; - KASSERT(rnh != 0, ("no table for af %u", rt_key(rt)->sa_family)); + if (rnh == 0) + return (EAFNOSUPPORT); RADIX_NODE_HEAD_LOCK(rnh); @@ -566,7 +568,10 @@ * Remove the item from the tree; it must be there. */ rn = rnh->rnh_deladdr(rt_key(rt), rt_mask(rt), rnh); - KASSERT(rn != 0, ("no table entry")); + if (rn == 0) { + error = ESRCH; + goto bad; + } KASSERT((rn->rn_flags & (RNF_ACTIVE | RNF_ROOT)) == 0, ("unexpected flags 0x%x", rn->rn_flags)); KASSERT(rt == (struct rtentry *)rn, @@ -612,8 +617,9 @@ * linked to the routing table. */ rttrash++; - +bad: RADIX_NODE_HEAD_UNLOCK(rnh); + return (error); } int @@ -1024,8 +1030,7 @@ * or a routing redirect, so try to delete it. */ if (rt_key(rt)) - rtrequest(RTM_DELETE, rt_key(rt), - rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0); + rtexpunge(rt); return EADDRNOTAVAIL; } ==== //depot/projects/netperf/sys/net/route.h#11 (text+ko) ==== @@ -297,7 +297,7 @@ void rtalloc_ign(struct route *, u_long); /* NB: the rtentry is returned locked */ struct rtentry *rtalloc1(struct sockaddr *, int, u_long); -void rtexpunge(struct rtentry *); +int rtexpunge(struct rtentry *); void rtfree(struct rtentry *); int rtinit(struct ifaddr *, int, int); int rtioctl(u_long, caddr_t);