From: Breuninger Matthias (ETAS-DAP/XPC-Fe3) Date: Thu, 24 Oct 2024 09:12:16 +0000 (+0200) Subject: fix: Move tx-fast config from MED to LLDP section X-Git-Tag: 1.0.20~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8136b86f10a2e8f891f8fba5ab290dfe073fa35b;p=thirdparty%2Flldpd.git fix: Move tx-fast config from MED to LLDP section --- diff --git a/src/client/conf-lldp.c b/src/client/conf-lldp.c index 0c5b985b..e883c553 100644 --- a/src/client/conf-lldp.c +++ b/src/client/conf-lldp.c @@ -22,6 +22,65 @@ #include "client.h" #include "../log.h" +static int +cmd_faststart(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env, + const void *arg) +{ + log_debug("lldpctl", "configure fast interval support"); + + lldpctl_atom_t *config = lldpctl_get_configuration(conn); + if (config == NULL) { + log_warnx("lldpctl", "unable to get configuration from lldpd. %s", + lldpctl_last_strerror(conn)); + return 0; + } + + const char *action = arg; + if ((!strcmp(action, "enable") && + (lldpctl_atom_set_int(config, lldpctl_k_config_fast_start_enabled, 1) == + NULL)) || + (!strcmp(action, "disable") && + (lldpctl_atom_set_int(config, lldpctl_k_config_fast_start_enabled, 0) == + NULL)) || + (!strcmp(action, "delay") && + (lldpctl_atom_set_str(config, lldpctl_k_config_fast_start_interval, + cmdenv_get(env, "tx-interval")) == NULL))) { + log_warnx("lldpctl", "unable to setup fast start. %s", + lldpctl_last_strerror(conn)); + lldpctl_atom_dec_ref(config); + return 0; + } + log_info("lldpctl", "configuration for fast start applied"); + lldpctl_atom_dec_ref(config); + return 1; +} + +static void +register_commands_fast_start(struct cmd_node *configure_lldp, struct cmd_node *unconfigure_lldp) +{ + struct cmd_node *configure_fast = commands_new(configure_lldp, "fast-start", + "Fast start configuration", cmd_check_no_env, NULL, "ports"); + struct cmd_node *unconfigure_fast = commands_new(unconfigure_lldp, "fast-start", + "Fast start configuration", cmd_check_no_env, NULL, "ports"); + + /* Enable */ + commands_new(commands_new(configure_fast, "enable", "Enable fast start", NULL, + NULL, NULL), + NEWLINE, "Enable fast start", NULL, cmd_faststart, "enable"); + + /* Set TX delay */ + commands_new(commands_new(commands_new(configure_fast, "tx-interval", + "Set LLDP fast transmit delay", NULL, NULL, NULL), + NULL, "LLDP fast transmit delay in seconds", NULL, + cmd_store_env_value, "tx-interval"), + NEWLINE, "Set LLDP fast transmit delay", NULL, cmd_faststart, "delay"); + + /* Disable */ + commands_new(commands_new(unconfigure_fast, NEWLINE, "Disable fast start", NULL, + cmd_faststart, "disable"), + NEWLINE, "Disable fast start", NULL, cmd_faststart, "disable"); +} + static int cmd_txdelay(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env, const void *arg) @@ -617,6 +676,8 @@ register_commands_configure_lldp(struct cmd_node *configure, struct cmd_node *unconfigure_lldp = commands_new(unconfigure, "lldp", "LLDP configuration", NULL, NULL, NULL); + register_commands_fast_start(configure_lldp, unconfigure_lldp); + commands_new( commands_new(commands_new(configure_lldp, "tx-interval", "Set LLDP transmit delay", cmd_check_no_env, NULL, diff --git a/src/client/conf-med.c b/src/client/conf-med.c index 04156bc5..36399557 100644 --- a/src/client/conf-med.c +++ b/src/client/conf-med.c @@ -489,11 +489,8 @@ register_commands_configure_med(struct cmd_node *configure, struct cmd_node *configure_med = commands_new(configure, "med", "MED configuration", NULL, NULL, NULL); - struct cmd_node *unconfigure_med = - commands_new(unconfigure, "med", "MED configuration", NULL, NULL, NULL); register_commands_medloc(configure_med); register_commands_medpol(configure_med); register_commands_medpow(configure_med); - register_commands_medfast(configure_med, unconfigure_med); } diff --git a/src/client/display.c b/src/client/display.c index 978accf0..6d9be2a5 100644 --- a/src/client/display.c +++ b/src/client/display.c @@ -971,6 +971,14 @@ display_configuration(lldpctl_conn_t *conn, struct writer *w) tag_start(w, "configuration", "Global configuration"); tag_start(w, "config", "Configuration"); + tag_datatag(w, "fast-start", "Fast start mechanism", + (lldpctl_atom_get_int(configuration, lldpctl_k_config_fast_start_enabled) == + 0) ? + "no" : + "yes"); + tag_datatag(w, "fast-start-interval", "Fast start interval", + N(lldpctl_atom_get_str(configuration, + lldpctl_k_config_fast_start_interval))); tag_datatag(w, "tx-delay", "Transmit delay", lldpctl_atom_get_str(configuration, lldpctl_k_config_tx_interval)); tag_datatag(w, "tx-delay-ms", "Transmit delay in milliseconds", @@ -1020,14 +1028,6 @@ display_configuration(lldpctl_conn_t *conn, struct writer *w) lldpctl_k_config_lldpmed_noinventory) == 0) ? "no" : "yes"); - tag_datatag(w, "lldpmed-faststart", "LLDP-MED fast start mechanism", - (lldpctl_atom_get_int(configuration, lldpctl_k_config_fast_start_enabled) == - 0) ? - "no" : - "yes"); - tag_datatag(w, "lldpmed-faststart-interval", "LLDP-MED fast start interval", - N(lldpctl_atom_get_str(configuration, - lldpctl_k_config_fast_start_interval))); tag_datatag(w, "bond-slave-src-mac-type", "Source MAC for LLDP frames on bond slaves", lldpctl_atom_get_str(configuration,