Mostly straightforward conversion to imsg_get_fd() only the handling
authorclaudio <claudio@openbsd.org>
Thu, 14 Dec 2023 13:52:37 +0000 (13:52 +0000)
committerclaudio <claudio@openbsd.org>
Thu, 14 Dec 2023 13:52:37 +0000 (13:52 +0000)
of the control socket needs a local variable since imsg_get_fd() can
only be called once on an imsg.
OK tb@

usr.sbin/bgpd/rde.c
usr.sbin/bgpd/rtr.c
usr.sbin/bgpd/session.c

index ef63170..b5ba5d7 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rde.c,v 1.612 2023/11/07 11:18:35 claudio Exp $ */
+/*     $OpenBSD: rde.c,v 1.613 2023/12/14 13:52:37 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -854,7 +854,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *imsgbuf)
                case IMSG_SOCKET_CONN:
                case IMSG_SOCKET_CONN_CTL:
                case IMSG_SOCKET_CONN_RTR:
-                       if ((fd = imsg.fd) == -1) {
+                       if ((fd = imsg_get_fd(&imsg)) == -1) {
                                log_warnx("expected to receive imsg fd "
                                    "but didn't receive any");
                                break;
@@ -1229,7 +1229,7 @@ rde_dispatch_imsg_parent(struct imsgbuf *imsgbuf)
                                break;
                        }
                        memcpy(&xmrt, imsg.data, sizeof(xmrt));
-                       if ((fd = imsg.fd) == -1)
+                       if ((fd = imsg_get_fd(&imsg)) == -1)
                                log_warnx("expected to receive fd for mrt dump "
                                    "but didn't receive any");
                        else if (xmrt.type == MRT_TABLE_DUMP ||
index 0619e6a..8077e10 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rtr.c,v 1.17 2023/11/07 11:18:35 claudio Exp $ */
+/*     $OpenBSD: rtr.c,v 1.18 2023/12/14 13:52:38 claudio Exp $ */
 
 /*
  * Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
@@ -319,7 +319,7 @@ rtr_dispatch_imsg_parent(struct imsgbuf *imsgbuf)
 
                switch (imsg.hdr.type) {
                case IMSG_SOCKET_CONN_RTR:
-                       if ((fd = imsg.fd) == -1) {
+                       if ((fd = imsg_get_fd(&imsg)) == -1) {
                                log_warnx("expected to receive imsg fd "
                                    "but didn't receive any");
                                break;
@@ -335,7 +335,7 @@ rtr_dispatch_imsg_parent(struct imsgbuf *imsgbuf)
                        imsg_init(ibuf_rde, fd);
                        break;
                case IMSG_SOCKET_CONN:
-                       if ((fd = imsg.fd) == -1) {
+                       if ((fd = imsg_get_fd(&imsg)) == -1) {
                                log_warnx("expected to receive imsg fd "
                                    "but didn't receive any");
                                break;
index 7480937..c3029ac 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: session.c,v 1.455 2023/11/07 11:18:35 claudio Exp $ */
+/*     $OpenBSD: session.c,v 1.456 2023/12/14 13:52:38 claudio Exp $ */
 
 /*
  * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -2977,7 +2977,7 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
                case IMSG_SOCKET_CONN_CTL:
                        if (idx != PFD_PIPE_MAIN)
                                fatalx("reconf request not from parent");
-                       if ((fd = imsg.fd) == -1) {
+                       if ((fd = imsg_get_fd(&imsg)) == -1) {
                                log_warnx("expected to receive imsg fd to "
                                    "RDE but didn't receive any");
                                break;
@@ -3037,7 +3037,7 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
                                        fatalx("king bula sez: "
                                            "expected REINIT");
 
-                               if ((nla->fd = imsg.fd) == -1)
+                               if ((nla->fd = imsg_get_fd(&imsg)) == -1)
                                        log_warnx("expected to receive fd for "
                                            "%s but didn't receive any",
                                            log_sockaddr((struct sockaddr *)
@@ -3066,17 +3066,17 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
                            sizeof(restricted))
                                fatalx("RECONF_CTRL imsg with wrong len");
                        memcpy(&restricted, imsg.data, sizeof(restricted));
-                       if (imsg.fd == -1) {
+                       if ((fd = imsg_get_fd(&imsg)) == -1) {
                                log_warnx("expected to receive fd for control "
                                    "socket but didn't receive any");
                                break;
                        }
                        if (restricted) {
                                control_shutdown(rcsock);
-                               rcsock = imsg.fd;
+                               rcsock = fd;
                        } else {
                                control_shutdown(csock);
-                               csock = imsg.fd;
+                               csock = fd;
                        }
                        break;
                case IMSG_RECONF_DRAIN:
@@ -3166,7 +3166,7 @@ session_dispatch_imsg(struct imsgbuf *imsgbuf, int idx, u_int *listener_cnt)
                        }
 
                        memcpy(&xmrt, imsg.data, sizeof(struct mrt));
-                       if ((xmrt.wbuf.fd = imsg.fd) == -1)
+                       if ((xmrt.wbuf.fd = imsg_get_fd(&imsg)) == -1)
                                log_warnx("expected to receive fd for mrt dump "
                                    "but didn't receive any");