bgpd: Increase administrative shutdown message size to 255

Extended BGP Administrative Shutdown Communication (rfc9003):

Basically, shutdown message size is increased to 255 from 128.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
Donatas Abraitis 2022-01-05 12:11:27 +02:00
parent 541b51a5a3
commit 9f33eea39a
3 changed files with 7 additions and 5 deletions

View File

@ -509,7 +509,7 @@ const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data,
return NULL;
uint8_t len = data[0];
if (len > 128 || len > datalen - 1)
if (!len || len > datalen - 1)
return NULL;
return zlog_sanitize(buf, bufsz, data + 1, len);

View File

@ -4272,17 +4272,16 @@ static void peer_flag_modify_action(struct peer *peer, uint32_t flag)
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
char *msg = peer->tx_shutdown_message;
size_t msglen;
uint8_t msgbuf[BGP_ADMIN_SHUTDOWN_MSG_LEN + 1];
if (!msg && peer_group_active(peer))
msg = peer->group->conf
->tx_shutdown_message;
msglen = msg ? strlen(msg) : 0;
if (msglen > 128)
msglen = 128;
if (msglen > BGP_ADMIN_SHUTDOWN_MSG_LEN)
msglen = BGP_ADMIN_SHUTDOWN_MSG_LEN;
if (msglen) {
uint8_t msgbuf[129];
msgbuf[0] = msglen;
memcpy(msgbuf + 1, msg, msglen);

View File

@ -1731,6 +1731,9 @@ struct bgp_nlri {
/* Default BGP port number. */
#define BGP_PORT_DEFAULT 179
/* Extended BGP Administrative Shutdown Communication */
#define BGP_ADMIN_SHUTDOWN_MSG_LEN 255
/* BGP minimum message size. */
#define BGP_MSG_OPEN_MIN_SIZE (BGP_HEADER_SIZE + 10)
#define BGP_MSG_UPDATE_MIN_SIZE (BGP_HEADER_SIZE + 4)