]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Minor cleanups
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Fri, 23 Dec 2016 22:03:26 +0000 (23:03 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 3 Jan 2017 15:30:27 +0000 (16:30 +0100)
nest/proto.c
nest/route.h
proto/bgp/bgp.c
proto/bgp/bgp.h
proto/bgp/config.Y
proto/bgp/packets.c

index 815d0652813a9bd0e3afc956ab99acb5e9804aba..0a7a32a64f4faa4e28507f134317545dc755b194 100644 (file)
@@ -490,7 +490,7 @@ int
 channel_reconfigure(struct channel *c, struct channel_config *cf)
 {
   /* FIXME: better handle these changes, also handle in_keep_filtered */
-  if ((c->table != cf->table->table) || (c->ra_mode != cf->ra_mode))
+  if ((c->table != cf->table->table) || (cf->ra_mode && (c->ra_mode != cf->ra_mode)))
     return 0;
 
   int import_changed = !filter_same(c->in_filter, cf->in_filter);
index d652ca15adfc87c39eeb030c69cc65c7dba2f460..12e67d61b27e613b7f8e51f131fc68dd2eec0ab0 100644 (file)
@@ -258,6 +258,7 @@ static inline int rte_is_filtered(rte *r) { return !!(r->flags & REF_FILTERED);
 
 
 /* Types of route announcement, also used as flags */
+#define RA_UNDEF       0               /* Undefined RA type */
 #define RA_OPTIMAL     1               /* Announcement of optimal route change */
 #define RA_ACCEPTED    2               /* Announcement of first accepted route */
 #define RA_ANY         3               /* Announcement of any route change */
index 5df2e38df27a7af3428c0480285710e24e3656a5..83c1688948da169d92402ecd0c0476b7dbab3850 100644 (file)
@@ -524,9 +524,13 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
     c->add_path_rx = (loc->add_path & BGP_ADD_PATH_RX) && (rem->add_path & BGP_ADD_PATH_TX);
     c->add_path_tx = (loc->add_path & BGP_ADD_PATH_TX) && (rem->add_path & BGP_ADD_PATH_RX);
 
-    // XXXX reset back to non-ANY?
+    /* Update RA mode */
     if (c->add_path_tx)
       c->c.ra_mode = RA_ANY;
+    else if (c->cf->secondary)
+      c->c.ra_mode = RA_ACCEPTED;
+    else
+      c->c.ra_mode = RA_OPTIMAL;
   }
 
   p->afi_map = mb_alloc(p->p.pool, num * sizeof(u32));
@@ -1411,8 +1415,6 @@ bgp_channel_init(struct channel *C, struct channel_config *CF)
   struct bgp_channel *c = (void *) C;
   struct bgp_channel_config *cf = (void *) CF;
 
-  C->ra_mode = cf->secondary ? RA_ACCEPTED : RA_OPTIMAL;
-
   c->cf = cf;
   c->afi = cf->afi;
   c->desc = bgp_get_af_desc(c->afi);
index a8a0494732ebbb915eb4e36f3907734882ee7380..7f5be4ea6cf449f5d7e44d03922b071efc73a360 100644 (file)
@@ -453,18 +453,6 @@ bgp_unset_attr(ea_list **to, struct linpool *pool, uint code)
 { eattr *e = bgp_set_attr(to, pool, code, 0, 0); e->type = EAF_TYPE_UNDEF; }
 
 
-
-
-/* Hack: although BA_NEXT_HOP attribute has type EAF_TYPE_IP_ADDRESS, in IPv6
- * we store two addesses in it - a global address and a link local address.
- */
-#ifdef XXX
-#define NEXT_HOP_LENGTH (2*sizeof(ip_addr))
-static inline void set_next_hop(byte *b, ip_addr addr) { ((ip_addr *) b)[0] = addr; ((ip_addr *) b)[1] = IPA_NONE; }
-#define NEXT_HOP_LENGTH sizeof(ip_addr)
-static inline void set_next_hop(byte *b, ip_addr addr) { ((ip_addr *) b)[0] = addr; }
-#endif
-
 int bgp_encode_attrs(struct bgp_write_state *s, ea_list *attrs, byte *buf, byte *end);
 ea_list * bgp_decode_attrs(struct bgp_parse_state *s, byte *data, uint len);
 
index 2a54db17e8cfc07a5b0e4cc2d9f04954c564235d..7c89fd50dbd80664a76df0e68399b3d35688639f 100644 (file)
@@ -152,6 +152,7 @@ bgp_channel_start: bgp_afi
 
   this_channel = channel_config_new(&channel_bgp, desc->net, this_proto);
   BGP_CC->c.name = desc->name;
+  BGP_CC->c.ra_mode = RA_UNDEF;
   BGP_CC->afi = $1;
   BGP_CC->gr_able = 0xff;      /* undefined */
 };
index 43149a0c592a0301b3e74f67f39246728e926291..a7df1c6373ca848ccd4d003b7d711b058783cded 100644 (file)
@@ -277,6 +277,12 @@ bgp_write_capabilities(struct bgp_conn *conn, byte *buf)
 
   /* Create capability list in buffer */
 
+  /*
+   * Note that max length is ~ 20+14*af_count. With max 6 channels that is
+   * 104. Option limit is 253 and buffer size is 4096, so we cannot overflow
+   * unless we add new capabilities or more AFs.
+   */
+
   WALK_AF_CAPS(caps, ac)
     if (ac->ready)
     {
@@ -350,8 +356,6 @@ bgp_write_capabilities(struct bgp_conn *conn, byte *buf)
     *buf++ = 0;                        /* Capability data length */
   }
 
-  /* FIXME: Should not XXXX 255 */
-
   return buf;
 }