summaryrefslogtreecommitdiff
path: root/sys/net/radix.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-07-07 09:39:29 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-07-07 09:39:29 +0000
commit0efa11a7975f34dbbce371077099de952edf75c8 (patch)
treefd45790c9ec663bf03c103a9a6bd2af6372c8c7a /sys/net/radix.c
parentc267d381cf787172340b4aabba3cde35c4ca536a (diff)
Do not return internal nodes to the upper layer in rn_lookup().
The limit between the radix layer and the route layer is somewhat vague, if it exists at all. This changes prevent rtrequest1(9) to find and delete the root node (RNF_ROOT) when trying to delete a non-existing default route: # route delete 0.0.0.0 delete host 0.0.0.0 # route delete 0.0.0.0 route: writing to routing socket: No such process delete host 0.0.0.0: not in table Historically rn_delete() was a no-op when called with an internal node as argument. But there's no reason to manipulate such node. In a better world rn_match() would contain such check, but let's change the perfect-match function for the moment as this fixes a bug and many dragons are lurking in there. Fix a regression introduced by the big refactoring of r1.40 and reported by tobias@. ok tobias@, claudio@, pelikan@
Diffstat (limited to 'sys/net/radix.c')
-rw-r--r--sys/net/radix.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/net/radix.c b/sys/net/radix.c
index f8eca3630cd..23e44b9c65f 100644
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radix.c,v 1.44 2015/03/04 15:53:29 claudio Exp $ */
+/* $OpenBSD: radix.c,v 1.45 2015/07/07 09:39:28 mpi Exp $ */
/* $NetBSD: radix.c,v 1.20 2003/08/07 16:32:56 agc Exp $ */
/*
@@ -192,6 +192,9 @@ rn_lookup(void *v_arg, void *m_arg, struct radix_node_head *head)
while (x && x->rn_mask != netmask)
x = x->rn_dupedkey;
}
+ /* Never return internal nodes to the upper layer. */
+ if (x && (x->rn_flags & RNF_ROOT))
+ return (NULL);
return x;
}