From 765bd20af0fb93e17d14cc35065af1c269d4f305 Mon Sep 17 00:00:00 2001 From: claudio Date: Wed, 22 May 2024 08:42:34 +0000 Subject: [PATCH] Adjust code since remote_bgpid, bgpid and clusterid changed to host byte order. OK tb@ --- usr.sbin/bgpctl/bgpctl.c | 10 ++++++---- usr.sbin/bgpctl/output.c | 4 ++-- usr.sbin/bgpctl/output_json.c | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index bea30afc3e3..1dd4c7a6767 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.305 2024/02/01 11:37:10 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.306 2024/05/22 08:42:34 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -1548,15 +1548,16 @@ show_mrt_capabilities(struct ibuf *b) static void show_mrt_open(struct ibuf *b) { + struct in_addr ina; + uint32_t bgpid; uint16_t short_as, holdtime; uint8_t version, optparamlen; - struct in_addr bgpid; /* length check up to optparamlen already happened */ if (ibuf_get_n8(b, &version) == -1 || ibuf_get_n16(b, &short_as) == -1 || ibuf_get_n16(b, &holdtime) == -1 || - ibuf_get(b, &bgpid, sizeof(bgpid)) == -1 || + ibuf_get_n32(b, &bgpid) == -1 || ibuf_get_n8(b, &optparamlen) == -1) { trunc: printf("truncated message"); @@ -1564,8 +1565,9 @@ show_mrt_open(struct ibuf *b) } printf("\n "); + ina.s_addr = htonl(bgpid); printf("Version: %d AS: %u Holdtime: %u BGP Id: %s Paramlen: %u", - version, short_as, holdtime, inet_ntoa(bgpid), optparamlen); + version, short_as, holdtime, inet_ntoa(ina), optparamlen); if (optparamlen != ibuf_size(b)) { /* XXX missing support for RFC9072 */ printf("optional parameter length mismatch"); diff --git a/usr.sbin/bgpctl/output.c b/usr.sbin/bgpctl/output.c index d4a5fb9c665..247a66d3756 100644 --- a/usr.sbin/bgpctl/output.c +++ b/usr.sbin/bgpctl/output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: output.c,v 1.50 2024/01/31 11:23:20 claudio Exp $ */ +/* $OpenBSD: output.c,v 1.51 2024/05/22 08:42:34 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -299,7 +299,7 @@ show_neighbor_full(struct peer *p, struct parse_result *res) printf("\n"); if (p->state == STATE_ESTABLISHED) { - ina.s_addr = p->remote_bgpid; + ina.s_addr = htonl(p->remote_bgpid); printf(" BGP version 4, remote router-id %s", inet_ntoa(ina)); printf("%s\n", fmt_auth_method(p->auth.method)); diff --git a/usr.sbin/bgpctl/output_json.c b/usr.sbin/bgpctl/output_json.c index 98e78a51a12..e0190966e5f 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.43 2024/04/24 10:42:09 claudio Exp $ */ +/* $OpenBSD: output_json.c,v 1.44 2024/05/22 08:42:34 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -324,7 +324,7 @@ json_neighbor(struct peer *p, struct parse_result *res) log_addr(&p->conf.remote_addr), p->conf.remote_masklen); if (p->state == STATE_ESTABLISHED) { struct in_addr ina; - ina.s_addr = p->remote_bgpid; + ina.s_addr = htonl(p->remote_bgpid); json_do_string("bgpid", inet_ntoa(ina)); } json_do_string("state", statenames[p->state]); -- 2.20.1