]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Fix segfaults at visited_uris.c, add minor updates and RRDP debug logs.
authorpcarana <pc.moreno2099@gmail.com>
Wed, 18 Dec 2019 19:03:58 +0000 (13:03 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Wed, 18 Dec 2019 19:03:58 +0000 (13:03 -0600)
+The segfaults where due to a bad initialization of visited URI elements and reference count.
+Add some debug logs when processing RRDP files.
+Replace 'Valid ROAs' label with 'Valid Prefixes' when there are updates at VRPS DB (and update docs where this label is referenced).

docs/logging.md
man/fort.8
src/http/http.c
src/rrdp/rrdp_loader.c
src/rrdp/rrdp_objects.c
src/rrdp/rrdp_parser.c
src/rtr/db/vrps.c
src/visited_uris.c

index 16e8c5e36f12ea59758b93b066127185442278ed..3e7bf5bab53232471175c4af70814868d6b0fddb 100644 (file)
@@ -36,7 +36,7 @@ The validator uses exactly five levels of priority (they're just some of all the
 - `info`: Information deemed useful to the user:
        - Configuration echo at the beginning.
        - Server binding status.
-       - Start and end of a validation cycle, including: number of valid ROAs and Router Keys, current serial number (only when [`--mode=server`](usage.html#--mode), and real execution time.
+       - Start and end of a validation cycle, including: number of valid Prefixes and Router Keys, current RTR serial number (only when [`--mode=server`](usage.html#--mode), and real execution time.
        - SLURM version applied in case of a syntax error or invalid data at the newest loaded SLURM configured at [`--slurm`](usage.html#--slurm).
        - RTR client connection accepted, closed or terminated.
 - `debug`: Information deemed useful to the developer. Expect a lot of messages when utilized.
index 79933b3609a4cc2af3db50492b68fb5bdf9b9e23..cce3416d45e5a34e4b87d633439ee375b9acb944 100644 (file)
@@ -1,4 +1,4 @@
-.TH fort 8 "2019-11-08" "v1.2.0" "FORT validator"
+.TH fort 8 "2019-12-18" "v1.2.0" "FORT validator"
 
 .SH NAME
 fort \- RPKI certificate path validator and RTR server
index 8cdaa8f42fafc0d108ba1f7dfebf2e404b255e3e..02cff97f14069d7e2b66803b4c1a0855eceb6c3b 100644 (file)
@@ -106,7 +106,7 @@ http_fetch(struct http_handler *handler, char const *uri, long *response_code,
        curl_easy_setopt(handler->curl, CURLOPT_WRITEFUNCTION, cb);
        curl_easy_setopt(handler->curl, CURLOPT_WRITEDATA, arg);
 
-       pr_debug("HTTP GET from '%s'.", uri);
+       pr_debug("Doing HTTP GET to '%s'.", uri);
        res = curl_easy_perform(handler->curl);
        curl_easy_getinfo(handler->curl, CURLINFO_RESPONSE_CODE, response_code);
        if (res == CURLE_OK)
index c4566a4cb12f3d62f8efeafd00c8aa2e67f8f87b..5031bb26d58840aa5f6dc11436536a1c9e958312 100644 (file)
@@ -87,8 +87,10 @@ rrdp_load(struct rpki_uri *uri)
                return error;
 
        /* No updates at the file (yet), didn't pushed to fnstack */
-       if (upd_notification == NULL)
+       if (upd_notification == NULL) {
+               pr_debug("No updates yet at '%s'.", uri_get_global(uri));
                return 0;
+       }
 
        error = db_rrdp_uris_cmp(uri_get_global(uri),
            upd_notification->global_data.session_id,
@@ -102,11 +104,11 @@ rrdp_load(struct rpki_uri *uri)
                goto set_update;
        case RRDP_URI_DIFF_SERIAL:
                error = process_diff_serial(upd_notification, &visited);
-               /* Something went wrong, use snapshot */
                if (!error) {
                        visited_uris_refget(visited);
                        break;
                }
+               /* Something went wrong, use snapshot */
                pr_warn("There was an error processing RRDP deltas, using the snapshot instead.");
        case RRDP_URI_DIFF_SESSION:
                /* Delete the old session files */
@@ -122,6 +124,12 @@ rrdp_load(struct rpki_uri *uri)
 
        /* Any change, and no error during the process, update db */
        if (!error) {
+               pr_debug("Updating local RRDP data of '%s' to:",
+                   uri_get_global(uri));
+               pr_debug("- Session ID: %s",
+                   upd_notification->global_data.session_id);
+               pr_debug("- Serial: %lu",
+                   upd_notification->global_data.serial);
                error = db_rrdp_uris_update(uri_get_global(uri),
                    upd_notification->global_data.session_id,
                    upd_notification->global_data.serial,
@@ -132,6 +140,8 @@ rrdp_load(struct rpki_uri *uri)
 
 set_update:
        /* Set the last update to now */
+       pr_debug("Set last update of RRDP data of '%s' to now.",
+           uri_get_global(uri));
        error = db_rrdp_uris_set_last_update(uri_get_global(uri));
 end:
        if (upd_notification != NULL) {
index 7a2d8aa4992018763e0e15f112263b473d6721e1..8bd3745d0d4ef5d23b1ef72c2ae017059be33357 100644 (file)
@@ -219,6 +219,8 @@ deltas_head_for_each(struct deltas_head *deltas, unsigned long max_serial,
                return -ENOENT;
        }
 
+       pr_debug("Getting RRDP deltas from serial %lu to %lu.", from_serial,
+           max_serial);
        from = deltas->capacity - (max_serial - from_serial);
        for (index = from; index < deltas->capacity; index++) {
                error = cb(deltas->array[index], arg);
index 3001ba2e5f4524ee2dc31bcc8906a1b80b2b769f..922d51c6d039eac92ae3e9f310210a24624a40d1 100644 (file)
@@ -612,6 +612,7 @@ write_from_uri(char const *location, unsigned char *content, size_t content_len,
        return 0;
 }
 
+/* Remove a local file and its directory tree (if empty) */
 static int
 delete_from_uri(struct rpki_uri *uri, struct visited_uris *visited_uris)
 {
index a2025c50a51a4b14bfdf716717eafa9297f6cd51..1aeb7815400137df3c31555a796ce65c61771c84 100644 (file)
@@ -408,7 +408,7 @@ vrps_update(bool *changed)
                        break;
                }
 
-               pr_info("- Valid ROAs: %u", db_table_roa_count(state.base));
+               pr_info("- Valid Prefixes: %u", db_table_roa_count(state.base));
                pr_info("- Valid Router Keys: %u",
                    db_table_router_key_count(state.base));
                if (config_get_mode() == SERVER) {
index 669324ee8d1058736a0a16fa4570a8d62f431165..6148c75693ce8d58830c344844ebb5d576610dab 100644 (file)
@@ -26,6 +26,8 @@ visited_elem_create(struct visited_elem **elem, char const *uri)
        tmp = malloc(sizeof(struct visited_elem));
        if (tmp == NULL)
                return pr_enomem();
+       /* Needed by uthash */
+       memset(tmp, 0, sizeof(struct visited_elem));
 
        tmp->uri = strdup(uri);
        if (tmp->uri == NULL) {
@@ -54,13 +56,12 @@ visited_uris_create(struct visited_uris **uris)
                return pr_enomem();
 
        tmp->table = NULL;
-       tmp->refs = 0;
+       tmp->refs = 1;
 
        *uris = tmp;
        return 0;
 }
 
-
 static void
 visited_uris_destroy(struct visited_uris *uris)
 {
@@ -83,9 +84,8 @@ void
 visited_uris_refput(struct visited_uris *uris)
 {
        uris->refs--;
-       if (uris->refs == 0) {
+       if (uris->refs == 0)
                visited_uris_destroy(uris);
-       }
 }
 
 static struct visited_elem *