From 56b1927a40f9c8d7f4c40df6fafe78a2aab354bc Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Tue, 4 Dec 2007 19:43:05 +0000 Subject: Always compare the nexthop if one is specified even if it is a non-multipath route. This mostly affects "route delete" and it will not remove the last route if previous delete is redone. OK henning@ --- sys/net/radix_mpath.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sys') diff --git a/sys/net/radix_mpath.c b/sys/net/radix_mpath.c index 8b375f18acd..3ecfd2f983a 100644 --- a/sys/net/radix_mpath.c +++ b/sys/net/radix_mpath.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radix_mpath.c,v 1.7 2006/06/18 12:03:19 pascoe Exp $ */ +/* $OpenBSD: radix_mpath.c,v 1.8 2007/12/04 19:43:04 claudio Exp $ */ /* $KAME: radix_mpath.c,v 1.13 2002/10/28 21:05:59 itojun Exp $ */ /* @@ -92,23 +92,23 @@ rn_mpath_count(struct radix_node *rn) struct rtentry * rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate) { - struct radix_node *rn; + struct radix_node *rn = (struct radix_node *)rt; - if (!rn_mpath_next((struct radix_node *)rt)) + /* + * if gate is set it must be compared, if not set the route must be + * a non-multipath one. + */ + if (!gate && !rn_mpath_next(rn)) return rt; - if (!gate) return NULL; - /* beyond here, we use rn as the master copy */ - rn = (struct radix_node *)rt; + do { rt = (struct rtentry *)rn; if (rt->rt_gateway->sa_len == gate->sa_len && !memcmp(rt->rt_gateway, gate, gate->sa_len)) break; } while ((rn = rn_mpath_next(rn)) != NULL); - if (!rn) - return NULL; return (struct rtentry *)rn; } -- cgit v1.2.3