From: pcarana Date: Tue, 2 Jul 2019 20:12:02 +0000 (-0500) Subject: Add some small fixes. X-Git-Tag: v1.1.0~1^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24c0fcab46ab18ed60c1487d30254dc588a31d55;p=thirdparty%2FFORT-validator.git Add some small fixes. -Update '--tal' and '--slurm' arguments doc. -Update '-O' level to '2'. -Remove unnecessary parameter '*serial' on 'vrps_foreach_base_roa'. --- diff --git a/docs/doc/usage.md b/docs/doc/usage.md index 1e540058..357f76db 100644 --- a/docs/doc/usage.md +++ b/docs/doc/usage.md @@ -40,15 +40,13 @@ command: fort ## Syntax - - ``` {{ page.command }} [--help] [--usage] [--version] [--configuration-file=] - [--tal=] + [--tal=|] [--local-repository=] [--sync-strategy=off|strict|root|root-except-ta] [--shuffle-uris] @@ -58,7 +56,7 @@ command: fort [--server.port=] [--server.backlog=] [--server.validation-interval=] - [--slurm=] + [--slurm=|] [--log.color-output] [--log.file-name-format=global-url|local-path|file-name] [--output.roa=] diff --git a/src/Makefile.am b/src/Makefile.am index 76913ec2..1155489e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,7 +104,7 @@ fort_SOURCES += $(ASN_MODULE_SRCS) $(ASN_MODULE_HDRS) fort_CFLAGS = -Wall # Feel free to temporarily remove this one if you're not using gcc 7.3.0. #fort_CFLAGS += $(GCC_WARNS) -fort_CFLAGS += -std=gnu11 -O0 -g $(CFLAGS_DEBUG) $(FORT_FLAGS) +fort_CFLAGS += -std=gnu11 -O2 -g $(CFLAGS_DEBUG) $(FORT_FLAGS) fort_LDFLAGS = $(LDFLAGS_DEBUG) fort_LDADD = ${JANSSON_LIBS} diff --git a/src/config.c b/src/config.c index f90ac9d8..d1440dfd 100644 --- a/src/config.c +++ b/src/config.c @@ -155,7 +155,7 @@ static const struct option_field options[] = { .type = >_string, .offset = offsetof(struct rpki_config, tal), .doc = "Path to the TAL file or TALs directory", - .arg_doc = "", + .arg_doc = "|", }, { .id = 'r', .name = "local-repository", @@ -194,6 +194,7 @@ static const struct option_field options[] = { .type = >_string, .offset = offsetof(struct rpki_config, slurm), .doc = "Path to the SLURM file or SLURMs directory (files must have the extension .slurm)", + .arg_doc = "|" }, { .id = 1004, .name = "mode", diff --git a/src/rtr/db/vrps.c b/src/rtr/db/vrps.c index 53c374d7..df75bd4d 100644 --- a/src/rtr/db/vrps.c +++ b/src/rtr/db/vrps.c @@ -319,11 +319,9 @@ revert_base: * important ones are * 1. 0: No errors. * 2. -EAGAIN: No data available; database still under construction. - * - * TODO (whatever) @serial is a dumb hack. */ int -vrps_foreach_base_roa(vrp_foreach_cb cb, void *arg, serial_t *serial) +vrps_foreach_base_roa(vrp_foreach_cb cb, void *arg) { int error; @@ -331,12 +329,10 @@ vrps_foreach_base_roa(vrp_foreach_cb cb, void *arg, serial_t *serial) if (error) return error; - if (state.base != NULL) { + if (state.base != NULL) error = roa_table_foreach_roa(state.base, cb, arg); - *serial = state.next_serial - 1; - } else { + else error = -EAGAIN; - } rwlock_unlock(&lock); diff --git a/src/rtr/db/vrps.h b/src/rtr/db/vrps.h index 86f2b2b6..67116c5e 100644 --- a/src/rtr/db/vrps.h +++ b/src/rtr/db/vrps.h @@ -28,7 +28,7 @@ int vrps_update(bool *); * been called, or while it's still building the database. * Handle gracefully. */ -int vrps_foreach_base_roa(vrp_foreach_cb, void *, serial_t *); +int vrps_foreach_base_roa(vrp_foreach_cb, void *); int vrps_get_deltas_from(serial_t, serial_t *, struct deltas_db *); int get_last_serial_number(serial_t *); diff --git a/src/rtr/pdu_handler.c b/src/rtr/pdu_handler.c index c7b272f0..fa5bfd4e 100644 --- a/src/rtr/pdu_handler.c +++ b/src/rtr/pdu_handler.c @@ -124,6 +124,17 @@ handle_reset_query_pdu(int fd, struct rtr_request const *request) args.started = false; args.fd = fd; + error = get_last_serial_number(¤t_serial); + switch (error) { + case 0: + break; + case -EAGAIN: + return err_pdu_send_no_data_available(fd); + default: + err_pdu_send_internal_error(fd); + return error; + } + /* * It's probably best not to work on a copy, because the tree is large. * Unfortunately, this means we'll have to encourage writer stagnation, @@ -131,7 +142,7 @@ handle_reset_query_pdu(int fd, struct rtr_request const *request) * queries than reset queries. */ - error = vrps_foreach_base_roa(send_base_roa, &args, ¤t_serial); + error = vrps_foreach_base_roa(send_base_roa, &args); /* See handle_serial_query_pdu() for some comments. */ switch (error) { diff --git a/test/rtr/db/vrps_test.c b/test/rtr/db/vrps_test.c index ab43ef22..c61988e1 100644 --- a/test/rtr/db/vrps_test.c +++ b/test/rtr/db/vrps_test.c @@ -178,8 +178,8 @@ check_base(serial_t expected_serial, bool const *expected_base) array_index i; memset(actual_base, 0, sizeof(actual_base)); - ck_assert_int_eq(0, vrps_foreach_base_roa(vrp_check, actual_base, - &actual_serial)); + ck_assert_int_eq(0, get_last_serial_number(&actual_serial)); + ck_assert_int_eq(0, vrps_foreach_base_roa(vrp_check, actual_base)); ck_assert_uint_eq(expected_serial, actual_serial); for (i = 0; i < ARRAY_LEN(actual_base); i++) ck_assert_uint_eq(expected_base[i], actual_base[i]); @@ -281,7 +281,7 @@ create_deltas_0to1(struct deltas_db *deltas, serial_t *serial, bool *changed, /* First validation not yet performed: Tell routers to wait */ ck_assert_int_eq(-EAGAIN, get_last_serial_number(serial)); ck_assert_int_eq(-EAGAIN, vrps_foreach_base_roa(vrp_fail, - iterated_entries, serial)); + iterated_entries)); ck_assert_int_eq(-EAGAIN, vrps_get_deltas_from(0, serial, deltas)); /* First validation: One tree, no deltas */