From f6adee69803379dd8233b64369ed3f0cbf49d8c5 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Thu, 15 Apr 2021 14:12:06 +0000 Subject: Fix bgpctl show mrt for UPDATE messages. The call to output->attr() was incorrect. Adjust output->attr() to take a reqflag argument instead of a struct parse_result pointer since that is the only bit needed. Found by and OK procter@, OK deraadt@ --- usr.sbin/bgpctl/bgpctl.c | 13 +++++++------ usr.sbin/bgpctl/bgpctl.h | 2 +- usr.sbin/bgpctl/output.c | 6 +++--- usr.sbin/bgpctl/output_json.c | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) (limited to 'usr.sbin/bgpctl') diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index 954abd7e87e..02fc5ab0535 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.265 2021/02/16 08:30:21 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.266 2021/04/15 14:12:05 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -466,7 +466,7 @@ show(struct imsg *imsg, struct parse_result *res) warnx("bad IMSG_CTL_SHOW_RIB_ATTR received"); break; } - output->attr(imsg->data, ilen, res); + output->attr(imsg->data, ilen, res->flags); break; case IMSG_CTL_SHOW_RIB_MEM: if (imsg->hdr.len < IMSG_HEADER_SIZE + sizeof(stats)) @@ -1181,7 +1181,7 @@ show_mrt_dump(struct mrt_rib *mr, struct mrt_peer *mp, void *arg) if (req->flags & F_CTL_DETAIL) { for (j = 0; j < mre->nattrs; j++) output->attr(mre->attrs[j].attr, - mre->attrs[j].attr_len, &res); + mre->attrs[j].attr_len, req->flags); } } } @@ -1565,7 +1565,7 @@ show_mrt_notification(u_char *p, u_int16_t len) /* XXX this function does not handle JSON output */ static void -show_mrt_update(u_char *p, u_int16_t len) +show_mrt_update(u_char *p, u_int16_t len, int reqflags) { struct bgpd_addr prefix; int pos; @@ -1634,7 +1634,7 @@ show_mrt_update(u_char *p, u_int16_t len) attrlen += 1 + 2; } - output->attr(p, attrlen, 0); + output->attr(p, attrlen, reqflags); p += attrlen; alen -= attrlen; len -= attrlen; @@ -1664,6 +1664,7 @@ show_mrt_msg(struct mrt_bgp_msg *mm, void *arg) u_char *p; u_int16_t len; u_int8_t type; + struct ctl_show_rib_request *req = arg; printf("%s %s[%u] -> ", fmt_time(&mm->time), log_addr(&mm->src), mm->src_as); @@ -1717,7 +1718,7 @@ show_mrt_msg(struct mrt_bgp_msg *mm, void *arg) printf("illegal length: %u byte\n", len); return; } - show_mrt_update(p, len - MSGSIZE_HEADER); + show_mrt_update(p, len - MSGSIZE_HEADER, req->flags); break; case KEEPALIVE: printf("%s ", msgtypenames[type]); diff --git a/usr.sbin/bgpctl/bgpctl.h b/usr.sbin/bgpctl/bgpctl.h index 3261faa2303..25b28db38ec 100644 --- a/usr.sbin/bgpctl/bgpctl.h +++ b/usr.sbin/bgpctl/bgpctl.h @@ -24,7 +24,7 @@ struct output { void (*fib_table)(struct ktable *); void (*nexthop)(struct ctl_show_nexthop *); void (*interface)(struct ctl_show_interface *); - void (*attr)(u_char *, size_t, struct parse_result *); + void (*attr)(u_char *, size_t, int); void (*communities)(u_char *, size_t, struct parse_result *); void (*rib)(struct ctl_show_rib *, u_char *, size_t, struct parse_result *); diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index ac8c2a54c99..3d4d09f78ae 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.14 2021/03/01 08:02:34 jsg Exp $ */ +/* $OpenBSD: output.c,v 1.15 2021/04/15 14:12:05 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -594,7 +594,7 @@ show_ext_community(u_char *data, u_int16_t len) } static void -show_attr(u_char *data, size_t len, struct parse_result *res) +show_attr(u_char *data, size_t len, int reqflags) { u_char *path; struct in_addr id; @@ -822,7 +822,7 @@ show_attr(u_char *data, size_t len, struct parse_result *res) break; } done: - printf("%c", EOL0(res->flags)); + printf("%c", EOL0(reqflags)); } static void diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index fa0321c6345..4d19dd1971b 100644 --- a/usr.sbin/bgpctl/output_json.c +++ b/usr.sbin/bgpctl/output_json.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output_json.c,v 1.8 2021/03/01 08:02:34 jsg Exp $ */ +/* $OpenBSD: output_json.c,v 1.9 2021/04/15 14:12:05 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -538,7 +538,7 @@ json_do_ext_community(u_char *data, uint16_t len) } static void -json_attr(u_char *data, size_t len, struct parse_result *res) +json_attr(u_char *data, size_t len, int reqflags) { struct bgpd_addr prefix; struct in_addr id; -- cgit v1.2.3