]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Send message when bgp_check_capabilities() fails
authorIgor Putovny <igor.putovny@nic.cz>
Wed, 28 May 2025 12:40:20 +0000 (14:40 +0200)
committerIgor Putovny <igor.putovny@nic.cz>
Thu, 29 May 2025 12:31:18 +0000 (14:31 +0200)
proto/bgp/packets.c

index 95c34f025c388f6fd1cd9044a0d665a4bc059c7f..e16001540f007b9c55e380d25afc1ff37eb63f79 100644 (file)
@@ -995,7 +995,21 @@ bgp_rx_open(struct bgp_conn *conn, byte *pkt, uint len)
 
   /* RFC 5492 5 - check for required capabilities */
   if (p->cf->capabilities && !bgp_check_capabilities(conn, failed_caps))
-  { bgp_error(conn, 2, 7, NULL, 0); return; }
+  {
+    byte buf[32] = { 0 };
+    byte *end = bgp_write_capabilities(failed_caps, buf);
+
+    /* Send empty message if conn->buf has insufficient size or when write buffer is empty */
+    if (end > buf + sizeof(conn->buf) || end == buf)
+      bgp_error(conn, 2, 7, NULL, 0);
+    else
+    {
+      memcpy(conn->buf, buf, end - buf);
+      bgp_error(conn, 2, 7, conn->buf, end - buf);
+    }
+
+    return;
+  }
 
   struct bgp_caps *caps = conn->remote_caps;