Module Name: src Committed By: riz Date: Mon Aug 8 19:36:02 UTC 2011
Modified Files: src/sys/net [netbsd-5-0]: if.c Log Message: Pull up following revision(s) (requested by sborrill in ticket #1643): sys/net/if.c: revision 1.243 Prevent if_detach() from crashing while it walks the routing table to find and unlink routes that reference the detached ifnet: make if_rt_walktree() return ERESTART whenever it has deleted a route. Whenever rt_walktree() returns ERESTART, if_detach() restarts it. I believe that this fix resembles one by Jonathan Kollasch or by someone else, which has languished in a PR for too long. Sorry! Tested by me and by Jeff Rizzo. XXX It's supposed to be safe for rn_walktree() to apply to the routing XXX table a routine that may delete routes. Why isn't it safe in XXX practice? To generate a diff of this commit: cvs rdiff -u -r1.230.4.1 -r1.230.4.1.2.1 src/sys/net/if.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if.c diff -u src/sys/net/if.c:1.230.4.1 src/sys/net/if.c:1.230.4.1.2.1 --- src/sys/net/if.c:1.230.4.1 Tue Feb 24 02:26:42 2009 +++ src/sys/net/if.c Mon Aug 8 19:36:02 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.230.4.1 2009/02/24 02:26:42 snj Exp $ */ +/* $NetBSD: if.c,v 1.230.4.1.2.1 2011/08/08 19:36:02 riz Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.230.4.1 2009/02/24 02:26:42 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.230.4.1.2.1 2011/08/08 19:36:02 riz Exp $"); #include "opt_inet.h" @@ -726,8 +726,10 @@ if_free_sadl(ifp); /* Walk the routing table looking for stragglers. */ - for (i = 0; i <= AF_MAX; i++) - (void)rt_walktree(i, if_rt_walktree, ifp); + for (i = 0; i <= AF_MAX; i++) { + while (rt_walktree(i, if_rt_walktree, ifp) == ERESTART) + ; + } DOMAIN_FOREACH(dp) { if (dp->dom_ifdetach != NULL && ifp->if_afdata[dp->dom_family]) @@ -838,7 +840,7 @@ if (error != 0) printf("%s: warning: unable to delete rtentry @ %p, " "error = %d\n", ifp->if_xname, rt, error); - return 0; + return ERESTART; } /*