From 961b3824bfb82ddb00f85c1a7fbed7f802f48219 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 11 Aug 2025 20:32:23 +0200 Subject: ipcpd: Configure link-state at bootstrap The link-state component had some values defined in the source such as link-state advertisement interval, link timeout period and the PFF recalculation time. These can now be configured from the config file or via "irm ipcp bootstrap" on the command line. Signed-off-by: Dimitri Staessens --- src/irmd/configfile.c | 61 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 10 deletions(-) (limited to 'src/irmd/configfile.c') diff --git a/src/irmd/configfile.c b/src/irmd/configfile.c index f8948c2c..14b03d53 100644 --- a/src/irmd/configfile.c +++ b/src/irmd/configfile.c @@ -315,22 +315,63 @@ static int toml_routing(toml_table_t * table, struct dt_config * conf) { toml_datum_t routing; + toml_datum_t t_recalc; + toml_datum_t t_update; + toml_datum_t t_timeo; routing = toml_string_in(table, "routing"); if (routing.ok) { - if (strcmp(routing.u.s, "link-state") == 0) - conf->routing_type = ROUTING_LINK_STATE; - else if (strcmp(routing.u.s, "lfa") == 0) - conf->routing_type = ROUTING_LINK_STATE_LFA; - else if (strcmp(routing.u.s, "ecmp") == 0) - conf->routing_type = ROUTING_LINK_STATE_ECMP; - else - conf->routing_type = ROUTING_INVALID; + if (strcmp(routing.u.s, "link-state") == 0) { + conf->routing.pol = ROUTING_LINK_STATE; + conf->routing.ls.pol = LS_SIMPLE; + } else if (strcmp(routing.u.s, "lfa") == 0) { + conf->routing.pol = ROUTING_LINK_STATE; + conf->routing.ls.pol = LS_LFA; + } else if (strcmp(routing.u.s, "ecmp") == 0) { + conf->routing.pol = ROUTING_LINK_STATE; + conf->routing.ls.pol = LS_ECMP; + } else { + conf->routing.pol = ROUTING_INVALID; + return -EINVAL; + } free(routing.u.s); } - if (conf->routing_type == ROUTING_INVALID) - return -1; + switch (conf->routing.pol) { + case ROUTING_LINK_STATE: + log_info("Using Link State routing policy."); + t_recalc = toml_int_in(table, "ls_t_recalc"); + if (t_recalc.ok) { + if (t_recalc.u.i < 1) { + log_err("Invalid ls_t_recalc value: %ld", + t_recalc.u.i); + return -EINVAL; + } + conf->routing.ls.t_recalc = t_recalc.u.i; + } + t_update = toml_int_in(table, "ls_t_update"); + if (t_update.ok) { + if (t_update.u.i < 1) { + log_err("Invalid ls_t_update value: %ld", + t_update.u.i); + return -EINVAL; + } + conf->routing.ls.t_update = t_update.u.i; + } + t_timeo = toml_int_in(table, "ls_t_timeo"); + if (t_timeo.ok) { + if (t_timeo.u.i < 1) { + log_err("Invalid ls_t_timeo value: %ld", + t_timeo.u.i); + return -EINVAL; + } + conf->routing.ls.t_timeo = t_timeo.u.i; + } + break; + default: + log_err("Invalid routing policy: %d", conf->routing.pol); + return -EINVAL; + } return 0; } -- cgit v1.2.3