From afa47859e2106cb9a6626786b7d6cfe784004535 Mon Sep 17 00:00:00 2001 From: Katerina Kubecova Date: Wed, 11 Sep 2024 11:35:29 +0200 Subject: [PATCH] bmp table accesed in event.c after free - or walgrind is saying so --- nest/proto.c | 2 +- proto/bmp/bmp.c | 5 +++-- sysdep/unix/krt.c | 45 ++++++++++++++++++++++++++++++--------------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/nest/proto.c b/nest/proto.c index e8c2f11b..5bdec8eb 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -2915,7 +2915,7 @@ void protos_attr_field_init(void) { log("start of protos_attr_field_init"); - int init_length = 16; + int init_length = 32; proto_state_table = mb_allocz(&root_pool, sizeof(struct proto_attrs)); proto_state_table->attrs = mb_allocz(&root_pool, sizeof(ea_list *_Atomic)*init_length); proto_state_table->channels_attrs = mb_allocz(&root_pool, sizeof(struct channel_attrs_list) * init_length); diff --git a/proto/bmp/bmp.c b/proto/bmp/bmp.c index be57653c..6ff5df31 100644 --- a/proto/bmp/bmp.c +++ b/proto/bmp/bmp.c @@ -575,7 +575,7 @@ bmp_add_table_exp_req(struct bmp_proto *p, rtable *tab) return bt; } -static void +/*static void bmp_remove_table(struct bmp_proto *p, struct bmp_table *bt) { log("removing table - bmp table %x chann %x, (subscr %x uc %x)",bt, bt->channel, &bt->channel->roa_subscriptions, &bt->uc); @@ -590,7 +590,7 @@ bmp_remove_table(struct bmp_proto *p, struct bmp_table *bt) log("free table %x", bt); mb_free(bt); -} +}*/ static void bmp_remove_table_rt(struct bmp_proto *p, struct bmp_table *bt) // still falling in krt routes... The thread synchronization was maybe not needed... @@ -1199,6 +1199,7 @@ bmp_do_pre_policy(void *bt_) if (r->flags & REF_OBSOLETE) break; + } rte new = rte_init_from(r); diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index db527027..196f1989 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -392,7 +392,7 @@ krt_got_route(struct krt_proto *p, rte *e, s8 src) /* The rest is for KRT_SRC_BIRD (or KRT_SRC_UNKNOWN) */ /* Deleting all routes if final flush is requested */ if (p->sync_state == KPS_FLUSHING) - goto delete; + goto done;//delete; /* We wait for the initial feed to have correct installed state */ if (!p->ready) @@ -706,7 +706,7 @@ krt_rt_notify(struct proto *P, struct channel *ch UNUSED, const net_addr *net, case KPS_FLUSHING: /* Drop any incoming route */ - krt_replace_rte(p, net, NULL, old ?: new); + //krt_replace_rte(p, net, NULL, old ?: new); } } @@ -769,9 +769,9 @@ krt_export_fed(struct channel *C) break; case KPS_FLUSHING: - krt_do_scan(p); - krt_cleanup(p); - proto_notify_state(&p->p, PS_DOWN); + //krt_do_scan(p); + //krt_cleanup(p); + //proto_notify_state(&p->p, PS_DOWN); return; } } @@ -886,6 +886,7 @@ krt_start(struct proto *P) static int krt_shutdown(struct proto *P) { + log("krt shutdown"); struct krt_proto *p = (struct krt_proto *) P; krt_scan_timer_stop(p); @@ -896,26 +897,40 @@ krt_shutdown(struct proto *P) /* FIXME we should flush routes even when persist during reconfiguration */ if (p->initialized && !KRT_CF->persist && (P->down_code != PDC_CMD_GR_DOWN)) { - rt_export_feeder req; /* init z P->main_channel->table, na export_best */ - ...; - - RT_FEED_WALK(req, f) /* look at rt-show.c for example */ + log("start of if"); + struct rt_export_feeder req = (struct rt_export_feeder) { - for (...) - rte *e = &f->block[i]; + .name = "shotdown.feeder", + .trace_routes = P->main_channel->debug, + }; /* init z P->main_channel->table, na export_best */ + rt_feeder_subscribe(&P->main_channel->table->export_all, &req);//...; + + RT_FEED_WALK(&req, f) /* look at rt-show.c for example */ + { + for (uint i = 0; i < f->count_routes; i++) + { + rte *e = &f->block[i]; /* check bmap_test(P->main_channel->export_rejected_map, e->id) * if 0, then never exported (can be skipped) */ + if (bmap_test(&P->main_channel->export_rejected_map, e->id)) + continue; /* if exported then delete from kernel */ - krt_replace_rte(p, net, NULL, old ?: new); + rte new = rte_init_from(e); + krt_replace_rte(p, e->net, NULL, &new);//old ?: new); + } } /* put things from krt_export_fed */ - + krt_do_scan(p); + krt_cleanup(p); + proto_notify_state(&p->p, PS_DOWN); + log("end of if"); } - - krt_cleanup(p); + else + krt_cleanup(p); + log("Lets return"); return PS_DOWN; }