]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Handle case where capabilites are not used
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Fri, 15 Mar 2019 19:54:01 +0000 (20:54 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 18 Mar 2019 13:29:12 +0000 (14:29 +0100)
If peer does not announce capabilities at all, or when we have
capabilities disabled, handle that as implicit IPv4 unicast.

proto/bgp/bgp.c
proto/bgp/bgp.h
proto/bgp/packets.c

index 8dedde9f782d485e770366d87f4c55e992c18895..56401a080b68dfb4fd571a1a1234df0a456b1114 100644 (file)
@@ -491,6 +491,7 @@ bgp_conn_enter_openconfirm_state(struct bgp_conn *conn)
 }
 
 static const struct bgp_af_caps dummy_af_caps = { };
+static const struct bgp_af_caps basic_af_caps = { .ready = 1 };
 
 void
 bgp_conn_enter_established_state(struct bgp_conn *conn)
@@ -541,6 +542,13 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
     const struct bgp_af_caps *loc = bgp_find_af_caps(local, c->afi);
     const struct bgp_af_caps *rem = bgp_find_af_caps(peer,  c->afi);
 
+    /* Use default if capabilities were not announced */
+    if (!local->length && (c->afi == BGP_AF_IPV4))
+      loc = &basic_af_caps;
+
+    if (!peer->length && (c->afi == BGP_AF_IPV4))
+      rem = &basic_af_caps;
+
     /* Ignore AFIs that were not announced in multiprotocol capability */
     if (!loc || !loc->ready)
       loc = &dummy_af_caps;
index cfc88d8e1e4bbaadc6ffc4c2aa1584262aa70a13..56dbf4854c12a79a54b008fa05a88092fec29da9 100644 (file)
@@ -215,6 +215,7 @@ struct bgp_caps {
   u8 llgr_aware;                       /* Long-lived GR capability, RFC draft */
 
   u16 af_count;                                /* Number of af_data items */
+  u16 length;                          /* Length of capabilities in OPEN msg */
 
   struct bgp_af_caps af_data[0];       /* Per-AF capability data */
 };
index 26716573ef506faf1bac65fab4ea24c5f155fa79..4ae6c5cf6f191f77844742a98ac33a9c6a80cd03 100644 (file)
@@ -217,6 +217,7 @@ bgp_write_capabilities(struct bgp_conn *conn, byte *buf)
   struct bgp_af_caps *ac;
   uint any_ext_next_hop = 0;
   uint any_add_path = 0;
+  byte *buf_head = buf;
   byte *data;
 
   /* Prepare bgp_caps structure */
@@ -394,6 +395,8 @@ bgp_write_capabilities(struct bgp_conn *conn, byte *buf)
     data[-1] = buf - data;
   }
 
+  caps->length = buf - buf_head;
+
   return buf;
 }
 
@@ -405,6 +408,8 @@ bgp_read_capabilities(struct bgp_conn *conn, struct bgp_caps *caps, byte *pos, i
   int i, cl;
   u32 af;
 
+  caps->length += len;
+
   while (len > 0)
   {
     if (len < 2 || len < (2 + pos[1]))