From e11cebce2c8a8755fb2b5c5ac59c501c047ee432 Mon Sep 17 00:00:00 2001 From: "Breuninger Matthias (ETAS-DAP/XPC-Fe3)" Date: Fri, 17 Jan 2025 08:54:24 +0100 Subject: [PATCH] fix: Some cleanup in moving fast-start into LLDP core --- src/client/conf-med.c | 62 ------------------------------- src/client/lldpcli.8.in | 10 ++--- tests/integration/test_lldpcli.py | 20 +--------- tests/lldpcli.conf | 6 +-- 4 files changed, 10 insertions(+), 88 deletions(-) diff --git a/src/client/conf-med.c b/src/client/conf-med.c index 36399557..bb3797a7 100644 --- a/src/client/conf-med.c +++ b/src/client/conf-med.c @@ -416,68 +416,6 @@ register_commands_medpol(struct cmd_node *configure_med) } } -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; -} - -/** - * Register "configure med fast-start *" - */ -static void -register_commands_medfast(struct cmd_node *med, struct cmd_node *nomed) -{ - struct cmd_node *configure_fast = commands_new(med, "fast-start", - "Fast start configuration", cmd_check_no_env, NULL, "ports"); - struct cmd_node *unconfigure_fast = commands_new(nomed, "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"); -} - /** * Register "configure med *" */ diff --git a/src/client/lldpcli.8.in b/src/client/lldpcli.8.in index 298e4ada..817fc7b2 100644 --- a/src/client/lldpcli.8.in +++ b/src/client/lldpcli.8.in @@ -666,15 +666,15 @@ and subtype is specified, remove specific instances of custom TLV. .Ed -.Cd configure med fast-start +.Cd configure lldp fast-start .Cd enable | tx-interval Ar interval .Bd -ragged -offset XXXXXX -Configure LLDP-MED fast start mechanism. When a new LLDP-MED-enabled +Configure LLDP fast start mechanism. When a new LLDP neighbor is detected, fast start allows .Nm lldpd to shorten the interval between two LLDPDU. .Cd enable -should enable LLDP-MED fast start while +should enable LLDP fast start while .Cd tx-interval specifies the interval between two LLDPDU in seconds. The valid interval range is 1 through 3600 in seconds. The default interval is 1 second. Once @@ -682,9 +682,9 @@ range is 1 through 3600 in seconds. The default interval is 1 second. Once neighbor is detected. .Ed -.Cd unconfigure med fast-start +.Cd unconfigure lldp fast-start .Bd -ragged -offset XXXXXX -Disable LLDP-MED fast start mechanism. +Disable LLDP fast start mechanism. .Ed .Cd configure diff --git a/tests/integration/test_lldpcli.py b/tests/integration/test_lldpcli.py index 3e964dfc..30d0a4e9 100644 --- a/tests/integration/test_lldpcli.py +++ b/tests/integration/test_lldpcli.py @@ -690,24 +690,8 @@ def test_return_code(lldpd1, lldpcli, namespaces): ("configure lldp tx-interval 20", "tx-delay", 20), ("configure lldp tx-hold 5", "tx-hold", 5), ("configure lldp portidsubtype ifname", "lldp-portid-type", "ifname"), - pytest.param( - "unconfigure med fast-start", - "lldpmed-faststart", - "no", - marks=pytest.mark.skipif( - "'LLDP-MED' not in config.lldpd.features", - reason="LLDP-MED not supported", - ), - ), - pytest.param( - "configure med fast-start tx-interval 2", - "lldpmed-faststart-interval", - 2, - marks=pytest.mark.skipif( - "'LLDP-MED' not in config.lldpd.features", - reason="LLDP-MED not supported", - ), - ), + ("unconfigure lldp fast-start", "fast-start", "no"), + ("configure lldp fast-start tx-interval 2", "fast-start-interval", 2), ("configure system interface pattern eth*", "iface-pattern", "eth*"), ("configure system interface permanent eth*", "perm-iface-pattern", "eth*"), ("configure system ip management pattern 10.*", "mgmt-pattern", "10.*"), diff --git a/tests/lldpcli.conf b/tests/lldpcli.conf index d085f63c..4afabeec 100644 --- a/tests/lldpcli.conf +++ b/tests/lldpcli.conf @@ -39,11 +39,11 @@ configure lldp custom-tlv add oui 33,44,55 subtype 55 oui-info 65,65,65,65,65 configure lldp custom-tlv replace oui 33,44,55 subtype 44 oui-info 66,66,66,66,66 unconfigure lldp custom-tlv oui 33,44,55 subtype 55 unconfigure lldp custom-tlv +configure lldp fast-start enable +configure lldp fast-start tx-interval 3 +unconfigure lldp fast-start configure system bond-slave-src-mac-type fixed configure system bond-slave-src-mac-type local -configure med fast-start enable -configure med fast-start tx-interval 3 -unconfigure med fast-start configure med location coordinate latitude 48.58667N longitude 2.2014E altitude 117.47 m datum WGS84 configure med location address country US language en_US street "Commercial Road" city "Roseville" configure med location elin 911 -- 2.47.2