From 946386f2dd69982105d0b02a90f57391b265d2ef Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 14 Nov 2024 22:15:56 +0100 Subject: [PATCH] MRT: instead of crashing, ignore non-BGP attributes --- proto/bgp/attrs.c | 6 +++++- proto/bgp/bgp.h | 1 + proto/mrt/mrt.c | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 5bd05fb2..0872ae23 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1247,7 +1247,11 @@ bgp_export_attrs(struct bgp_export_state *s, ea_list *attrs) static inline int bgp_encode_attr(struct bgp_write_state *s, eattr *a, byte *buf, uint size) { - ASSERT(EA_PROTO(a->id) == PROTOCOL_BGP); + if (EA_PROTO(a->id) != PROTOCOL_BGP) + if (s->ignore_non_bgp_attrs) + return 0; + else + bug("Tried to encode a non-BGP attribute"); uint code = EA_ID(a->id); diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index 4cef8caf..19b44372 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -453,6 +453,7 @@ struct bgp_write_state { int add_path; int mpls; int sham; + int ignore_non_bgp_attrs; eattr *mp_next_hop; const adata *mpls_labels; diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c index 3378bace..1336837a 100644 --- a/proto/mrt/mrt.c +++ b/proto/mrt/mrt.c @@ -594,7 +594,10 @@ mrt_table_dump_free(struct mrt_table_dump_state *s) static int mrt_table_dump_step(struct mrt_table_dump_state *s) { - struct bgp_write_state bws = { .as4_session = 1 }; + struct bgp_write_state bws = { + .as4_session = 1, + .ignore_non_bgp_attrs = 1, + }; s->max = 2048; s->bws = &bws;