summaryrefslogtreecommitdiff
path: root/usr.sbin/rpki-client
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:30:18 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:30:18 +0000
commit8d82387b5156480b1f77d5c3eb2adcd93f870f74 (patch)
treebbc587961d5e003b4f5d07a59d4904835e829b2d /usr.sbin/rpki-client
parent3da86e2f55552de4b0d297bf96a123a724fa3bea (diff)
Adjust rpki-client to new msgbuf API
OK tb@
Diffstat (limited to 'usr.sbin/rpki-client')
-rw-r--r--usr.sbin/rpki-client/filemode.c15
-rw-r--r--usr.sbin/rpki-client/http.c15
-rw-r--r--usr.sbin/rpki-client/main.c44
-rw-r--r--usr.sbin/rpki-client/parser.c16
-rw-r--r--usr.sbin/rpki-client/rrdp.c21
-rw-r--r--usr.sbin/rpki-client/rsync.c15
6 files changed, 67 insertions, 59 deletions
diff --git a/usr.sbin/rpki-client/filemode.c b/usr.sbin/rpki-client/filemode.c
index 72999f47763..d458cbc8356 100644
--- a/usr.sbin/rpki-client/filemode.c
+++ b/usr.sbin/rpki-client/filemode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: filemode.c,v 1.54 2024/11/21 13:28:54 claudio Exp $ */
+/* $OpenBSD: filemode.c,v 1.55 2024/11/21 13:30:17 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -724,8 +724,8 @@ void
proc_filemode(int fd)
{
struct entityq q;
- struct msgbuf msgq;
struct pollfd pfd;
+ struct msgbuf *msgq;
struct entity *entp;
struct ibuf *b, *inbuf = NULL;
@@ -748,12 +748,13 @@ proc_filemode(int fd)
TAILQ_INIT(&q);
- msgbuf_init(&msgq);
+ if ((msgq = msgbuf_new()) == NULL)
+ err(1, NULL);
pfd.fd = fd;
for (;;) {
pfd.events = POLLIN;
- if (msgbuf_queuelen(&msgq) > 0)
+ if (msgbuf_queuelen(msgq) > 0)
pfd.events |= POLLOUT;
if (poll(&pfd, 1, INFTIM) == -1) {
@@ -782,7 +783,7 @@ proc_filemode(int fd)
}
if (pfd.revents & POLLOUT) {
- if (msgbuf_write(fd, &msgq) == -1) {
+ if (msgbuf_write(fd, msgq) == -1) {
if (errno == EPIPE)
errx(1, "write: connection closed");
else
@@ -790,10 +791,10 @@ proc_filemode(int fd)
}
}
- parse_file(&q, &msgq);
+ parse_file(&q, msgq);
}
- msgbuf_clear(&msgq);
+ msgbuf_free(msgq);
while ((entp = TAILQ_FIRST(&q)) != NULL) {
TAILQ_REMOVE(&q, entp, entries);
entity_free(entp);
diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c
index ba5a6d3eabc..b1518cf719d 100644
--- a/usr.sbin/rpki-client/http.c
+++ b/usr.sbin/rpki-client/http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: http.c,v 1.90 2024/11/21 13:28:54 claudio Exp $ */
+/* $OpenBSD: http.c,v 1.91 2024/11/21 13:30:17 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -163,7 +163,7 @@ static struct http_conn_list idle = LIST_HEAD_INITIALIZER(idle);
static struct http_req_queue queue = TAILQ_HEAD_INITIALIZER(queue);
static unsigned int http_conn_count;
-static struct msgbuf msgq;
+static struct msgbuf *msgq;
static struct sockaddr_storage http_bindaddr;
static struct tls_config *tls_config;
static uint8_t *tls_ca_mem;
@@ -625,7 +625,7 @@ http_req_done(unsigned int id, enum http_result res, const char *last_modified)
io_simple_buffer(b, &id, sizeof(id));
io_simple_buffer(b, &res, sizeof(res));
io_str_buffer(b, last_modified);
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
}
/*
@@ -641,7 +641,7 @@ http_req_fail(unsigned int id)
io_simple_buffer(b, &id, sizeof(id));
io_simple_buffer(b, &res, sizeof(res));
io_str_buffer(b, NULL);
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
}
/*
@@ -2066,7 +2066,8 @@ proc_http(char *bind_addr, int fd)
if (pledge("stdio inet dns recvfd", NULL) == -1)
err(1, "pledge");
- msgbuf_init(&msgq);
+ if ((msgq = msgbuf_new()) == NULL)
+ err(1, NULL);
for (;;) {
time_t now;
@@ -2076,7 +2077,7 @@ proc_http(char *bind_addr, int fd)
memset(&pfds, 0, sizeof(pfds));
pfds[0].fd = fd;
pfds[0].events = POLLIN;
- if (msgbuf_queuelen(&msgq) > 0)
+ if (msgbuf_queuelen(msgq) > 0)
pfds[0].events |= POLLOUT;
i = 1;
@@ -2137,7 +2138,7 @@ proc_http(char *bind_addr, int fd)
if (pfds[0].revents & POLLHUP)
break;
if (pfds[0].revents & POLLOUT) {
- if (msgbuf_write(fd, &msgq) == -1) {
+ if (msgbuf_write(fd, msgq) == -1) {
if (errno == EPIPE)
errx(1, "write: connection closed");
else
diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c
index b5c6250fda1..acf836b12fe 100644
--- a/usr.sbin/rpki-client/main.c
+++ b/usr.sbin/rpki-client/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.273 2024/11/21 13:28:54 claudio Exp $ */
+/* $OpenBSD: main.c,v 1.274 2024/11/21 13:30:17 claudio Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -60,7 +60,7 @@ volatile sig_atomic_t killme;
void suicide(int sig);
static struct filepath_tree fpt = RB_INITIALIZER(&fpt);
-static struct msgbuf procq, rsyncq, httpq, rrdpq;
+static struct msgbuf *procq, *rsyncq, *httpq, *rrdpq;
static int cachefd, outdirfd;
const char *bird_tablename = "ROAS";
@@ -182,7 +182,7 @@ entity_write_req(const struct entity *ent)
io_str_buffer(b, ent->file);
io_str_buffer(b, ent->mftaki);
io_buf_buffer(b, ent->data, ent->datasz);
- io_close_buffer(&procq, b);
+ io_close_buffer(procq, b);
}
static void
@@ -208,7 +208,7 @@ entity_write_repo(const struct repo *rp)
io_str_buffer(b, altpath);
io_buf_buffer(b, NULL, 0); /* ent->mftaki */
io_buf_buffer(b, NULL, 0); /* ent->data */
- io_close_buffer(&procq, b);
+ io_close_buffer(procq, b);
free(path);
free(altpath);
}
@@ -279,7 +279,7 @@ rrdp_file_resp(unsigned int id, int ok)
io_simple_buffer(b, &type, sizeof(type));
io_simple_buffer(b, &id, sizeof(id));
io_simple_buffer(b, &ok, sizeof(ok));
- io_close_buffer(&rrdpq, b);
+ io_close_buffer(rrdpq, b);
}
void
@@ -296,7 +296,7 @@ rrdp_fetch(unsigned int id, const char *uri, const char *local,
io_str_buffer(b, uri);
rrdp_session_buffer(b, s);
- io_close_buffer(&rrdpq, b);
+ io_close_buffer(rrdpq, b);
}
void
@@ -308,7 +308,7 @@ rrdp_abort(unsigned int id)
b = io_new_buffer();
io_simple_buffer(b, &type, sizeof(type));
io_simple_buffer(b, &id, sizeof(id));
- io_close_buffer(&rrdpq, b);
+ io_close_buffer(rrdpq, b);
}
/*
@@ -325,7 +325,7 @@ rsync_fetch(unsigned int id, const char *uri, const char *local,
io_str_buffer(b, local);
io_str_buffer(b, base);
io_str_buffer(b, uri);
- io_close_buffer(&rsyncq, b);
+ io_close_buffer(rsyncq, b);
}
void
@@ -338,7 +338,7 @@ rsync_abort(unsigned int id)
io_str_buffer(b, NULL);
io_str_buffer(b, NULL);
io_str_buffer(b, NULL);
- io_close_buffer(&rsyncq, b);
+ io_close_buffer(rsyncq, b);
}
/*
@@ -355,7 +355,7 @@ http_fetch(unsigned int id, const char *uri, const char *last_mod, int fd)
io_str_buffer(b, last_mod);
/* pass file as fd */
ibuf_fd_set(b, fd);
- io_close_buffer(&httpq, b);
+ io_close_buffer(httpq, b);
}
/*
@@ -376,7 +376,7 @@ rrdp_http_fetch(unsigned int id, const char *uri, const char *last_mod)
io_simple_buffer(b, &type, sizeof(type));
io_simple_buffer(b, &id, sizeof(id));
ibuf_fd_set(b, pi[0]);
- io_close_buffer(&rrdpq, b);
+ io_close_buffer(rrdpq, b);
http_fetch(id, uri, last_mod, pi[1]);
}
@@ -393,7 +393,7 @@ rrdp_http_done(unsigned int id, enum http_result res, const char *last_mod)
io_simple_buffer(b, &id, sizeof(id));
io_simple_buffer(b, &res, sizeof(res));
io_str_buffer(b, last_mod);
- io_close_buffer(&rrdpq, b);
+ io_close_buffer(rrdpq, b);
}
/*
@@ -1231,10 +1231,14 @@ main(int argc, char *argv[])
if (pledge("stdio rpath wpath cpath fattr sendfd unveil", NULL) == -1)
err(1, "pledge");
- msgbuf_init(&procq);
- msgbuf_init(&rsyncq);
- msgbuf_init(&httpq);
- msgbuf_init(&rrdpq);
+ if ((procq = msgbuf_new()) == NULL)
+ err(1, NULL);
+ if ((rsyncq = msgbuf_new()) == NULL)
+ err(1, NULL);
+ if ((httpq = msgbuf_new()) == NULL)
+ err(1, NULL);
+ if ((rrdpq = msgbuf_new()) == NULL)
+ err(1, NULL);
/*
* The main process drives the top-down scan to leaf ROAs using
@@ -1243,13 +1247,13 @@ main(int argc, char *argv[])
*/
pfd[0].fd = procfd;
- queues[0] = &procq;
+ queues[0] = procq;
pfd[1].fd = rsyncfd;
- queues[1] = &rsyncq;
+ queues[1] = rsyncq;
pfd[2].fd = httpfd;
- queues[2] = &httpq;
+ queues[2] = httpq;
pfd[3].fd = rrdpfd;
- queues[3] = &rrdpq;
+ queues[3] = rrdpq;
load_skiplist(skiplistfile);
diff --git a/usr.sbin/rpki-client/parser.c b/usr.sbin/rpki-client/parser.c
index 29ff2506d2c..21c4a82d6b6 100644
--- a/usr.sbin/rpki-client/parser.c
+++ b/usr.sbin/rpki-client/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.146 2024/11/21 13:28:54 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.147 2024/11/21 13:30:17 claudio Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1046,7 +1046,7 @@ void
proc_parser(int fd)
{
struct entityq q;
- struct msgbuf msgq;
+ struct msgbuf *msgq;
struct pollfd pfd;
struct entity *entp;
struct ibuf *b, *inbuf = NULL;
@@ -1070,13 +1070,14 @@ proc_parser(int fd)
TAILQ_INIT(&q);
- msgbuf_init(&msgq);
+ if ((msgq = msgbuf_new()) == NULL)
+ err(1, NULL);
pfd.fd = fd;
for (;;) {
pfd.events = POLLIN;
- if (msgbuf_queuelen(&msgq) > 0)
+ if (msgbuf_queuelen(msgq) > 0)
pfd.events |= POLLOUT;
if (poll(&pfd, 1, INFTIM) == -1) {
@@ -1105,7 +1106,7 @@ proc_parser(int fd)
}
if (pfd.revents & POLLOUT) {
- if (msgbuf_write(fd, &msgq) == -1) {
+ if (msgbuf_write(fd, msgq) == -1) {
if (errno == EPIPE)
errx(1, "write: connection closed");
else
@@ -1113,7 +1114,7 @@ proc_parser(int fd)
}
}
- parse_entity(&q, &msgq);
+ parse_entity(&q, msgq);
}
while ((entp = TAILQ_FIRST(&q)) != NULL) {
@@ -1127,8 +1128,7 @@ proc_parser(int fd)
X509_STORE_CTX_free(ctx);
BN_CTX_free(bn_ctx);
- msgbuf_clear(&msgq);
-
+ msgbuf_free(msgq);
ibuf_free(inbuf);
if (certid > CERTID_MAX)
diff --git a/usr.sbin/rpki-client/rrdp.c b/usr.sbin/rpki-client/rrdp.c
index b480e020f0d..bd24a73ddc9 100644
--- a/usr.sbin/rpki-client/rrdp.c
+++ b/usr.sbin/rpki-client/rrdp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rrdp.c,v 1.37 2024/11/21 13:28:54 claudio Exp $ */
+/* $OpenBSD: rrdp.c,v 1.38 2024/11/21 13:30:17 claudio Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
@@ -36,7 +36,7 @@
#define MAX_SESSIONS 32
#define READ_BUF_SIZE (32 * 1024)
-static struct msgbuf msgq;
+static struct msgbuf *msgq;
#define RRDP_STATE_REQ 0x01
#define RRDP_STATE_WAIT 0x02
@@ -98,7 +98,7 @@ rrdp_done(unsigned int id, int ok)
io_simple_buffer(b, &type, sizeof(type));
io_simple_buffer(b, &id, sizeof(id));
io_simple_buffer(b, &ok, sizeof(ok));
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
}
/*
@@ -120,7 +120,7 @@ rrdp_http_req(unsigned int id, const char *uri, const char *last_mod)
io_simple_buffer(b, &id, sizeof(id));
io_str_buffer(b, uri);
io_str_buffer(b, last_mod);
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
}
/*
@@ -136,7 +136,7 @@ rrdp_state_send(struct rrdp *s)
io_simple_buffer(b, &type, sizeof(type));
io_simple_buffer(b, &s->id, sizeof(s->id));
rrdp_session_buffer(b, s->current);
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
}
/*
@@ -151,7 +151,7 @@ rrdp_clear_repo(struct rrdp *s)
b = io_new_buffer();
io_simple_buffer(b, &type, sizeof(type));
io_simple_buffer(b, &s->id, sizeof(s->id));
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
}
/*
@@ -174,7 +174,7 @@ rrdp_publish_file(struct rrdp *s, struct publish_xml *pxml,
io_simple_buffer(b, &pxml->hash, sizeof(pxml->hash));
io_str_buffer(b, pxml->uri);
io_buf_buffer(b, data, datasz);
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
s->file_pending++;
}
}
@@ -543,7 +543,8 @@ proc_rrdp(int fd)
if (pledge("stdio recvfd", NULL) == -1)
err(1, "pledge");
- msgbuf_init(&msgq);
+ if ((msgq = msgbuf_new()) == NULL)
+ err(1, NULL);
for (;;) {
i = 1;
@@ -584,7 +585,7 @@ proc_rrdp(int fd)
*/
pfds[0].fd = fd;
pfds[0].events = POLLIN;
- if (msgbuf_queuelen(&msgq) > 0)
+ if (msgbuf_queuelen(msgq) > 0)
pfds[0].events |= POLLOUT;
if (poll(pfds, i, INFTIM) == -1) {
@@ -596,7 +597,7 @@ proc_rrdp(int fd)
if (pfds[0].revents & POLLHUP)
break;
if (pfds[0].revents & POLLOUT) {
- if (msgbuf_write(fd, &msgq) == -1) {
+ if (msgbuf_write(fd, msgq) == -1) {
if (errno == EPIPE)
errx(1, "write: connection closed");
else
diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c
index 8ef188c7504..d8612a57ce2 100644
--- a/usr.sbin/rpki-client/rsync.c
+++ b/usr.sbin/rpki-client/rsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsync.c,v 1.54 2024/11/21 13:28:54 claudio Exp $ */
+/* $OpenBSD: rsync.c,v 1.55 2024/11/21 13:30:17 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -226,7 +226,7 @@ proc_rsync(char *prog, char *bind_addr, int fd)
{
int nprocs = 0, npending = 0, rc = 0;
struct pollfd pfd;
- struct msgbuf msgq;
+ struct msgbuf *msgq;
struct ibuf *b, *inbuf = NULL;
sigset_t mask, oldmask;
struct rsync *s, *ns;
@@ -234,7 +234,8 @@ proc_rsync(char *prog, char *bind_addr, int fd)
if (pledge("stdio rpath proc exec unveil", NULL) == -1)
err(1, "pledge");
- msgbuf_init(&msgq);
+ if ((msgq = msgbuf_new()) == NULL)
+ err(1, NULL);
pfd.fd = fd;
/*
@@ -293,7 +294,7 @@ proc_rsync(char *prog, char *bind_addr, int fd)
pfd.events = 0;
pfd.events |= POLLIN;
- if (msgbuf_queuelen(&msgq) > 0)
+ if (msgbuf_queuelen(msgq) > 0)
pfd.events |= POLLOUT;
if (npending > 0 && nprocs < MAX_RSYNC_REQUESTS) {
@@ -342,7 +343,7 @@ proc_rsync(char *prog, char *bind_addr, int fd)
b = io_new_buffer();
io_simple_buffer(b, &s->id, sizeof(s->id));
io_simple_buffer(b, &ok, sizeof(ok));
- io_close_buffer(&msgq, b);
+ io_close_buffer(msgq, b);
rsync_free(s);
nprocs--;
@@ -354,7 +355,7 @@ proc_rsync(char *prog, char *bind_addr, int fd)
}
if (pfd.revents & POLLOUT) {
- if (msgbuf_write(fd, &msgq) == -1) {
+ if (msgbuf_write(fd, msgq) == -1) {
if (errno == EPIPE)
errx(1, "write: connection closed");
else
@@ -404,6 +405,6 @@ proc_rsync(char *prog, char *bind_addr, int fd)
rsync_free(s);
}
- msgbuf_clear(&msgq);
+ msgbuf_free(msgq);
exit(rc);
}