From 798df969aae46409a2768cdcaacd21c4f8ad8fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20R=C3=B6thke?= Date: Fri, 16 Aug 2019 12:52:47 +0200 Subject: [PATCH 1/2] bgpd: remove initial sync timeout in rpki startup code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The initial sync timeout breaks config load and is not necessary anyway. Fix #4827 Signed-off-by: Marcel Röthke --- bgpd/bgp_rpki.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 408d423aac..5414e2ef15 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -142,7 +142,6 @@ static struct rtr_mgr_config *rtr_config; static struct list *cache_list; static int rtr_is_running; static int rtr_is_stopping; -static int rtr_is_starting; static _Atomic int rtr_update_overflow; static int rpki_debug; static unsigned int polling_period; @@ -478,7 +477,7 @@ static void rpki_update_cb_sync_rtr(struct pfx_table *p __attribute__((unused)), const struct pfx_record rec, const bool added __attribute__((unused))) { - if (rtr_is_stopping || rtr_is_starting + if (rtr_is_stopping || atomic_load_explicit(&rtr_update_overflow, memory_order_seq_cst)) return; @@ -570,11 +569,9 @@ static int bgp_rpki_module_init(void) static int start(void) { - unsigned int waiting_time = 0; int ret; rtr_is_stopping = 0; - rtr_is_starting = 1; rtr_update_overflow = 0; if (list_isempty(cache_list)) { @@ -603,23 +600,6 @@ static int start(void) return ERROR; } rtr_is_running = 1; - RPKI_DEBUG("Waiting for rtr connection to synchronize."); - while (waiting_time++ <= initial_synchronisation_timeout) { - if (rtr_mgr_conf_in_sync(rtr_config)) - break; - - sleep(1); - } - if (rtr_mgr_conf_in_sync(rtr_config)) { - RPKI_DEBUG("Got synchronisation with at least one RPKI cache!"); - RPKI_DEBUG("Forcing revalidation."); - rtr_is_starting = 0; - revalidate_all_routes(); - } else { - RPKI_DEBUG( - "Timeout expired! Proceeding without RPKI validation data."); - rtr_is_starting = 0; - } XFREE(MTYPE_BGP_RPKI_CACHE_GROUP, groups); From 24b7eb485d13b454aa9d7b9a9690bd5b7d0425a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20R=C3=B6thke?= Date: Fri, 16 Aug 2019 16:20:05 +0200 Subject: [PATCH 2/2] bgpd: fix bgp_table range lookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- bgpd/bgp_table.c | 14 ++++++++------ tests/bgpd/test_bgp_table.c | 2 +- tests/bgpd/test_bgp_table.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index ecde71279d..53175bfccf 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); diff --git a/tests/bgpd/test_bgp_table.c b/tests/bgpd/test_bgp_table.c index 7b38df5f66..819c2d7282 100644 --- a/tests/bgpd/test_bgp_table.c +++ b/tests/bgpd/test_bgp_table.c @@ -183,7 +183,7 @@ static void test_range_lookup(void) do_test(table, "16.0.0.0/8", 16, "16.0.0.0/16", NULL); - do_test(table, "0.0.0.0/3", 21, "1.16.0.0/16", "1.16.128.0/18", + do_test(table, "0.0.0.0/2", 21, "1.16.0.0/16", "1.16.128.0/18", "1.16.192.0/18", "1.16.64.0/19", "1.16.160.0/19", "1.16.32.0/20", "1.16.32.0/21", "16.0.0.0/16", NULL); } diff --git a/tests/bgpd/test_bgp_table.py b/tests/bgpd/test_bgp_table.py index 4423530fe0..4deaf08c22 100644 --- a/tests/bgpd/test_bgp_table.py +++ b/tests/bgpd/test_bgp_table.py @@ -3,5 +3,5 @@ import frrtest class TestTable(frrtest.TestMultiOut): program = './test_bgp_table' -for i in range(6): +for i in range(9): TestTable.onesimple('Checks successfull')