]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Partially fixup to protocol announce state -> announce later mq-thread-next-bmp-pas-fixup
authorMaria Matejka <mq@ucw.cz>
Wed, 16 Oct 2024 13:44:21 +0000 (15:44 +0200)
committerMaria Matejka <mq@ucw.cz>
Wed, 16 Oct 2024 13:44:21 +0000 (15:44 +0200)
nest/proto.c
nest/protocol.h
proto/bgp/bgp.c

index 0856ec7054e97696d5a3a00abdadf030f0d86b9f..337df09701f4ef1632996922289319676b140d34 100644 (file)
@@ -3023,9 +3023,18 @@ proto_announce_state_locked(struct proto_state_table_private* ts, struct proto *
 
   ASSERT_DIE(p->id < ts->length_states);
   ea_list *old_attr = ts->states[p->id];
+
+  if (attr == old_attr)
+  {
+    /* Nothing has changed */
+    ea_free_later(attr);
+    return;
+  }
+
   ts->states[p->id] = attr;
 
-  p->ea_state = attr;
+  ea_free_later(p->ea_state);
+  p->ea_state = attr ? ea_ref(attr) : NULL;
 
   struct proto_pending_update *pupdate = SKIP_BACK(struct proto_pending_update, li, lfjour_push_prepare(&proto_state_table_pub.journal));
 
@@ -3052,6 +3061,30 @@ proto_announce_state(struct proto *p, ea_list *attr)
     proto_announce_state_locked(ts, p, attr);
 }
 
+struct proto_announce_state_deferred {
+  struct deferred_call dc;
+  struct proto *p;
+};
+
+static void proto_announce_state_deferred(struct deferred_call *dc)
+{
+  SKIP_BACK_DECLARE(struct proto_announce_state_deferred, pasd, dc, dc);
+  proto_announce_state(pasd->p, pasd->p->ea_state);
+}
+
+void
+proto_announce_state_later(struct proto *p, ea_list *attr)
+{
+  ea_free_later(p->ea_state);
+  p->ea_state = ea_lookup(attr, 0, EALS_CUSTOM);
+
+  struct proto_announce_state_deferred pasd = {
+    .dc.hook = proto_announce_state_deferred,
+    .p = p,
+  };
+
+  defer_call(&pasd.dc, sizeof pasd);
+}
 
 ea_list *
 channel_get_state(int id)
index 75a942d903f035ca41b923de791c5aad8b85562f..8f9723d90fdaecde2eed1d1cb547f94b51dfdbdf 100644 (file)
@@ -445,6 +445,7 @@ struct proto_pending_update {
 
 void proto_announce_state_locked(struct proto_state_table_private *ts, struct proto *p, ea_list *attr);
 void proto_announce_state(struct proto *p, ea_list *attr);
+void proto_announce_state_later(struct proto *p, ea_list *attr);
 ea_list *channel_get_state(int id);
 ea_list *proto_get_state(int id);
 void proto_states_subscribe(struct lfjour_recipient *r);
index bdfba942fd039f63884af8bb900dcddcc8f62d80..5f297872fcd9fd63f01334acaaf5c52717fbe9ce 100644 (file)
@@ -800,14 +800,13 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
 
 
 #ifdef CONFIG_BMP
-  ea_list *ea_l = proto_get_state(p->p.id);
+  ea_list *ea_l = p->p.ea_state;
   ea_set_attr(&ea_l, EA_LITERAL_STORE_ADATA(&ea_bgp_local_open_msg, 0, conn->local_open_msg, conn->local_open_length));
   ea_set_attr(&ea_l, EA_LITERAL_STORE_ADATA(&ea_bgp_remote_open_msg, 0, conn->remote_open_msg, conn->remote_open_length));
   ea_set_attr(&ea_l, EA_LITERAL_EMBEDDED(&ea_bgp_local_open_msg_len, 0, conn->local_open_length));
   ea_set_attr(&ea_l, EA_LITERAL_EMBEDDED(&ea_bgp_remote_open_msg_len, 0, conn->remote_open_length));
-  ea_l = ea_lookup(ea_l, 0, EALS_CUSTOM);
 
-  proto_announce_state(&p->p, ea_l);
+  proto_announce_state_later(&p->p, ea_l);
 #endif
 }