From 0efa11a7975f34dbbce371077099de952edf75c8 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Tue, 7 Jul 2015 09:39:29 +0000 Subject: 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@ --- sys/net/radix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sys') 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; } -- cgit v1.2.3