Seen while working on similar code. There is no need to make the
composition of IMSG_CTL_SHOW_RIB_COMMUNITIES so complicated.

-- 
:wq Claudio

Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.600
diff -u -p -r1.600 rde.c
--- rde.c       7 Apr 2023 13:49:03 -0000       1.600
+++ rde.c       13 Apr 2023 13:47:51 -0000
@@ -2730,16 +2730,10 @@ rde_dump_rib_as(struct prefix *p, struct
                struct rde_community *comm = prefix_communities(p);
                size_t len = comm->nentries * sizeof(struct community);
                if (comm->nentries > 0) {
-                       if ((wbuf = imsg_create(ibuf_se_ctl,
-                           IMSG_CTL_SHOW_RIB_COMMUNITIES, 0, pid,
-                           len)) == NULL)
+                       if (imsg_compose(ibuf_se_ctl,
+                           IMSG_CTL_SHOW_RIB_COMMUNITIES, 0, pid, -1,
+                           comm->communities, len) == -1)
                                return;
-                       if ((bp = ibuf_reserve(wbuf, len)) == NULL) {
-                               ibuf_free(wbuf);
-                               return;
-                       }
-                       memcpy(bp, comm->communities, len);
-                       imsg_close(ibuf_se_ctl, wbuf);
                }
                for (l = 0; l < asp->others_len; l++) {
                        if ((a = asp->others[l]) == NULL)

Reply via email to