]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Fix extended messages
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 11 Jul 2016 18:41:32 +0000 (20:41 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 11 Jul 2016 18:41:32 +0000 (20:41 +0200)
Change attribute length limit to handle extended (64 kB) messages.

Do not mix updates and withdraws (RFC 7606).

proto/bgp/packets.c

index 72ca3728940294475ed1aa8339654a996a335186..0cf38edf41a44f68d6229eccdca19e30943d0c3f 100644 (file)
@@ -369,7 +369,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf)
     }
   put_u16(buf, wd_size);
 
-  if (remains >= 3072)
+  if (!wd_size)
     {
       while ((buck = (struct bgp_bucket *) HEAD(p->bucket_queue))->send_node.next)
        {
@@ -382,7 +382,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf)
            }
 
          DBG("Processing bucket %p\n", buck);
-         a_size = bgp_encode_attrs(p, w+2, buck->eattrs, 2048);
+         a_size = bgp_encode_attrs(p, w+2, buck->eattrs, remains - 1024);
 
          if (a_size < 0)
            {
@@ -461,8 +461,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf)
       w += size;
       remains -= size;
     }
-
-  if (remains >= 3072)
+  else
     {
       while ((buck = (struct bgp_bucket *) HEAD(p->bucket_queue))->send_node.next)
        {
@@ -478,7 +477,7 @@ bgp_create_update(struct bgp_conn *conn, byte *buf)
          rem_stored = remains;
          w_stored = w;
 
-         size = bgp_encode_attrs(p, w, buck->eattrs, 2048);
+         size = bgp_encode_attrs(p, w, buck->eattrs, remains - 1024);
          if (size < 0)
            {
              log(L_ERR "%s: Attribute list too long, skipping corresponding routes", p->p.name);