]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Increase administrative shutdown message size to 255
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 5 Jan 2022 10:11:27 +0000 (12:11 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Fri, 7 Jan 2022 20:35:38 +0000 (22:35 +0200)
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>
bgpd/bgp_debug.c
bgpd/bgpd.c
bgpd/bgpd.h

index fde1bdd7ce6b66725b085f2b24651984eb9ac466..64f71bebc976d96329903a95f48df99464f9d065 100644 (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);
index 789c156da412919c36b89b15a5436ec12c84a1c1..3921ad2367137bc0d51ba0b7f3a07d5e371b8cb0 100644 (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);
 
index f4d7ab769a357702abc106814102d88352d4d1dd..865a50757ff4ca1311e05a25096f5b81ac991950 100644 (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)