56844987f0
Fix global tx-interval and tx-hold range checking Resolves: RHEL-40245 Signed-off-by: Hangbin Liu <haliu@redhat.com>
84 lines
2.9 KiB
Diff
84 lines
2.9 KiB
Diff
From 54c057d1190d4405d66e752dff789a01b8612f9b Mon Sep 17 00:00:00 2001
|
|
From: Hangbin Liu <liuhangbin@gmail.com>
|
|
Date: Mon, 2 Dec 2024 14:33:16 +0800
|
|
Subject: [PATCH 3/4] lldpd: fix ttl range on ports
|
|
|
|
In the following fixed commit, I forgot to fix the ttl range for
|
|
interfaces/ports.
|
|
|
|
Fixes: a73e04f46ebe ("lldpd: limit tx ttl to 65535")
|
|
Reported-by: Fei Liu <feliu@redhat.com>
|
|
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
|
|
---
|
|
src/client/display.c | 3 ++-
|
|
src/daemon/protocols/edp.c | 3 ++-
|
|
src/daemon/protocols/sonmp.c | 3 ++-
|
|
3 files changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/client/display.c b/src/client/display.c
|
|
index 6b23ec5b9e33..978accf02eae 100644
|
|
--- a/src/client/display.c
|
|
+++ b/src/client/display.c
|
|
@@ -21,6 +21,7 @@
|
|
#include <ctype.h>
|
|
#include <time.h>
|
|
#include <errno.h>
|
|
+#include <sys/param.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
@@ -599,7 +600,7 @@ display_local_ttl(struct writer *w, lldpctl_conn_t *conn, int details)
|
|
tx_interval =
|
|
lldpctl_atom_get_int(configuration, lldpctl_k_config_tx_interval_ms);
|
|
|
|
- tx_interval = (tx_interval * tx_hold + 999) / 1000;
|
|
+ tx_interval = MIN((tx_interval * tx_hold + 999) / 1000, 65535);
|
|
|
|
if (asprintf(&ttl, "%lu", tx_interval) == -1) {
|
|
log_warnx("lldpctl", "not enough memory to build TTL.");
|
|
diff --git a/src/daemon/protocols/edp.c b/src/daemon/protocols/edp.c
|
|
index b55130b54806..773d210653f6 100644
|
|
--- a/src/daemon/protocols/edp.c
|
|
+++ b/src/daemon/protocols/edp.c
|
|
@@ -25,6 +25,7 @@
|
|
# include <errno.h>
|
|
# include <arpa/inet.h>
|
|
# include <fnmatch.h>
|
|
+# include <sys/param.h>
|
|
|
|
static int seq = 0;
|
|
|
|
@@ -296,7 +297,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardwar
|
|
goto malformed;
|
|
}
|
|
port->p_ttl = cfg ? cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold : 0;
|
|
- port->p_ttl = (port->p_ttl + 999) / 1000;
|
|
+ port->p_ttl = MIN((port->p_ttl + 999) / 1000, 65535);
|
|
chassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;
|
|
chassis->c_id_len = ETHER_ADDR_LEN;
|
|
if ((chassis->c_id = (char *)malloc(ETHER_ADDR_LEN)) == NULL) {
|
|
diff --git a/src/daemon/protocols/sonmp.c b/src/daemon/protocols/sonmp.c
|
|
index ddc2771d75c1..59636262ed28 100644
|
|
--- a/src/daemon/protocols/sonmp.c
|
|
+++ b/src/daemon/protocols/sonmp.c
|
|
@@ -24,6 +24,7 @@
|
|
# include <unistd.h>
|
|
# include <errno.h>
|
|
# include <arpa/inet.h>
|
|
+# include <sys/param.h>
|
|
|
|
static struct sonmp_chassis sonmp_chassis_types[] = {
|
|
{ 1, "unknown (via SONMP)" },
|
|
@@ -369,7 +370,7 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s, struct lldpd_hardware *hardw
|
|
TAILQ_INSERT_TAIL(&chassis->c_mgmt, mgmt, m_entries);
|
|
port->p_ttl =
|
|
cfg ? (cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold) : LLDPD_TTL;
|
|
- port->p_ttl = (port->p_ttl + 999) / 1000;
|
|
+ port->p_ttl = MIN((port->p_ttl + 999) / 1000, 65535);
|
|
|
|
port->p_id_subtype = LLDP_PORTID_SUBTYPE_LOCAL;
|
|
|
|
--
|
|
2.39.5 (Apple Git-154)
|
|
|