]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
MRT: instead of crashing, ignore non-BGP attributes
authorMaria Matejka <mq@ucw.cz>
Thu, 14 Nov 2024 21:15:56 +0000 (22:15 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Mon, 2 Dec 2024 03:27:30 +0000 (04:27 +0100)
proto/bgp/attrs.c
proto/bgp/bgp.h
proto/mrt/mrt.c

index 5bd05fb26335d516d46a31b501f6bbc61357ad99..0872ae23f026f47f7c292b45673e379ab0ef6ca3 100644 (file)
@@ -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);
 
index 4cef8caf40a4a7f4c53c419ed5683e5e8be364cc..19b44372167d42a0babc77a9c364b1b42fc9a761 100644 (file)
@@ -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;
index 3378baceced1890e4414aae949c68bc77ee07a46..1336837a80f4621fc7512db3f38b33b2706af7f9 100644 (file)
@@ -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;