]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Remove the reset and merge validation handler callbacks
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 3 Jun 2019 21:50:31 +0000 (16:50 -0500)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Mon, 3 Jun 2019 22:12:38 +0000 (17:12 -0500)
The only certificate that can invalidate the tree is the root one.
This is because other certificates are considered subtrees, and
therefore isolated problems.

RFC 7730 seems to agree:

> If the connection to the preferred URI fails, or the retrieved CA
> certificate public key does not match the TAL public key, the RP
> SHOULD retrieve the CA certificate from the next URI

(Neither of those reasons can be caused by a subtree.)

By the time the first ROA is handled, the root certificate is
already validated. This means that Fort will never find itself
needing to invalidate previously handled ROAs. Hence, there's no
need to "reset" a ROA table nor "merge" it with a global one after
success.

Not having to track both a global and a temporal table also reduces
RAM usage.

src/console_handler.c
src/object/tal.c
src/rtr/db/roa_table.c
src/rtr/db/roa_table.h
src/rtr/db/vrps.c
src/validation_handler.c
src/validation_handler.h

index a4fc44b7a5ee9448d0f303baeb8749ec8ce48b72..fca6f5c0cac18965e8dabfb2c7e6d623af3154b8 100644 (file)
@@ -27,7 +27,6 @@ validate_into_console(void)
 {
        struct validation_handler handler;
 
-       handler.reset = NULL;
        handler.handle_roa_v4 = print_v4_roa;
        handler.handle_roa_v6 = print_v6_roa;
        handler.arg = NULL;
index 9709102961edeb3f353f457e6a59b7d891c4bb63..29f47135e36ae7437d06d9f514b6f5854ef4ace2 100644 (file)
@@ -308,10 +308,6 @@ handle_tal_uri(struct tal *tal, struct rpki_uri *uri, void *arg)
        if (error)
                return ENSURE_NEGATIVE(error);
 
-       error = vhandler_reset(arg);
-       if (error)
-               return ENSURE_NEGATIVE(error);
-
        pr_debug_add("TAL URI '%s' {", uri_get_printable(uri));
 
        if (!uri_is_certificate(uri)) {
@@ -341,6 +337,7 @@ handle_tal_uri(struct tal *tal, struct rpki_uri *uri, void *arg)
         * From now on, the tree should be considered valid, even if subsequent
         * certificates fail.
         * (the root validated successfully; subtrees are isolated problems.)
+        * Only critical errors should trigger negative result codes.
         */
 
        /* Handle every other certificate. */
@@ -357,7 +354,7 @@ handle_tal_uri(struct tal *tal, struct rpki_uri *uri, void *arg)
                        error = 1;
                        goto end;
                }
-               if (error)
+               if (error) /* All other errors are critical, currently */
                        goto fail;
 
                /*
index 905641ef241eef06e2f9e09f8f91357a6c900c83..1f738a45427b849125b9710644b7e3e32bd35caf 100644 (file)
@@ -26,8 +26,8 @@ roa_table_create(void)
        return table;
 }
 
-static void
-roa_table_cleanup(struct roa_table *table)
+void
+roa_table_destroy(struct roa_table *table)
 {
        struct hashable_roa *node;
        struct hashable_roa *tmp;
@@ -36,12 +36,7 @@ roa_table_cleanup(struct roa_table *table)
                HASH_DEL(table->roas, node);
                free(node);
        }
-}
 
-void
-roa_table_destroy(struct roa_table *table)
-{
-       roa_table_cleanup(table);
        free(table);
 }
 
@@ -60,13 +55,6 @@ roa_table_foreach_roa(struct roa_table *table, vrp_foreach_cb cb, void *arg)
        return 0;
 }
 
-int
-rtrhandler_reset(struct roa_table *table)
-{
-       roa_table_cleanup(table);
-       return 0;
-}
-
 static struct hashable_roa *
 create_roa(uint32_t asn, uint8_t max_length)
 {
@@ -158,12 +146,6 @@ roa_table_clone(struct roa_table **dst, struct roa_table *src)
        return error;
 }
 
-int
-rtrhandler_merge(struct roa_table *dst, struct roa_table *src)
-{
-       return roa_table_merge(dst, src);
-}
-
 void
 roa_table_remove_roa(struct roa_table *table, struct vrp const *del)
 {
index 131913044cae25a3f278becf12eeb0fa9415c82b..73648756d3a72dd2c3b2aed09e21ce396c05dfb1 100644 (file)
@@ -13,12 +13,10 @@ int roa_table_clone(struct roa_table **, struct roa_table *);
 int roa_table_foreach_roa(struct roa_table *, vrp_foreach_cb, void *);
 void roa_table_remove_roa(struct roa_table *, struct vrp const *);
 
-int rtrhandler_reset(struct roa_table *);
 int rtrhandler_handle_roa_v4(struct roa_table *, uint32_t,
     struct ipv4_prefix const *, uint8_t);
 int rtrhandler_handle_roa_v6(struct roa_table *, uint32_t,
     struct ipv6_prefix const *, uint8_t);
-int rtrhandler_merge(struct roa_table *, struct roa_table *);
 
 int compute_deltas(struct roa_table *, struct roa_table *, struct deltas **);
 
index bcbe6ede078615fec7d61367af0909c3c6af26a9..4ee53b4f64964b14b64c544ba2a8a754393af3f8 100644 (file)
@@ -88,12 +88,6 @@ vrps_destroy(void)
        pthread_rwlock_destroy(&lock); /* Nothing to do with error code */
 }
 
