summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client/repo.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2021-11-04 17:35:10 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2021-11-04 17:35:10 +0000
commit2bb8e9a495cd9050bb4b6c97a98d223798f80e0d (patch)
tree210d99687631464a13294fb6a097d64583f4c667 /usr.sbin/rpki-client/repo.c
parentdaaf312a24480a7a322b8fa289b1c8840d8bc52e (diff)
Instead of creating a struct repo for each unique caRepository URI
use the rsync URI (a base version of caRepository) and the notify URI to identify repositories. If both rsync URI and notify URI are the same then the repo is the same. The notify URI is optional and can be NULL so the lookup needs to be a bit careful. This reduces the number of struct repos from 26k to around 50. OK tb@
Diffstat (limited to 'usr.sbin/rpki-client/repo.c')
-rw-r--r--usr.sbin/rpki-client/repo.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c
index 59c0e6b5a4c..02580d53e6e 100644
--- a/usr.sbin/rpki-client/repo.c
+++ b/usr.sbin/rpki-client/repo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: repo.c,v 1.9 2021/08/12 15:27:15 claudio Exp $ */
+/* $OpenBSD: repo.c,v 1.10 2021/11/04 17:35:09 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -88,7 +88,8 @@ SLIST_HEAD(, tarepo) tarepos = SLIST_HEAD_INITIALIZER(tarepos);
struct repo {
SLIST_ENTRY(repo) entry;
- char *repouri; /* CA repository base URI */
+ char *repouri;
+ char *notifyuri;
const struct rrdprepo *rrdp;
const struct rsyncrepo *rsync;
const struct tarepo *ta;
@@ -1089,18 +1090,33 @@ ta_lookup(struct tal *tal)
struct repo *
repo_lookup(const char *uri, const char *notify)
{
- struct repo *rp;
+ struct repo *rp;
+ char *repouri;
+
+ if ((repouri = rsync_base_uri(uri)) == NULL)
+ errx(1, "bad caRepository URI: %s", uri);
/* Look up in repository table. */
SLIST_FOREACH(rp, &repos, entry) {
- if (strcmp(rp->repouri, uri) != 0)
+ if (strcmp(rp->repouri, repouri) != 0)
continue;
+ if (rp->notifyuri != NULL) {
+ if (notify == NULL)
+ continue;
+ if (strcmp(rp->notifyuri, notify) != 0)
+ continue;
+ } else if (notify != NULL)
+ continue;
+ /* found matching repo */
+ free(repouri);
return rp;
}
rp = repo_alloc();
- if ((rp->repouri = strdup(uri)) == NULL)
- err(1, NULL);
+ rp->repouri = repouri;
+ if (notify != NULL)
+ if ((rp->notifyuri = strdup(notify)) == NULL)
+ err(1, NULL);
/* try RRDP first if available */
if (notify != NULL)