]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: don't sidestep vty code
authorDavid Lamparter <equinox@opensourcerouting.org>
Fri, 11 Aug 2017 12:25:56 +0000 (14:25 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Fri, 11 Aug 2017 13:45:38 +0000 (15:45 +0200)
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 <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgpd.c

index d30def0f07837f5db361068305f585d6f51fba67..ae0a22f28a56aa43a89d78b023a2cbd1488405c0 100644 (file)
@@ -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)