From 2cb5980f20bb642e60484a1647031cb6f013ddc3 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 11 Aug 2017 14:25:56 +0200 Subject: [PATCH] bgpd: don't sidestep vty code afi_header_vty_out is sidestepping the vty code, writing straight to the output (either stdout or the obuf), which results in newline translation not being performed. Easiest fix is replacing it with a macro. Longer-term, I have some old code to add "prefaces" to the vty output, planning to dig that up. Fixes: #949 ("bgpd show running doesn't show new lines") Reported-by: Lou Berger Signed-off-by: David Lamparter --- bgpd/bgpd.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d30def0f07..ae0a22f28a 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6135,27 +6135,11 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, u_char use_json, return buf; } -static void afi_header_vty_out(struct vty *vty, afi_t afi, safi_t safi, - int *write, const char *format, ...) -{ - va_list args; - int len = 0; - char buf[1024]; - - bgp_config_write_family_header(vty, afi, safi, write); - - if (vty_shell(vty)) { - va_start(args, format); - vprintf(format, args); - va_end(args); - } else { - va_start(args, format); - len = vsnprintf(buf, sizeof(buf), format, args); - va_end(args); - - buffer_put(vty->obuf, (u_char *)buf, len); - } -} +#define afi_header_vty_out(vty, afi, safi, write, format, ...) \ + do { \ + bgp_config_write_family_header(vty, afi, safi, write); \ + vty_out(vty, format, ## __VA_ARGS__); \ + } while (0) static void bgp_config_write_filter(struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int *write) -- 2.39.5