]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
fix: Move tx-fast config from MED to LLDP section
authorBreuninger Matthias (ETAS-DAP/XPC-Fe3) <Matthias.Breuninger@etas.com>
Thu, 24 Oct 2024 09:12:16 +0000 (11:12 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 9 Aug 2025 18:13:08 +0000 (20:13 +0200)
src/client/conf-lldp.c
src/client/conf-med.c
src/client/display.c

index 0c5b985be14f32b2ca5e42d721b8f5710ab198e7..e883c5535b9376e7d954d60ae7d3190dcac5eb92 100644 (file)
 #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,
index 04156bc5cf88f1331fdac6a1e614b6919d3b5552..36399557ef65f0cd0d11d3fc14275c10a36fedfe 100644 (file)
@@ -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);
 }
index 978accf02eae0c5f89ef4009468cc84288ce8d1e..6d9be2a5a12863d69b30d08fd34aeb45615f2545 100644 (file)
@@ -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,