]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Remove the working_repo module
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 27 Jun 2023 19:31:25 +0000 (13:31 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 27 Jun 2023 20:48:31 +0000 (14:48 -0600)
It's a thread variable that keeps track of a URI that roughly represents
the publication point currently being traversed.

I would have moved it to the validation state, but given the two
previous commits, it wasn't really doing anything anymore.

src/object/certificate.c
src/object/tal.c
src/thread_var.c
src/thread_var.h

index 3c94df8a9e2a0afe50868bd0d6dd1c448cf68cf3..b72d888754374cdfa0161ea7d8a4e01b04bb4bdc 100644 (file)
@@ -2113,7 +2113,6 @@ use_access_method(struct sia_ca_uris *sia_uris, access_method_exec rsync_cb,
        }
 
        if (primary_rrdp) {
-               working_repo_push(uri_get_global(sia_uris->rpkiNotify.uri));
                if (error != -EPERM)
                        pr_val_info("Couldn't fetch data from RRDP repository '%s', trying to fetch data now from '%s'.",
                            uri_get_global(sia_uris->rpkiNotify.uri),
@@ -2123,7 +2122,6 @@ use_access_method(struct sia_ca_uris *sia_uris, access_method_exec rsync_cb,
                            uri_get_global(sia_uris->rpkiNotify.uri),
                            uri_get_global(sia_uris->caRepository.uri));
        } else {
-               working_repo_push(uri_get_global(sia_uris->caRepository.uri));
                pr_val_info("Couldn't fetch data from repository '%s', trying to fetch data now from RRDP '%s'.",
                    uri_get_global(sia_uris->caRepository.uri),
                    uri_get_global(sia_uris->rpkiNotify.uri));
@@ -2132,8 +2130,6 @@ use_access_method(struct sia_ca_uris *sia_uris, access_method_exec rsync_cb,
        /* Retry if rrdp was the first option but failed */
        (*retry_repo_sync) = primary_rrdp;
        error = cb_secondary(sia_uris);
-       /* No need to remember the working repository anymore */
-       working_repo_pop();
 
 verify_mft:
        /* Reach here on error or when both access methods were utilized */
index 8f96a1327efa42a62962f09314eb5b2da4bb7f46..62881fb29cb6a4885b6a12572ad407f9c9d0681d 100644 (file)
@@ -458,8 +458,7 @@ tal_get_spki(struct tal *tal, unsigned char const **buffer, size_t *len)
  * have been extracted from a TAL.
  */
 static int
-handle_tal_uri(struct tal *tal, struct rpki_uri *uri,
-    struct validation_thread *thread)
+handle_tal_uri(struct tal *tal, struct rpki_uri *uri, void *arg)
 {
        /*
         * Because of the way the foreach iterates, this function must return
@@ -476,11 +475,14 @@ handle_tal_uri(struct tal *tal, struct rpki_uri *uri,
         */
 
        struct validation_handler validation_handler;
+       struct validation_thread *thread;
        struct validation *state;
        struct cert_stack *certstack;
        struct deferred_cert deferred;
        int error;
 
+       thread = arg;
+
        validation_handler.handle_roa_v4 = handle_roa_v4;
        validation_handler.handle_roa_v6 = handle_roa_v6;
        validation_handler.handle_router_key = handle_router_key;
@@ -507,7 +509,6 @@ handle_tal_uri(struct tal *tal, struct rpki_uri *uri,
 
                /* Reminder: there's a positive error: EREQFAILED */
                if (error) {
-                       working_repo_push(uri_get_global(uri));
                        validation_destroy(state);
                        return pr_val_warn(
                            "TAL URI '%s' could not be downloaded.",
@@ -524,7 +525,6 @@ handle_tal_uri(struct tal *tal, struct rpki_uri *uri,
 
        /* At least one URI was sync'd */
        thread->retry_local = false;
-       working_repo_pop();
 
        pr_val_debug("TAL URI '%s' {", uri_val_get_printable(uri));
 
@@ -592,25 +592,6 @@ end:       validation_destroy(state);
        return error;
 }
 
-static int
-__handle_tal_uri_sync(struct tal *tal, struct rpki_uri *uri, void *arg)
-{
-       int error;
-
-       error = handle_tal_uri(tal, uri, arg);
-       if (error)
-               return error;
-       working_repo_push(uri_get_global(uri));
-
-       return 0;
-}
-
-static int
-__handle_tal_uri_local(struct tal *tal, struct rpki_uri *uri, void *arg)
-{
-       return handle_tal_uri(tal, uri, arg);
-}
-
 static void
 do_file_validation(void *thread_arg)
 {
@@ -621,15 +602,13 @@ do_file_validation(void *thread_arg)
        fnstack_init();
        fnstack_push(thread->tal_file);
 
-       working_repo_init();
-
        error = tal_load(thread->tal_file, &tal);
        if (error)
                goto end;
 
        tal_order_uris(tal);
 
-       error = foreach_uri(tal, __handle_tal_uri_sync, thread);
+       error = foreach_uri(tal, handle_tal_uri, thread);
        if (error > 0) {
                error = 0;
                goto destroy_tal;
@@ -646,7 +625,7 @@ do_file_validation(void *thread_arg)
        thread->sync_files = false;
        pr_val_warn("Looking for the TA certificate at the local files.");
 
-       error = foreach_uri(tal, __handle_tal_uri_local, thread);
+       error = foreach_uri(tal, handle_tal_uri, thread);
        if (error > 0)
                error = 0;
        else if (error == 0)
@@ -656,7 +635,6 @@ do_file_validation(void *thread_arg)
 destroy_tal:
        tal_destroy(tal);
 end:
-       working_repo_cleanup();
        fnstack_cleanup();
        thread->exit_status = error;
 }
index 35cd5d8f60f442c12508909a3694ae1957799042..8fa3961c2f38a3058d4ca944fc4c8e8cc40cac8b 100644 (file)
@@ -13,7 +13,6 @@
 
 static pthread_key_t state_key;
 static pthread_key_t filenames_key;
-static pthread_key_t repository_key;
 
 struct filename_stack {
        /* This can be NULL. Abort all operations if this is the case. */
@@ -22,10 +21,6 @@ struct filename_stack {
        unsigned int size;
 };
 
-struct working_repo {
-       char const *uri;
-};
-
 static void
 fnstack_discard(void *arg)
 {
@@ -34,13 +29,6 @@ fnstack_discard(void *arg)
        free(files);
 }
 
-static void
-working_repo_discard(void *arg)
-{
-       struct working_repo *repo = arg;
-       free(repo);
-}
-
 /** Initializes this entire module. Call once per runtime lifetime. */
 int
 thvar_init(void)
@@ -69,14 +57,6 @@ thvar_init(void)
                return error;
        }
 
-       error = pthread_key_create(&repository_key, working_repo_discard);
-       if (error) {
-               pr_op_err(
-                   "Fatal: Errcode %d while initializing the 'working repository' thread variable.",
-                   error);
-               return error;
-       }
-
        return 0;
 }
 
@@ -226,81 +206,6 @@ fnstack_pop(void)
        files->len--;
 }
 
-/** Initializes the current thread's working repo. Call once per thread. */
-void
-working_repo_init(void)
-{
-       struct working_repo *repo;
-       int error;
-
-       repo = pmalloc(sizeof(struct working_repo));
-
-       repo->uri = NULL;
-
-       error = pthread_setspecific(repository_key, repo);
-       if (error)
-               pr_op_err("pthread_setspecific() returned %d.", error);
-}
-
-void
-working_repo_cleanup(void)
-{
-       struct working_repo *repo;
-       int error;
-
-       repo = pthread_getspecific(repository_key);
-       if (repo == NULL)
-               return;
-
-       working_repo_discard(repo);
-
-       error = pthread_setspecific(repository_key, NULL);
-       if (error)
-               pr_op_err("pthread_setspecific() returned %d.", error);
-}
-
-/*
- * Call whenever a certificate has more than one repository where its childs
- * live (rsync or RRDP).
- */
-void
-working_repo_push(char const *location)
-{
-       struct working_repo *repo;
-
-       repo = pthread_getspecific(repository_key);
-       if (repo == NULL)
-               return;
-
-       repo->uri = location;
-}
-
-char const *
-working_repo_peek(void)
-{
-       struct working_repo *repo;
-
-       repo = pthread_getspecific(repository_key);
-
-       return repo == NULL ? NULL : repo->uri;
-}
-
-/*
- * Call once the certificate's repositories were downloaded (either successful
- * or erroneously).
- */
-void
-working_repo_pop(void)
-{
-       struct working_repo *repo;
-
-       repo = pthread_getspecific(repository_key);
-       if (repo == NULL)
-               return;
-
-       repo->uri = NULL;
-}
-
 static char const *
 addr2str(int af, void const *addr, char *(*buffer_cb)(struct validation *))
 {
index 4dfe1abc4a1630d5e5cf2972f1e396853ee00777..15769964b090d069de0c9f33fc9882acba9aa932 100644 (file)
@@ -16,14 +16,6 @@ void fnstack_push_uri(struct rpki_uri *);
 char const *fnstack_peek(void);
 void fnstack_pop(void);
 
-void working_repo_init(void);
-void working_repo_cleanup(void);
-
-/* TODO (#78) remove? */
-void working_repo_push(char const *);
-char const *working_repo_peek(void);
-void working_repo_pop(void);
-
 /* Please remember that these functions can only be used during validations. */
 char const *v4addr2str(struct in_addr const *);
 char const *v4addr2str2(struct in_addr const *);