]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Fix handling of 16bit-only ASN translation
authorNasato Goto <goto@mfeed.ad.jp>
Wed, 15 Apr 2020 01:46:53 +0000 (03:46 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 15 Apr 2020 01:46:53 +0000 (03:46 +0200)
The bug generated invalid AGGREGATOR attribute during translation of
32bit ASN to 16bit-only BGP peer. The patch fixes that.

nest/attrs.h
proto/bgp/attrs.c

index 3a4b0acd84b919827e2aca7dc53923322eec1a5c..d88a73f340f702dba9ca07777c27bb8583f467cb 100644 (file)
@@ -111,7 +111,7 @@ static inline struct adata *
 aggregator_to_old(struct linpool *pool, const struct adata *a)
 {
   struct adata *d = lp_alloc_adata(pool, 8);
-  put_u32(d->data, 0xFFFF);
+  put_u32(d->data, AS_TRANS);
   memcpy(d->data + 4, a->data + 4, 4);
   return d;
 }
index 39297dd7bf2e877da80582956893294b2c5d9a57..655ddb621a4f16a8f115770f9dd6b8abfb4c5586 100644 (file)
@@ -577,6 +577,7 @@ bgp_encode_aggregator(struct bgp_write_state *s, eattr *a, byte *buf, uint size)
     /* Prepare 16-bit AGGREGATOR (from 32-bit one) in a temporary buffer */
     byte *dst = alloca(6);
     len = aggregator_32to16(dst, data);
+    data = dst;
   }
 
   return bgp_put_attr(buf, size, BA_AGGREGATOR, a->flags, data, len);