On Sat, Oct 19 2019, Claudio Jeker <[email protected]> wrote:
> bgpd supports up to 255 byte shutdown communications. So the manpage is
> not telling the truth. Also I don't think it is helpful to mention the
> limit at all. bgpctl will exit with 'shutdown reason too long' if the text
> is too long which is good enough. For best interop people should keep the
> shutdown message as simple and short as possible.
What about just truncating the shutdown message (possibly with a visible
marker like '@')?
This way bgpctl would still send the message to the peer, which is nicer
in unattended runs. But maybe I'm overthinking this. Diff below very
lightly tested as I have no bgpd setup at hand. The diff only touches
bgpctl, people should probably keep their config files free of such
problems.
--8<--
russell /usr/src/usr.sbin/bgpctl$ obj/bgpctl nei 1.1.1.1 down 'lll[...]llll'
bgpctl: shutdown reason too long, truncated
bgpctl: connect: /var/run/bgpd.sock.0: No such file or directory
-->8--
Index: parser.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpctl/parser.c,v
retrieving revision 1.99
diff -u -p -r1.99 parser.c
--- parser.c 27 Sep 2019 10:34:54 -0000 1.99
+++ parser.c 19 Oct 2019 12:58:29 -0000
@@ -648,8 +648,10 @@ match_token(int *argc, char **argv[], co
if (!match && word != NULL && wordlen > 0) {
if (strlcpy(res.shutcomm, word,
sizeof(res.shutcomm)) >=
- sizeof(res.shutcomm))
- errx(1, "shutdown reason too long");
+ sizeof(res.shutcomm)) {
+ warnx("shutdown reason too long, "
+ "truncated");
+ }
match++;
t = &table[i];
}
--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE