Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Oct 2003 08:38:41 -0800 (PST)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 40838 for review
Message-ID:  <200310301638.h9UGcf6B043939@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310301638.h9UGcf6B043939>