Ruslan Ermilov 36fea5de60 rn_walktree*() compute the next leaf before applying a function
to current leaves because function may vanish the current node.

If parent RTA_GENMASK route has a clone (a "cloning clone"), an
rn_walktree_from() starting from parent will cause another walk
starting from clone.  If a function is either rt_fixdelete() or
rt_fixchange(), this recursive walk may vanish the leaf that is
remembered by an outer walk (the "next leaf" above), panicing a
system when it resumes with an outer walk.

The following script paniced my single-user mode booted system:

: sysctl net.inet.ip.forwarding=1
: ipfw add 1 allow ip from any to any
: ifconfig lo0 127.1
: route add -net 10 -genmask 255.255.255.0 127.1
: telnet 10.1			# rt_fixchange() panic
: telnet 10.2
: telnet 10.1
: route delete -net 10		# rt_fixdelete() panic

For the time being, avoid these races by disallowing recursive
walks in rt_fixchange() and rt_fixdelete().

Also, make a slight optimization in the rtrequest(RTM_RESOLVE)
case: there is no reason to call rt_fixchange() in this case.

PR:		kern/37606
MFC after:	5 days
2002-12-23 13:12:41 +00:00
..
2002-12-18 21:47:52 +00:00
2002-12-22 05:35:03 +00:00
2002-12-22 05:35:03 +00:00
2002-10-18 21:41:41 +00:00
2002-12-18 11:46:59 +00:00
2002-12-22 05:35:03 +00:00
2002-12-22 05:35:03 +00:00
2002-12-22 05:35:03 +00:00
2002-12-22 05:35:03 +00:00
2002-11-27 06:04:49 +00:00
2002-12-14 01:56:26 +00:00