summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2022-01-05 15:05:04 +0200
committerDonatas Abraitis <donatas.abraitis@gmail.com>2022-01-07 22:35:38 +0200
commit202a171144d2c4735c5ca199bce5adda89272e11 (patch)
tree9ae626e4996b187cf29245e399f4ec79c35686ac
parentb776f48c3658d9c3aae1034883a4a20ab40fa2bb (diff)
bgpd: Use correct encoding before printing shutdown msg
Using `bgp shutdown message MSG...`. Length should be decoded from the first byte, but it's decoded from the data instead. Before: ``` %NOTIFICATION: sent to neighbor 192.168.0.2 6/2 (Cease/Administratively Shutdown) 70 bytes 5b 54 49 43 4b 45 54 2d 31 2d 31 34 33 38 33 36 37 33 39 30 5d 20 73 ``` After: ``` %NOTIFICATION: sent to neighbor 192.168.0.2 6/2 (Cease/Administratively Shutdown) "[TICKET-1-1438367390] software upgrade; Expected downtime for 2 hours;" ``` On receiving side: ``` "[TICKET-1-1438367390] software upgrade; Expected downtime for 2 hours;" ``` Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
-rw-r--r--bgpd/bgpd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 3921ad2367..6d0fd2fdd6 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -4318,6 +4318,12 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg)
{
struct peer *peer;
struct listnode *node;
+ /* length(1) + message(N) */
+ uint8_t data[BGP_ADMIN_SHUTDOWN_MSG_LEN + 1];
+ size_t datalen = strlen(msg);
+
+ data[0] = datalen;
+ memcpy(data + 1, msg, datalen);
/* do nothing if already shut down */
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SHUTDOWN))
@@ -4338,8 +4344,8 @@ void bgp_shutdown_enable(struct bgp *bgp, const char *msg)
if (msg)
bgp_notify_send_with_data(
peer, BGP_NOTIFY_CEASE,
- BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN,
- (uint8_t *)(msg), strlen(msg));
+ BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, data,
+ datalen + 1);
else
bgp_notify_send(
peer, BGP_NOTIFY_CEASE,