From bd5d7e28ab029fe3ae1a32d7425b3d43aa2f9d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tvrd=C3=ADk?= Date: Tue, 5 Jan 2016 18:05:06 +0100 Subject: [PATCH] MRT Table Dump: Fix size of AS_PATH in BGP Attributes All AS numbers in the AS_PATH attribute in RIB Entries MUST be encoded as 4-byte AS numbers. -- RFC 6396 Thanks to Colin Petrie for noticing us about this bug in BIRD! --- proto/bgp/mrt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/proto/bgp/mrt.c b/proto/bgp/mrt.c index d4f8a434..713be83a 100644 --- a/proto/bgp/mrt.c +++ b/proto/bgp/mrt.c @@ -101,7 +101,11 @@ bgp_mrt_table_dump_step(struct mrt_table_dump_ctx *state) continue; } - attributes_length = bgp_encode_attrs(p, attributes_buffer, e->attrs->eattrs, BGP_ATTR_BUFFER_SIZE); + struct bgp_proto tmp_bgp_proto = { + .as4_session = 1, /* to force build AS_PATH as 32bit AS in bgp_encode_attrs() */ + }; + + attributes_length = bgp_encode_attrs(&tmp_bgp_proto, attributes_buffer, e->attrs->eattrs, BGP_ATTR_BUFFER_SIZE); if (attributes_length == -1) { log(L_WARN "%s: MRT Table Dump for %I/%u: Attribute list too long, let it blank", p->p.name, n->n.prefix, n->n.pxlen);