From 65117b4ceddac4c780dcce8511b1d34b6f9f311e Mon Sep 17 00:00:00 2001 From: claudio Date: Mon, 12 Jun 2023 12:48:07 +0000 Subject: [PATCH] Use attr_writebuf() instead of hand rolling a more complicated version for IMSG_CTL_SHOW_RIB_ATTR. Also drop the attr_optlen() usage in imsg_create() since it is not stricly needed. With this attr_optlen follows the path of the dodo. OK tb@ --- usr.sbin/bgpd/rde.c | 14 ++++---------- usr.sbin/bgpd/rde.h | 4 +--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 8d51ec20b12..894e541f5fb 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.605 2023/04/20 15:44:45 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.606 2023/06/12 12:48:07 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -2828,7 +2828,6 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags, struct rib_entry *re; struct prefix *xp; struct rde_peer *peer; - void *bp; time_t staletime; size_t aslen; uint8_t l; @@ -2931,15 +2930,10 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags, if ((a = asp->others[l]) == NULL) break; if ((wbuf = imsg_create(ibuf_se_ctl, - IMSG_CTL_SHOW_RIB_ATTR, 0, pid, - attr_optlen(a))) == NULL) + IMSG_CTL_SHOW_RIB_ATTR, 0, pid, 0)) == NULL) return; - if ((bp = ibuf_reserve(wbuf, attr_optlen(a))) == NULL) { - ibuf_free(wbuf); - return; - } - if (attr_write(bp, attr_optlen(a), a->flags, - a->type, a->data, a->len) == -1) { + if (attr_writebuf(wbuf, a->flags, a->type, a->data, + a->len) == -1) { ibuf_free(wbuf); return; } diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 1ed3e15d276..d7a0aebba82 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.293 2023/04/19 13:23:33 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.294 2023/06/12 12:48:07 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker and @@ -401,8 +401,6 @@ void attr_copy(struct rde_aspath *, const struct rde_aspath *); int attr_compare(struct rde_aspath *, struct rde_aspath *); void attr_freeall(struct rde_aspath *); void attr_free(struct rde_aspath *, struct attr *); -#define attr_optlen(x) \ - ((x)->len > 255 ? (x)->len + 4 : (x)->len + 3) struct aspath *aspath_get(void *, uint16_t); struct aspath *aspath_copy(struct aspath *); -- 2.20.1