Simplify the IMSG_CTL_KROUTE after the change in bgpd.
authorclaudio <claudio@openbsd.org>
Mon, 8 Jan 2024 15:09:14 +0000 (15:09 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 8 Jan 2024 15:09:14 +0000 (15:09 +0000)
OK tb@

usr.sbin/bgpctl/bgpctl.c

index bd3a898..388b08c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: bgpctl.c,v 1.298 2023/11/20 14:41:55 claudio Exp $ */
+/*     $OpenBSD: bgpctl.c,v 1.299 2024/01/08 15:09:14 claudio Exp $ */
 
 /*
  * Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -194,19 +194,13 @@ main(int argc, char *argv[])
                break;
        case SHOW_FIB:
                if (!res->addr.aid) {
-                       struct ibuf     *msg;
-                       sa_family_t      af;
-
-                       af = aid2af(res->aid);
-                       if ((msg = imsg_create(imsgbuf, IMSG_CTL_KROUTE,
-                           res->rtableid, 0, sizeof(res->flags) +
-                           sizeof(af))) == NULL)
-                               errx(1, "imsg_create failure");
-                       if (imsg_add(msg, &res->flags, sizeof(res->flags)) ==
-                           -1 ||
-                           imsg_add(msg, &af, sizeof(af)) == -1)
-                               errx(1, "imsg_add failure");
-                       imsg_close(imsgbuf, msg);
+                       struct ctl_kroute_req   req = { 0 };
+
+                       req.af = aid2af(res->aid);
+                       req.flags = res->flags;
+
+                       imsg_compose(imsgbuf, IMSG_CTL_KROUTE, res->rtableid,
+                           0, -1, &req, sizeof(req));
                } else
                        imsg_compose(imsgbuf, IMSG_CTL_KROUTE_ADDR,
                            res->rtableid, 0, -1,