Index | Thread | Search

From:
Job Snijders <job@bsd.nl>
Subject:
Re: rpki-client: add rsync baseuri-based batching
To:
Theo Buehler <tb@theobuehler.org>
Cc:
tech@openbsd.org
Date:
Wed, 8 Jul 2026 18:11:49 +0000

Download raw body.

Thread
With the dedup refactor out of the way, perhaps rsync baseuri batching
could be done as follows?

I think this also fixes a fresh bug in ncas_plan_retries(), in the
second RB_FOREACH there is a break statement that should've been cleaned
up when the inner fqdn loop was refactored away. Additionally, only
consider rpkiNotify URIs when RRDP actually is in play.

Index: extern.h
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/extern.h,v
diff -u -p -r1.288 extern.h
--- extern.h	8 Jul 2026 17:49:04 -0000	1.288
+++ extern.h	8 Jul 2026 18:07:38 -0000
@@ -163,6 +163,7 @@ struct nca_hist {
 	char			*ski;
 	char			*location;
 	char			*mfturi;
+	char			*baseuri;
 	char			*notify;
 	time_t			 since;
 	time_t			 last_attempt;
Index: nca.c
===================================================================
RCS file: /cvs/src/usr.sbin/rpki-client/nca.c,v
diff -u -p -r1.9 nca.c
--- nca.c	8 Jul 2026 17:49:04 -0000	1.9
+++ nca.c	8 Jul 2026 18:07:38 -0000
@@ -31,6 +31,8 @@
 
 #include "extern.h"
 
+extern int rrdpon;
+
 /*
  * Add a given CA cert into the non-functional CA tree.
  * Return 1 if a synchronization attempt is to be made, 0 otherwise.
@@ -171,6 +173,7 @@ nca_hist_free(struct nca_hist *nca_hist)
 	free(nca_hist->ski);
 	free(nca_hist->location);
 	free(nca_hist->mfturi);
+	free(nca_hist->baseuri);
 	free(nca_hist->notify);
 	free(nca_hist);
 }
@@ -222,8 +225,8 @@ nca_decide_retry(const struct nca_hist *
 
 /*
  * Determine which non-functioncal CAs are eligible for retry.
- * If multiple NCAs point to the same RRDP repo and at least one NCA is eligible
- * for retry, batch all of those together.
+ * If multiple NCAs point to the same rsync base URI or RRDP repo and at least
+ * one NCA is eligible for retry, batch all of those together.
  */
 static void
 ncas_plan_retries(void)
@@ -237,18 +240,24 @@ ncas_plan_retries(void)
 			continue;
 		}
 
-		if (nca_hist->notify != NULL)
+		strlist_insert(&batchlist, nca_hist->baseuri);
+
+		if (nca_hist->notify != NULL && rrdpon)
 			strlist_insert(&batchlist, nca_hist->notify);
 	}
 
 	RB_FOREACH(nca_hist, nca_hist_tree, &ncas_hist) {
-		if (nca_hist->notify == NULL)
+		if (strlist_find(&batchlist, nca_hist->baseuri,
+		    strlen(nca_hist->baseuri))) {
+			nca_hist->defer = 0;
 			continue;
+		}
 
-		if (strlist_find(&batchlist, nca_hist->notify,
-		    strlen(nca_hist->notify))) {
-			nca_hist->defer = 0;
-			break;
+		if (nca_hist->notify != NULL && rrdpon) {
+			if (strlist_find(&batchlist, nca_hist->notify,
+			    strlen(nca_hist->notify))) {
+				nca_hist->defer = 0;
+			}
 		}
 	}
 
@@ -347,6 +356,8 @@ nca_history_load(void)
 		if (strcmp(mfturi + mfturi_len - 4, ".mft") != 0)
 			goto err;
 		if (!valid_uri(mfturi, strlen(mfturi), RSYNC_PROTO))
+			goto err;
+		if (!rsync_base_uri(mfturi, &nca_hist->baseuri))
 			goto err;
 		if ((nca_hist->mfturi = strdup(mfturi)) == NULL)
 			err(1, NULL);