summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:28:35 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-11-21 13:28:35 +0000
commitd4c259af8b5a77d599c11a2f0611ab1cfb868044 (patch)
tree071577a8a918776b060709e1484d203e389ea2a6
parente9e7239fa15efe453248b73d1958a2279f2bb722 (diff)
Adjust bgpd to the new msgbuf_write / ibuf_write API
OK tb@
-rw-r--r--usr.sbin/bgpd/bgpd.h3
-rw-r--r--usr.sbin/bgpd/mrt.c6
-rw-r--r--usr.sbin/bgpd/rde.c12
-rw-r--r--usr.sbin/bgpd/rtr_proto.c6
-rw-r--r--usr.sbin/bgpd/session.c21
5 files changed, 24 insertions, 24 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index afea5600394..33195a17ffe 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.498 2024/10/08 12:28:09 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.499 2024/11/21 13:28:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1399,6 +1399,7 @@ struct mrt {
LIST_ENTRY(mrt) entry;
uint32_t peer_id;
uint32_t group_id;
+ int fd;
enum mrt_type type;
enum mrt_state state;
uint16_t seqnum;
diff --git a/usr.sbin/bgpd/mrt.c b/usr.sbin/bgpd/mrt.c
index 7a53a9d7419..2e8f085bcf1 100644
--- a/usr.sbin/bgpd/mrt.c
+++ b/usr.sbin/bgpd/mrt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mrt.c,v 1.119 2024/11/21 13:26:49 claudio Exp $ */
+/* $OpenBSD: mrt.c,v 1.120 2024/11/21 13:28:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -1110,7 +1110,7 @@ fail:
void
mrt_write(struct mrt *mrt)
{
- if (ibuf_write(&mrt->wbuf) == -1) {
+ if (ibuf_write(mrt->fd, &mrt->wbuf) == -1) {
log_warn("mrt dump aborted, mrt_write");
mrt_clean(mrt);
mrt_done(mrt);
@@ -1120,7 +1120,7 @@ mrt_write(struct mrt *mrt)
void
mrt_clean(struct mrt *mrt)
{
- close(mrt->wbuf.fd);
+ close(mrt->fd);
msgbuf_clear(&mrt->wbuf);
}
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 8873c85daad..6e6886343c8 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.637 2024/11/21 13:18:38 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.638 2024/11/21 13:28:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -246,11 +246,11 @@ rde_main(int debug, int verbose)
if (i >= pfd_elms)
fatalx("poll pfd too small");
if (msgbuf_queuelen(&mctx->mrt.wbuf) > 0) {
- pfd[i].fd = mctx->mrt.wbuf.fd;
+ pfd[i].fd = mctx->mrt.fd;
pfd[i].events = POLLOUT;
i++;
} else if (mctx->mrt.state == MRT_STATE_REMOVE) {
- close(mctx->mrt.wbuf.fd);
+ close(mctx->mrt.fd);
LIST_REMOVE(mctx, entry);
free(mctx);
rde_mrt_cnt--;
@@ -299,7 +299,7 @@ rde_main(int debug, int verbose)
for (j = PFD_PIPE_COUNT, mctx = LIST_FIRST(&rde_mrts);
j < i && mctx != 0; j++) {
- if (pfd[j].fd == mctx->mrt.wbuf.fd &&
+ if (pfd[j].fd == mctx->mrt.fd &&
pfd[j].revents & POLLOUT)
mrt_write(&mctx->mrt);
mctx = LIST_NEXT(mctx, entry);
@@ -345,7 +345,7 @@ rde_main(int debug, int verbose)
while ((mctx = LIST_FIRST(&rde_mrts)) != NULL) {
msgbuf_clear(&mctx->mrt.wbuf);
- close(mctx->mrt.wbuf.fd);
+ close(mctx->mrt.fd);
LIST_REMOVE(mctx, entry);
free(mctx);
}
@@ -3214,7 +3214,7 @@ rde_dump_mrt_new(struct mrt *mrt, pid_t pid, int fd)
}
memcpy(&ctx->mrt, mrt, sizeof(struct mrt));
msgbuf_init(&ctx->mrt.wbuf);
- ctx->mrt.wbuf.fd = fd;
+ ctx->mrt.fd = fd;
ctx->mrt.state = MRT_STATE_RUNNING;
rid = rib_find(ctx->mrt.rib);
if (rid == RIB_NOTFOUND) {
diff --git a/usr.sbin/bgpd/rtr_proto.c b/usr.sbin/bgpd/rtr_proto.c
index 150f1434f0d..4e0ca1aa128 100644
--- a/usr.sbin/bgpd/rtr_proto.c
+++ b/usr.sbin/bgpd/rtr_proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtr_proto.c,v 1.43 2024/11/21 13:27:40 claudio Exp $ */
+/* $OpenBSD: rtr_proto.c,v 1.44 2024/11/21 13:28:34 claudio Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -1272,7 +1272,7 @@ rtr_dispatch_msg(struct pollfd *pfd, struct rtr_session *rs)
return;
}
if (pfd->revents & POLLOUT && msgbuf_queuelen(&rs->w) > 0) {
- if (ibuf_write(&rs->w) == -1) {
+ if (ibuf_write(rs->fd, &rs->w) == -1) {
log_warn("rtr %s: write error", log_rtr(rs));
rtr_fsm(rs, RTR_EVNT_CON_CLOSE);
return;
@@ -1468,7 +1468,7 @@ rtr_open(struct rtr_session *rs, int fd)
rs->prev_version = rtr_max_session_version(rs);
}
- rs->fd = rs->w.fd = fd;
+ rs->fd = fd;
rtr_fsm(rs, RTR_EVNT_CON_OPEN);
}
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 49b83b8e7ea..49d178a57bb 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.491 2024/11/21 13:27:40 claudio Exp $ */
+/* $OpenBSD: session.c,v 1.492 2024/11/21 13:28:34 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -435,7 +435,7 @@ session_main(int debug, int verbose)
LIST_FOREACH(m, &mrthead, entry)
if (msgbuf_queuelen(&m->wbuf) > 0) {
- pfd[i].fd = m->wbuf.fd;
+ pfd[i].fd = m->fd;
pfd[i].events = POLLOUT;
mrt_l[i - idx_peers] = m;
i++;
@@ -564,7 +564,7 @@ void
init_peer(struct peer *p)
{
TAILQ_INIT(&p->timers);
- p->fd = p->wbuf.fd = -1;
+ p->fd = -1;
if (p->conf.if_depend[0])
imsg_compose(ibuf_main, IMSG_SESSION_DEPENDON, 0, 0, -1,
@@ -865,7 +865,7 @@ session_close_connection(struct peer *peer)
close(peer->fd);
pauseaccept = 0;
}
- peer->fd = peer->wbuf.fd = -1;
+ peer->fd = -1;
}
void
@@ -887,7 +887,7 @@ change_state(struct peer *peer, enum session_state state,
*/
if (peer->state >= STATE_OPENSENT &&
msgbuf_queuelen(&peer->wbuf) > 0)
- ibuf_write(&peer->wbuf);
+ ibuf_write(peer->fd, &peer->wbuf);
/*
* we must start the timer for the next EVNT_START
@@ -1044,7 +1044,7 @@ open:
close(connfd);
return;
}
- p->fd = p->wbuf.fd = connfd;
+ p->fd = connfd;
if (session_setup_socket(p)) {
close(connfd);
return;
@@ -1095,7 +1095,6 @@ session_connect(struct peer *peer)
if (tcp_md5_set(peer->fd, &peer->auth_conf,
&peer->conf.remote_addr) == -1)
log_peer_warn(&peer->conf, "setting md5sig");
- peer->wbuf.fd = peer->fd;
/* if local-address is set we need to bind() */
bind_addr = session_localaddr(peer);
@@ -1935,7 +1934,7 @@ session_dispatch_msg(struct pollfd *pfd, struct peer *p)
}
if (pfd->revents & POLLOUT && msgbuf_queuelen(&p->wbuf) > 0) {
- if (ibuf_write(&p->wbuf) == -1) {
+ if (ibuf_write(p->fd, &p->wbuf) == -1) {
if (errno == EPIPE)
log_peer_warnx(&p->conf, "Connection closed");
else
@@ -3152,7 +3151,7 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
break;
}
- if ((xmrt.wbuf.fd = imsg_get_fd(&imsg)) == -1) {
+ if ((xmrt.fd = imsg_get_fd(&imsg)) == -1) {
log_warnx("expected to receive fd for mrt dump "
"but didn't receive any");
break;
@@ -3169,9 +3168,9 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
LIST_INSERT_HEAD(&mrthead, mrt, entry);
} else {
/* old dump reopened */
- close(mrt->wbuf.fd);
+ close(mrt->fd);
}
- mrt->wbuf.fd = xmrt.wbuf.fd;
+ mrt->fd = xmrt.fd;
break;
case IMSG_MRT_CLOSE:
if (idx != PFD_PIPE_MAIN)