int error;
filename = str_concat(node->path, ".json");
- pr_trc("rm %s", filename);
+ pr_trc("rm -f %s", filename);
if (unlink(filename) < 0) {
error = errno;
if (error == ENOENT)
- pr_trc("%s already doesn't exist.", filename);
+ pr_clutter("%s already doesn't exist.", filename);
else
pr_wrn("Cannot rm %s: %s", filename, strerror(errno));
}
pr_trc("Refresh ongoing.");
return VV_BUSY;
case DLS_FRESH:
+ pr_trc("Already downloaded.");
break;
default:
pr_panic("Unknown node state: %d", node->state);
/* Result needs free() */
char *
-cage_map_file(struct cache_cage *cage, struct uri const *url)
+cage_map_file(struct cache_cage *cage, struct uri const *url, char const **type)
{
/*
* Remember: In addition to honoring the consts of cache->refresh and
char *file;
file = node2file(cage->refresh, url);
- if (!file)
- file = node2file(cage->fallback, url);
+ if (file) {
+ *type = cage->refresh->rrdp ? "RRDP refresh" : "rsync refresh";
+ return file;
+ }
+
+ file = node2file(cage->fallback, url);
+ if (file) {
+ *type = cage->fallback->rrdp ? "RRDP fallback" : "rsync fallback";
+ return file;
+ }
- return file;
+ return NULL;
}
/*
{
struct cache_commit *commit;
- pr_trc("Listing for commit: [%s, %s]",
+ pr_trc("Queuing RPP for commit: [%s, %s]",
rpkiNotify ? uri_str(rpkiNotify) : "NULL",
uri_str(caRepository));
STAILQ_REMOVE_HEAD(&commits, lh);
if (uri_str(&commit->caRepository) != NULL) {
- pr_trc("Creating fallback for %s (%s)",
- uri_str(&commit->caRepository),
- uri_str(&commit->rpkiNotify));
+ pr_trc("Creating fallback for [%s, %s]",
+ uri_str(&commit->rpkiNotify),
+ uri_str(&commit->caRepository));
fb = provide_node(&cache.fallback,
&commit->rpkiNotify,
} else { /* TA */
struct cache_mapping *map = &commit->files[0];
- pr_trc("Creating fallback for %s", uri_str(&map->url));
+ pr_trc("Creating fallback for [NULL, %s]",
+ uri_str(&map->url));
fb = provide_node(&cache.fallback, &map->url, NULL);
fb->attempt_ts = now;
time_t now = time_fatal();
/* Delete the entirety of cache/tmp/. */
- pr_trc("Cleaning up temporal files.");
+ pr_trc("- Cleaning up temporal files.");
file_rm_rf(CACHE_TMPDIR);
/*
* Ensure valid RPPs and TAs are linked in fallback,
* by hard-linking the new files.
*/
- pr_trc("Committing fallbacks.");
+ pr_trc("- Committing fallbacks.");
commit_fallbacks(now);
/*
* Delete refresh nodes that haven't been downloaded in a while,
* and fallback nodes that haven't been valid in a while.
*/
- pr_trc("Cleaning up abandoned cache files.");
+ pr_trc("- Cleaning up abandoned cache files.");
foreach_node(remove_abandoned, &now);
/* (Paranoid) Delete nodes that are no longer mapped to files. */
- pr_trc("Cleaning up orphaned nodes.");
+ pr_trc("- Cleaning up orphaned nodes.");
foreach_node(remove_orphaned_nodes, NULL);
/* (Paranoid) Delete files that are no longer mapped to nodes. */
- pr_trc("Cleaning up orphaned files.");
+ pr_trc("- Cleaning up orphaned files.");
remove_orphaned_files();
}
void
cache_commit(void)
{
+ pr_trc("============ Committing cache ============");
cleanup_cache();
file_write_txt(METAFILE, "{ \"fort-version\": \"" PACKAGE_VERSION "\" }");
unlock_cache();
struct cache_cage;
validation_verdict cache_refresh_by_uris(struct extension_uris *,
struct cache_cage **);
-char *cage_map_file(struct cache_cage *, struct uri const *);
+char *cage_map_file(struct cache_cage *, struct uri const *, char const **);
bool cage_downgrade(struct cache_cage *);
struct mft_meta const *cage_mft_fallback(struct cache_cage *);
void cache_commit_rpp(struct uri const *, struct uri const *, struct rpp *);
#include "alloc.h"
#include "log.h"
-validation_verdict const VV_CONTINUE = "Continue";
+validation_verdict const VV_CONTINUE = "Success";
validation_verdict const VV_FAIL = "Failure";
validation_verdict const VV_BUSY = "Busy";
int
file_write_bin(char const *path, unsigned char const *bytes, size_t n)
{
- pr_trc("echo 'beep boop' > %s", path);
return write_file(path, bytes, n);
}
pr_crypto_err("Unable to register the %s NID.", sn);
return 0;
}
- pr_trc("%s registered. Its nid is %d.", sn, nid);
+ pr_clutter("%s registered. Its nid is %d.", sn, nid);
} else {
- pr_trc("%s retrieved. Its nid is %d.", sn, nid);
+ pr_clutter("%s retrieved. Its nid is %d.", sn, nid);
}
return nid;
{
struct cache_cage *cage;
struct cache_mapping mft;
+ char const *rpp_type;
array_index i;
struct cache_mapping *map;
unsigned int queued;
validation_verdict vv;
int error;
+ pr_trc("Checking certificate %s...", uri_str(&ca->map.url));
+
if (!ca->x509) {
if (validate_certificate(ca) != 0)
return VV_FAIL;
return VV_CONTINUE;
} /* else "we already did this, and returned VV_BUSY" */
+ pr_trc("Certificate seems correct; downloading RPP.");
+
vv = cache_refresh_by_uris(&ca->uris, &cage);
if (vv == VV_BUSY)
return VV_BUSY;
}
mft.url = ca->uris.rpkiManifest;
-retry: mft.path = cage_map_file(cage, &mft.url);
+retry: mft.path = cage_map_file(cage, &mft.url, &rpp_type);
if (!mft.path) {
if (cage_downgrade(cage))
goto retry;
goto end;
}
+ pr_trc("Checking %s RPP...", rpp_type);
+
error = manifest_traverse(&mft, cage, ca);
free(mft.path);
if (error) {
ghostbusters_traverse(map, ca);
}
+ pr_trc("RPP seems sufficiently correct.");
+
if (queued > 0)
task_wakeup();
cache_commit_rpp(cage_rpkiNotify(cage), &ca->uris.caRepository,
uri_child(&rpp_url, (char const *)src->file.buf, src->file.size,
&dst->url);
- dst->path = cage_map_file(cage, &dst->url);
+ dst->path = cage_map_file(cage, &dst->url, &ext);
if (!dst->path) {
error = pr_err(
"Manifest file '%s' is absent from the cache.",
}
/* Online attempts */
+ pr_trc("Trying HTTP refresh.");
vv = try_urls(tal, uri_is_https, cache_refresh_by_url);
if (vv != VV_FAIL)
goto end2;
+ pr_trc("Trying rsync refresh.");
vv = try_urls(tal, uri_is_rsync, cache_refresh_by_url);
if (vv != VV_FAIL)
goto end2;
/* Offline fallback attempts */
+ pr_trc("Trying HTTP fallback.");
vv = try_urls(tal, uri_is_https, cache_get_fallback);
if (vv != VV_FAIL)
goto end2;
+ pr_trc("Trying rsync fallback.");
vv = try_urls(tal, uri_is_rsync, cache_get_fallback);
if (vv != VV_FAIL)
goto end2;
validation_verdict vv;
while ((task = task_dequeue(task)) != NULL) {
+ pr_trc("Dequeued task: %s", task_name(task));
+
switch (task->type) {
case VTT_RPP:
- if (cer_traverse(task->u.ca) == VV_BUSY) {
+ vv = cer_traverse(task->u.ca);
+ if (vv == VV_BUSY) {
task_requeue_dormant(task);
task = NULL;
}
task_wakeup();
}
break;
+ default:
+ vv = VV_FAIL;
}
+ pr_trc("Task ended. Status: %s", vv);
}
return NULL;
file = cache_file_add(args->state, &tag.meta.uri, path);
}
+ pr_clutter("echo '$%s' > %s", file->map.url, file->map.path);
error = file_write_bin(file->map.path, tag.content, tag.content_len);
end: metadata_cleanup(&tag.meta);
struct rrdp_state *state)
{
struct parser_args args = { .session = session, .state = state };
- return relax_ng_parse(path, xml_read_snapshot, &args);
+ int error;
+
+ pr_trc("Exploding snapshot into %s...", state->seq.prefix);
+
+ error = relax_ng_parse(path, xml_read_snapshot, &args);
+
+ pr_trc("Snapshot exploded.");
+ return error;
}
static int
int error;
url = &new->snapshot.uri;
- pr_trc("Processing snapshot '%s'.", uri_str(url));
fnstack_push(uri_str(url));
error = dl_tmp(url, tmppath);
if (error)
return error;
+ pr_trc("Exploding delta into %s...", state->seq.prefix);
session.session_id = notif->session.session_id;
session.serial = delta->serial;
args.session = &session;
args.state = state;
- return relax_ng_parse(path, xml_read_delta, &args);
+ error = relax_ng_parse(path, xml_read_delta, &args);
+
+ pr_trc("Delta exploded.");
+ return error;
}
static int
int error;
fnstack_push(uri_str(notif));
- pr_trc("Processing notification.");
error = dl_notif(notif, mtim, changed, &new);
if (error)
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t awakener = PTHREAD_COND_INITIALIZER;
-static char const *
+char const *
task_name(struct validation_task *task)
{
switch (task->type) {
}
while (ntasks > 0) {
- pr_trc("task_dequeue(): %u existing tasks.", ntasks);
+ pr_clutter("task_dequeue(): %u existing tasks.", ntasks);
task = STAILQ_FIRST(&waiting);
if (task != NULL) {
STAILQ_REMOVE_HEAD(&waiting, lh);
mutex_unlock(&lock);
- pr_trc("task_dequeue(): Claimed task '%s'.",
+ pr_clutter("task_dequeue(): Claimed task '%s'.",
task_name(task));
return task;
}
- pr_trc("task_dequeue(): Sleeping...");
+ pr_clutter("task_dequeue(): Sleeping...");
timeout.tv_sec = time_fatal() + 10;
error = pthread_cond_timedwait(&awakener, &lock, &timeout);
switch (error) {
case 0:
- pr_trc("task_dequeue(): Woke up by cond.");
+ pr_clutter("task_dequeue(): Woke up by cond.");
break;
case ETIMEDOUT:
- pr_trc("task_dequeue(): Woke up by timeout.");
+ pr_clutter("task_dequeue(): Woke up by timeout.");
break;
case EINTR:
- pr_trc("task_dequeue(): Interrupted by signal.");
+ pr_clutter("task_dequeue(): Interrupted by signal.");
goto end;
default:
panic_on_fail(error, "pthread_cond_wait");
}
}
- pr_trc("task_dequeue(): No more tasks; done.");
+ pr_clutter("task_dequeue(): No more tasks; done.");
panic_on_fail(pthread_cond_broadcast(&awakener),
"pthread_cond_broadcast");
end: mutex_unlock(&lock);
bool task_stop(void);
void task_teardown(void);
+char const *task_name(struct validation_task *);
unsigned int task_enqueue_tal(char const *);
unsigned int task_enqueue_rpp(struct cache_mapping *, struct rpki_certificate *);
void task_requeue_dormant(struct validation_task *);