From: claudio Date: Wed, 31 Aug 2022 11:25:36 +0000 (+0000) Subject: Make sure that only one roa softreconfig runner is run at any time. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6f8eff73e408094c8eb3bc71885ac57ba935f667;p=openbsd Make sure that only one roa softreconfig runner is run at any time. If a run takes to long drop the current update and wait for the next update. OK benno@ --- diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 10782830671..d4602243bf8 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.570 2022/08/30 18:50:21 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.571 2022/08/31 11:25:36 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -1083,6 +1083,7 @@ rde_dispatch_imsg_rtr(struct imsgbuf *ibuf) switch (imsg.hdr.type) { case IMSG_RECONF_ROA_SET: /* start of update */ + trie_free(&roa_new.th); /* clear new roa */ break; case IMSG_RECONF_ROA_ITEM: if (imsg.hdr.len - IMSG_HEADER_SIZE != @@ -3923,11 +3924,14 @@ rde_roa_softreload(struct rib_entry *re, void *bula) } } +static int roa_update_pending; + static void rde_roa_softreload_done(void *arg, uint8_t aid) { /* the roa update is done */ log_info("ROA softreload done"); + roa_update_pending = 0; } static void @@ -3935,6 +3939,11 @@ rde_roa_reload(void) { struct rde_prefixset roa_old; + if (roa_update_pending) { + log_info("ROA softreload skipped, old still running"); + return; + } + roa_old = rde_roa; rde_roa = roa_new; memset(&roa_new, 0, sizeof(roa_new)); @@ -3950,6 +3959,7 @@ rde_roa_reload(void) trie_free(&roa_old.th); /* old roa no longer needed */ log_debug("ROA change: reloading Adj-RIB-In"); + roa_update_pending = 1; if (rib_dump_new(RIB_ADJ_IN, AID_UNSPEC, RDE_RUNNER_ROUNDS, rib_byid(RIB_ADJ_IN), rde_roa_softreload, rde_roa_softreload_done, NULL) == -1) diff --git a/usr.sbin/bgpd/rde_trie.c b/usr.sbin/bgpd/rde_trie.c index 8cec20fe706..029a807dd60 100644 --- a/usr.sbin/bgpd/rde_trie.c +++ b/usr.sbin/bgpd/rde_trie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_trie.c,v 1.15 2022/05/23 13:40:12 deraadt Exp $ */ +/* $OpenBSD: rde_trie.c,v 1.16 2022/08/31 11:25:36 claudio Exp $ */ /* * Copyright (c) 2018 Claudio Jeker @@ -468,6 +468,7 @@ trie_free(struct trie_head *th) { trie_free_v4(th->root_v4); trie_free_v6(th->root_v6); + memset(th, 0, sizeof(*th)); } static int diff --git a/usr.sbin/bgpd/rtr.c b/usr.sbin/bgpd/rtr.c index 13c5111230b..4775b6969f1 100644 --- a/usr.sbin/bgpd/rtr.c +++ b/usr.sbin/bgpd/rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtr.c,v 1.6 2022/08/17 15:15:26 claudio Exp $ */ +/* $OpenBSD: rtr.c,v 1.7 2022/08/31 11:25:36 claudio Exp $ */ /* * Copyright (c) 2020 Claudio Jeker @@ -76,7 +76,7 @@ rtr_expire_roas(time_t now) } } if (recalc != 0) - log_warnx("%u roa-set entries expired", recalc); + log_info("%u roa-set entries expired", recalc); return recalc; }