From 5ba9878b4f74a375d54a2d79a5ab80c7f1d0c466 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Mon, 29 May 2023 19:32:26 +0200 Subject: [PATCH] BFD: Fixed reconfiguration issues After converting BFD to the new IO loop system, reconfiguration never really worked. Sadly, we missed this case in our testing suite so it passed under the radar for quite a while. Thanks to Andrei Dinu for reporting and isolating this issue. --- proto/bfd/bfd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index e373e4dd..5980148b 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -528,7 +528,7 @@ bfd_reconfigure_session(struct bfd_proto *p, struct bfd_session *s) if (EMPTY_LIST(s->request_list)) return; - birdloop_enter(p->p.loop); + ASSERT_DIE(birdloop_inside(p->p.loop)); struct bfd_request *req = SKIP_BACK(struct bfd_request, n, HEAD(s->request_list)); s->cf = bfd_merge_options(s->ifa->cf, &req->opts); @@ -541,8 +541,6 @@ bfd_reconfigure_session(struct bfd_proto *p, struct bfd_session *s) bfd_session_control_tx_timer(s, 0); - birdloop_leave(p->p.loop); - TRACE(D_EVENTS, "Session to %I reconfigured", s->addr); } @@ -614,7 +612,7 @@ bfd_free_iface(struct bfd_iface *ifa) } static void -bfd_reconfigure_iface(struct bfd_proto *p, struct bfd_iface *ifa, struct bfd_config *nc) +bfd_reconfigure_iface(struct bfd_proto *p UNUSED, struct bfd_iface *ifa, struct bfd_config *nc) { struct bfd_iface_config *new = bfd_find_iface_config(nc, ifa->iface); struct bfd_iface_config *old = ifa->cf; @@ -628,9 +626,7 @@ bfd_reconfigure_iface(struct bfd_proto *p, struct bfd_iface *ifa, struct bfd_con (new->passive != old->passive); /* This should be probably changed to not access ifa->cf from the BFD thread */ - birdloop_enter(p->p.loop); ifa->cf = new; - birdloop_leave(p->p.loop); } @@ -873,7 +869,12 @@ bfd_update_request(struct bfd_request *req, const struct bfd_options *opts) req->opts = *opts; if (s) - bfd_reconfigure_session(s->ifa->bfd, s); + { + struct bfd_proto *p = s->ifa->bfd; + birdloop_enter(p->p.loop); + bfd_reconfigure_session(p, s); + birdloop_leave(p->p.loop); + } } static void