]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
OLocks in BGP must be freed early
authorMaria Matejka <mq@ucw.cz>
Sun, 7 May 2023 15:30:33 +0000 (17:30 +0200)
committerMaria Matejka <mq@ucw.cz>
Sun, 7 May 2023 15:30:33 +0000 (17:30 +0200)
nest/proto.c
nest/protocol.h
proto/bgp/bgp.c

index 647b7f4e517a7186798960616f1170c58890be94..e75afc9e91b7463024ad9dfaa710da1342c39bb6 100644 (file)
@@ -1158,10 +1158,13 @@ proto_event(void *ptr)
   }
 
   if (proto_is_done(p))
+  {
+    rp_free(p->pool_fragile);
     if (p->loop != &main_birdloop)
       birdloop_stop_self(p->loop, proto_loop_stopped, p);
     else
       proto_cleanup(p);
+  }
 }
 
 
@@ -1235,7 +1238,10 @@ proto_start(struct proto *p)
   p->iface_sub.target = proto_event_list(p);
 
   PROTO_LOCKED_FROM_MAIN(p)
+  {
+    p->pool_fragile = rp_newf(p->pool, birdloop_domain(p->loop), "Protocol %s fragile objects", p->cf->name);
     proto_notify_state(p, (p->proto->start ? p->proto->start(p) : PS_UP));
+  }
 }
 
 
index 02ec5c155de8ff2238afd23efd8a98a5dba2320e..e8f19801e7ab421c9d28738a97067683e9a4740c 100644 (file)
@@ -130,6 +130,8 @@ struct proto {
   struct proto_config *cf;             /* Configuration data */
   struct proto_config *cf_new;         /* Configuration we want to switch to after shutdown (NULL=delete) */
   pool *pool;                          /* Pool containing local objects */
+  pool *pool_fragile;                  /* Pool containing fragile local objects which need to be freed
+                                          before the protocol's birdloop actually stops, like olocks */
   event *event;                                /* Protocol event */
   timer *restart_timer;                        /* Timer to restart the protocol from limits */
   event *restart_event;                        /* Event to restart/shutdown the protocol from limits */
index f4d80e8dfc92a1673683c599555328aa93cf90e7..9d81b85b63748e7ed59ce4e4d13ac89e7df4c63f 100644 (file)
@@ -1742,7 +1742,7 @@ bgp_start(struct proto *P)
    * so that we are the only instance attempting to talk with that neighbor.
    */
   struct object_lock *lock;
-  lock = p->lock = olock_new(P->pool);
+  lock = p->lock = olock_new(P->pool_fragile);
   lock->addr = p->remote_ip;
   lock->port = p->cf->remote_port;
   lock->iface = p->cf->iface;