-static int
-__reset(void *arg)
-{
-       return rtrhandler_reset(arg);
-}
-
 int
 __handle_roa_v4(uint32_t as, struct ipv4_prefix const *prefix,
     uint8_t max_length, void *arg)
@@ -111,7 +105,7 @@ __handle_roa_v6(uint32_t as, struct ipv6_prefix const * prefix,
 static int
 __perform_standalone_validation(struct roa_table **result)
 {
-       struct roa_table *roas, *global_roas;
+       struct roa_table *roas;
        struct validation_handler validation_handler;
        int error;
 
@@ -119,25 +113,17 @@ __perform_standalone_validation(struct roa_table **result)
        if (roas == NULL)
                return pr_enomem();
 
-       global_roas = roa_table_create();
-       if (global_roas == NULL) {
-               roa_table_destroy(roas);
-               return pr_enomem();
-       }
-
-       validation_handler.reset = __reset;
        validation_handler.handle_roa_v4 = __handle_roa_v4;
        validation_handler.handle_roa_v6 = __handle_roa_v6;
        validation_handler.arg = roas;
 
        error = perform_standalone_validation(&validation_handler);
-       roa_table_destroy(roas);
        if (error) {
-               roa_table_destroy(global_roas);
+               roa_table_destroy(roas);
                return error;
        }
 
-       *result = global_roas;
+       *result = roas;
        return 0;
 }
 
index 94861e8570b77ffa8bfb69514bfc404035cd4b94..83348da4c57c783cbcbd1f8df2b54fc07666d840 100644 (file)
@@ -4,12 +4,6 @@
 #include "log.h"
 #include "thread_var.h"
 
-int
-vhandler_reset(struct validation_handler *handler)
-{
-       return (handler->reset != NULL) ? handler->reset(handler->arg) : 0;
-}
-
 static int
 get_current_threads_handler(struct validation_handler const **result)
 {
index 2bd4460244560b389cf30ef3322fe94faaa9a79a..fc557a205831ff9422afdc0e52ab9e05a535feed 100644 (file)
  * All of these functions can be NULL.
  */
 struct validation_handler {
-       /**
-        * Reinitializator; called every time Fort needs to invalidate a tree
-        * that was presumed to be correct thus far.
-        * (Implementor should invalidate all ROAs collected by handle_roa_v4()
-        * and handle_roa_v6().)
-        */
-       int (*reset)(void *);
        /** Called every time Fort has successfully validated an IPv4 ROA. */
        int (*handle_roa_v4)(uint32_t, struct ipv4_prefix const *, uint8_t,
            void *);
@@ -39,7 +32,6 @@ struct validation_handler {
        void *arg;
 };
 
-int vhandler_reset(struct validation_handler *);
 int vhandler_handle_roa_v4(uint32_t, struct ipv4_prefix const *, uint8_t);
 int vhandler_handle_roa_v6(uint32_t, struct ipv6_prefix const *, uint8_t);