diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-27 18:41:41 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-27 18:41:41 +0000 |
commit | 8aa70b3a4130113ba2bea42273de26b20c41eba8 (patch) | |
tree | 9621025261f169c061491d8a4e6ff41db28f8b51 | |
parent | bd67c826af3096ea4b54d47719fc15a296d8cc09 (diff) |
consider the defualt route in kroute_match as well. it is a special case.
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index d0b55bb270a..87791255630 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.40 2003/12/27 14:24:42 henning Exp $ */ +/* $OpenBSD: kroute.c,v 1.41 2003/12/27 18:41:40 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -612,13 +612,19 @@ kroute_match(in_addr_t key) ina = ntohl(key); /* we will never match the default route */ - for (i = 32; i >= 0; i--) { + for (i = 32; i > 0; i--) { s.r.prefix = htonl(ina & (0xffffffff << (32 - i))); s.r.prefixlen = i; if ((kr = RB_FIND(kroute_tree, &krt, &s)) != NULL) return (kr); } + /* if we don't have a match yet, try to find a defautl route */ + s.r.prefix = 0; + s.r.prefixlen = 0; + if ((kr = RB_FIND(kroute_tree, &krt, &s)) != NULL) + return (kr); + return (NULL); } |