summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorMarcel Röthke <marcel.roethke@haw-hamburg.de>2019-08-16 16:20:05 +0200
committerMarcel Röthke <marcel.roethke@haw-hamburg.de>2019-08-16 16:42:11 +0200
commit24b7eb485d13b454aa9d7b9a9690bd5b7d0425a1 (patch)
treedeae487af4c613f0d0a1b5a3421ca32b648431a1 /bgpd
parentbgpd: remove initial sync timeout in rpki startup code (diff)
downloadfrr-24b7eb485d13b454aa9d7b9a9690bd5b7d0425a1.tar.xz
frr-24b7eb485d13b454aa9d7b9a9690bd5b7d0425a1.zip
bgpd: fix bgp_table range lookup
In case the topmost node has a larger prefix length than the lookup prefix it never matches even if it was still lower than maxlen This also alters a test case to check for this bug. Signed-off-by: Marcel Röthke <marcel.roethke@haw-hamburg.de>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_table.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index ecde71279..53175bfcc 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -156,8 +156,10 @@ void bgp_table_range_lookup(const struct bgp_table *table, struct prefix *p,
struct bgp_node *node = bgp_node_from_rnode(table->route_table->top);
struct bgp_node *matched = NULL;
- while (node && node->p.prefixlen <= p->prefixlen
- && prefix_match(&node->p, p)) {
+ if (node == NULL)
+ return;
+
+ while (node->p.prefixlen <= p->prefixlen && prefix_match(&node->p, p)) {
if (bgp_node_has_bgp_path_info_data(node)
&& node->p.prefixlen == p->prefixlen) {
matched = node;
@@ -167,10 +169,10 @@ void bgp_table_range_lookup(const struct bgp_table *table, struct prefix *p,
&p->u.prefix, node->p.prefixlen)]);
}
- if (node == NULL)
- return;
-
- if ((matched == NULL && node->p.prefixlen > maxlen) || !node->parent)
+ if (matched == NULL && node->p.prefixlen <= maxlen
+ && prefix_match(p, &node->p) && node->parent == NULL)
+ matched = node;
+ else if ((matched == NULL && node->p.prefixlen > maxlen) || !node->parent)
return;
else if (matched == NULL)
matched = node = bgp_node_from_rnode(node->parent);