Bug 174959 - [net] [patch] rnh_walktree_from visits spurious nodes
Summary: [net] [patch] rnh_walktree_from visits spurious nodes
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-04 02:10 UTC by Keith Sklower
Modified: 2019-01-20 03:27 UTC (History)
2 users (show)

See Also:


Attachments
file.diff (565 bytes, patch)
2013-01-04 02:10 UTC, Keith Sklower
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Keith Sklower 2013-01-04 02:10:00 UTC
	The radix tree method rnh_walktree_from (as implemented 
	by rn_walktree_from in /sys/net/radix.c) invokes the helper
	function f on nodes that it should not, even when supplied with
	inputs adhering to its unreasonably strict assumptions.

	It is low priority because nothing in the source
	distribution uses this function anymore.  We have a local need for it.

How-To-Repeat: 
        Construct a routing tree with the following 4 routes:
	128.32.8.0/24
	128.32.9.0/24
	128.32.8.1 (host)
	128.32.8.2 (host)

	invoke rn_walktree_from(tree, 128.32.9.0, 255.255.255.0, f, 0)
	where f prints the IP address in each leaf visited.

	[I can supply 94 line C program that demonstrates this at user level]

	It should only visit 128.32.9.0/24; instead it visits the entire
	tree.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-01-20 01:54:19 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 Alexander V. Chernikov freebsd_committer freebsd_triage 2014-05-01 15:59:13 UTC
Responsible Changed
From-To: freebsd-net->melifaro

Take.
Comment 3 dfilter service freebsd_committer freebsd_triage 2014-05-01 16:04:39 UTC
Author: melifaro
Date: Thu May  1 15:04:32 2014
New Revision: 265196
URL: http://svnweb.freebsd.org/changeset/base/265196

Log:
  Fix rnh_walktree_from() function (patch from kern/174959).
  Require valid netmask to be passed since host route is always a leaf.
  
  PR:		kern/174959
  Submitted by:	Keith Sklower
  MFC after:	2 weeks

Modified:
  head/sys/net/radix.c

Modified: head/sys/net/radix.c
==============================================================================
--- head/sys/net/radix.c	Thu May  1 15:03:26 2014	(r265195)
+++ head/sys/net/radix.c	Thu May  1 15:04:32 2014	(r265196)
@@ -971,6 +971,8 @@ rn_walktree_from(struct radix_node_head 
 	int stopping = 0;
 	int lastb;
 
+	KASSERT(m != NULL, ("%s: mask needs to be specified", __func__));
+
 	/*
 	 * rn_search_m is sort-of-open-coded here. We cannot use the
 	 * function because we need to keep track of the last node seen.
@@ -994,11 +996,11 @@ rn_walktree_from(struct radix_node_head 
 	/*
 	 * Two cases: either we stepped off the end of our mask,
 	 * in which case last == rn, or we reached a leaf, in which
-	 * case we want to start from the last node we looked at.
-	 * Either way, last is the node we want to start from.
+	 * case we want to start from the leaf.
 	 */
-	rn = last;
-	lastb = rn->rn_bit;
+	if (rn->rn_bit >= 0)
+		rn = last;
+	lastb = last->rn_bit;
 
 	/* printf("rn %p, lastb %d\n", rn, lastb);*/
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:32 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 5 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-20 03:27:27 UTC
There was a commit referencing this bug, but it's still not closed and has been inactive for some time. Closing as fixed. Please re-open it if the issue hasn't been completely resolved.