From bb939ccdfffe18fce545a759bf3b5784708dfa22 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 18 Dec 2024 16:04:17 +0100 Subject: [PATCH] confd: Avoid initctl reload after exiting previous generation Instead of running initctl reload, which also prematurely enables services which are not supposed to be started until we have run through the netdag and evolved to the next generation. Handle the original use-case of disabling zeroconf is managed by asking finit to stop the service immediately in the exit action, and deferring the cleanup of the service until we call `initctl reload` after the init action of the new generation. --- src/confd/src/ietf-interfaces.c | 24 ------------------------ src/confd/src/ietf-interfaces.h | 1 - src/confd/src/ietf-ip.c | 2 +- 3 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/confd/src/ietf-interfaces.c b/src/confd/src/ietf-interfaces.c index 45339f35..0f2b9abe 100644 --- a/src/confd/src/ietf-interfaces.c +++ b/src/confd/src/ietf-interfaces.c @@ -148,30 +148,6 @@ static int ifchange_cand(sr_session_ctx_t *session, uint32_t sub_id, const char return SR_ERR_OK; } -int netdag_exit_reload(struct dagger *net) -{ - FILE *initctl; - - if (systemf("runlevel >/dev/null 2>&1")) - /* If we are still bootstrapping, there is nothing to - * reload. */ - return 0; - - /* We may end up writing this file multiple times, e.g. if - * multiple services are disabled in the same config cycle, - * but since the contents of the file are static it doesn't - * matter. - */ - initctl = dagger_fopen_current(net, "exit", "@post", - 90, "reload.sh"); - if (!initctl) - return -EIO; - - fputs("initctl -bnq reload\n", initctl); - fclose(initctl); - return 0; -} - static int netdag_gen_link_mtu(FILE *ip, struct lyd_node *dif) { const char *ifname = lydx_get_cattr(dif, "name"); diff --git a/src/confd/src/ietf-interfaces.h b/src/confd/src/ietf-interfaces.h index 41c2abe8..585a0d9a 100644 --- a/src/confd/src/ietf-interfaces.h +++ b/src/confd/src/ietf-interfaces.h @@ -47,7 +47,6 @@ int netdag_gen_ethtool(struct dagger *net, struct lyd_node *cif, struct lyd_node /* ietf-interfaces.c */ char *get_phys_addr(struct lyd_node *parent, int *deleted); -int netdag_exit_reload(struct dagger *net); /* ietf-ip.c */ int netdag_gen_ipv6_autoconf(struct dagger *net, struct lyd_node *cif, diff --git a/src/confd/src/ietf-ip.c b/src/confd/src/ietf-ip.c index 9092bf23..cf6fdc93 100644 --- a/src/confd/src/ietf-ip.c +++ b/src/confd/src/ietf-ip.c @@ -145,9 +145,9 @@ int netdag_gen_ipv4_autoconf(struct dagger *net, struct lyd_node *cif, return -EIO; } + fprintf(initctl, "initctl -bnq stop zeroconf:%s\n", ifname); fprintf(initctl, "initctl -bnq disable zeroconf@%s.conf\n", ifname); fprintf(initctl, "rm -f %s\n", defaults); - err = netdag_exit_reload(net); } fclose(initctl);