diff options
Diffstat (limited to 'proto/rpki/rpki.c')
-rw-r--r-- | proto/rpki/rpki.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/proto/rpki/rpki.c b/proto/rpki/rpki.c index afba2216..e5638aff 100644 --- a/proto/rpki/rpki.c +++ b/proto/rpki/rpki.c @@ -121,14 +121,11 @@ rpki_table_add_roa(struct rpki_cache *cache, struct channel *channel, const net_ { struct rpki_proto *p = cache->p; - rta a0 = { - .pref = channel->preference, - .source = RTS_RPKI, - .scope = SCOPE_UNIVERSE, - .dest = RTD_NONE, - }; + ea_list *ea = NULL; + ea_set_attr_u32(&ea, &ea_gen_preference, 0, channel->preference); + ea_set_attr_u32(&ea, &ea_gen_source, 0, RTS_RPKI); - rte e0 = { .attrs = &a0, .src = p->p.main_source, }; + rte e0 = { .attrs = ea, .src = p->p.main_source, }; rte_update(channel, &pfxr->n, &e0, p->p.main_source); } @@ -302,12 +299,13 @@ rpki_cache_change_state(struct rpki_cache *cache, const enum rpki_cache_state ne case RPKI_CS_NO_INCR_UPDATE_AVAIL: /* Server was unable to answer the last Serial Query and sent Cache Reset. */ - rpki_cache_change_state(cache, RPKI_CS_RESET); - break; - case RPKI_CS_ERROR_NO_DATA_AVAIL: /* No validation records are available on the cache server. */ - rpki_cache_change_state(cache, RPKI_CS_RESET); + + if (old_state == RPKI_CS_ESTABLISHED) + rpki_cache_change_state(cache, RPKI_CS_RESET); + else + rpki_schedule_next_retry(cache); break; case RPKI_CS_ERROR_FATAL: @@ -491,6 +489,11 @@ rpki_retry_hook(timer *tm) } break; + case RPKI_CS_NO_INCR_UPDATE_AVAIL: + case RPKI_CS_ERROR_NO_DATA_AVAIL: + rpki_cache_change_state(cache, RPKI_CS_RESET); + break; + default: rpki_cache_change_state(cache, RPKI_CS_CONNECTING); break; @@ -596,7 +599,7 @@ rpki_check_expire_interval(uint seconds) static struct rpki_cache * rpki_init_cache(struct rpki_proto *p, struct rpki_config *cf) { - pool *pool = rp_new(p->p.pool, p->p.loop, cf->hostname); + pool *pool = rp_new(p->p.pool, cf->hostname); struct rpki_cache *cache = mb_allocz(pool, sizeof(struct rpki_cache)); @@ -870,16 +873,27 @@ rpki_show_proto_info(struct proto *P) if (cache) { const char *transport_name = "---"; + uint default_port = 0; switch (cf->tr_config.type) { #if HAVE_LIBSSH - case RPKI_TR_SSH: transport_name = "SSHv2"; break; + case RPKI_TR_SSH: + transport_name = "SSHv2"; + default_port = RPKI_SSH_PORT; + break; #endif - case RPKI_TR_TCP: transport_name = "Unprotected over TCP"; break; + case RPKI_TR_TCP: + transport_name = "Unprotected over TCP"; + default_port = RPKI_TCP_PORT; + break; }; cli_msg(-1006, " Cache server: %s", cf->hostname); + + if (cf->port != default_port) + cli_msg(-1006, " Cache port: %u", cf->port); + cli_msg(-1006, " Status: %s", rpki_cache_state_to_str(cache->state)); cli_msg(-1006, " Transport: %s", transport_name); cli_msg(-1006, " Protocol version: %u", cache->version); @@ -977,7 +991,6 @@ rpki_copy_config(struct proto_config *dest UNUSED, struct proto_config *src UNUS struct protocol proto_rpki = { .name = "RPKI", .template = "rpki%d", - .class = PROTOCOL_RPKI, .preference = DEF_PREF_RPKI, .proto_size = sizeof(struct rpki_proto), .config_size = sizeof(struct rpki_config), @@ -991,3 +1004,9 @@ struct protocol proto_rpki = { .reconfigure = rpki_reconfigure, .get_status = rpki_get_status, }; + +void +rpki_build(void) +{ + proto_build(&proto_rpki); +} |