From 8f714af40b303628e30f74fc25dfcd30ed7318e9 Mon Sep 17 00:00:00 2001 From: Sebastian Pflieger Date: Wed, 20 Sep 2023 20:13:14 +0200 Subject: [PATCH 01/40] lldpd: add lldp_syscapabilities config option allow to overwrite the detected system capabilities e.g. if devices does not operate as bridge. Signed-off-by: Sebastian Pflieger (cherry picked from commit 3ce909914a12647bec52bcee0a162dd6d158a4f6) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 5b39144921f10..e1e8ac9fd4a5f 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -45,12 +45,16 @@ write_lldpd_conf() local lldp_mgmt_ip config_get lldp_mgmt_ip 'config' 'lldp_mgmt_ip' + local lldp_syscapabilities + config_get lldp_syscapabilities 'config' 'lldp_syscapabilities' + # Clear out the config file first echo -n > "$LLDPD_CONF" [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" [ -n "$lldp_description" ] && echo "configure system description" "\"$lldp_description\"" >> "$LLDPD_CONF" [ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF" [ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF" + [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled" "\"$lldp_syscapabilities\"" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR From b0f991d03cc5fb6bdda412347acd5287968ab107 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 22:32:19 +0000 Subject: [PATCH 02/40] lldpd: Init config read on reload Init script reload with trigger to detect config file update. Reload command added to attempt non-impactful lldpd reload where lldpcli can be used to update config without process restart. Config hash function used to track whether process restart is needed. Signed-off-by: Stephen Howell (cherry picked from commit e483c247dc75723a32d03b5b1149f7fd61ac8ac6) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- .../network/services/lldpd/files/lldpd.init | 66 ++++++++++++++++--- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index e1e8ac9fd4a5f..a52e6e0ec4618 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -5,11 +5,17 @@ START=90 STOP=01 USE_PROCD=1 +LLDPDBIN=/usr/sbin/lldpd LLDPCLI=/usr/sbin/lldpcli LLDPSOCKET=/var/run/lldpd.socket LLDPD_CONF=/tmp/lldpd.conf LLDPD_CONFS_DIR=/tmp/lldpd.d +LLDPD_RUN=/var/run/lldpd +LLDPD_RESTART_HASH=${LLDPD_RUN}/lldpd.restart_hash + +. "$IPKG_INSTROOT/lib/functions/network.sh" + find_release_info() { [ -s /etc/os-release ] && . /etc/os-release @@ -19,10 +25,27 @@ find_release_info() echo "${PRETTY_NAME:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)" } +get_config_restart_hash() { + local var="$1" + local _string _hash v + + config_load 'lldpd' + + config_get v 'config' 'lldp_class'; append _string "$v" "," + config_get v 'config' 'agentxsocket'; append _string "$v" "," + config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," + config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," + config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," + config_get_bool v 'config' 'enable_edp'; append _string "$v" "," + config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," + config_get_bool v 'config' 'enable_sonmp'; append _string "$v" "," + + _hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'` + export -n "$var=$_hash" +} + write_lldpd_conf() { - . /lib/functions/network.sh - local lldp_description config_load 'lldpd' @@ -60,10 +83,6 @@ write_lldpd_conf() [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR } -service_triggers() { - procd_add_reload_trigger "lldpd" -} - start_service() { local enable_cdp @@ -85,14 +104,15 @@ start_service() { config_get_bool readonly_mode 'config' 'readonly_mode' 0 config_get agentxsocket 'config' 'agentxsocket' - mkdir -p /var/run/lldp - chown lldp:lldp /var/run/lldp + mkdir -p ${LLDPD_RUN} + chown lldp:lldp ${LLDPD_RUN} # When lldpd starts, it also loads up what we write in this config file write_lldpd_conf procd_open_instance - procd_set_param command /usr/sbin/lldpd -d + procd_set_param command ${LLDPDBIN} + procd_append_param command -d [ $enable_cdp -gt 0 ] && procd_append_param command '-c' [ $enable_fdp -gt 0 ] && procd_append_param command '-f' @@ -102,13 +122,38 @@ start_service() { [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" + # Overwrite default configuration locations processed by lldpcli at start + procd_append_param command -O "$LLDPD_CONF" + + local restart_hash + get_config_restart_hash restart_hash + echo -n "$restart_hash" > $LLDPD_RESTART_HASH + # set auto respawn behavior procd_set_param respawn procd_close_instance } +service_triggers() { + procd_add_config_trigger "config.change" "lldpd" /etc/init.d/lldpd reload +} + reload_service() { running || return 1 + + local running_hash="" + local config_hash="" + + get_config_restart_hash config_hash + if [ -f ${LLDPD_RESTART_HASH} ]; then running_hash=`cat $LLDPD_RESTART_HASH`; fi + + if [ "x$running_hash" != "x$config_hash" ]; then + # Restart LLDPd + # Some parameters can't be configured at runtime + restart + return 0 + fi + $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF pause unconfigure lldp custom-tlv @@ -130,5 +175,6 @@ reload_service() { } stop_service() { - rm -rf /var/run/lldp $LLDPSOCKET + rm -rf ${LLDPD_RUN} $LLDPSOCKET 2>/dev/null } + From f79ab96312b04e4641031be2ffe4b82b9a281122 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 22:41:22 +0000 Subject: [PATCH 03/40] lldpd: LLDPD binds to only specified interfaces Bind to the configured system interfaces only. Switchport interfaces are no longer ignored and uci interface values for LLDPD are honored. Signed-off-by: Stephen Howell (cherry picked from commit 064b4999ad1f37f4c6ccf95a0404007b990ed0ef) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- .../network/services/lldpd/files/lldpd.init | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index a52e6e0ec4618..411fa0c6524aa 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -33,6 +33,7 @@ get_config_restart_hash() { config_get v 'config' 'lldp_class'; append _string "$v" "," config_get v 'config' 'agentxsocket'; append _string "$v" "," + config_get v 'config' 'cid_interface'; append _string "$v" "," config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," @@ -44,6 +45,21 @@ get_config_restart_hash() { export -n "$var=$_hash" } +get_config_cid_ifaces() { + local _ifaces + config_get _ifaces 'config' 'cid_interface' + + local _iface _ifnames="" + for _iface in $_ifaces; do + local _ifname="" + if network_get_device _ifname "$_iface" || [ -e "/sys/class/net/$_iface" ]; then + append _ifnames "${_ifname:-$_iface}" "," + fi + done + + export -n "${1}=$_ifnames" +} + write_lldpd_conf() { local lldp_description @@ -122,6 +138,11 @@ start_service() { [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" + # ChassisID interfaces + local ifnames + get_config_cid_ifaces ifnames + [ -n "$ifnames" ] && procd_append_param command -C "$ifnames" + # Overwrite default configuration locations processed by lldpcli at start procd_append_param command -O "$LLDPD_CONF" From 1d83e4c5ed766d4bf516229165f1713f170c5e63 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 22:52:10 +0000 Subject: [PATCH 04/40] lldpd: Allow neighbour filtering add filter option to init script. Signed-off-by: Stephen Howell (cherry picked from commit ac3ed75309e7db93bf2316eccba8106e3fe8f9fc) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 411fa0c6524aa..48d15a48246e6 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -34,6 +34,7 @@ get_config_restart_hash() { config_get v 'config' 'lldp_class'; append _string "$v" "," config_get v 'config' 'agentxsocket'; append _string "$v" "," config_get v 'config' 'cid_interface'; append _string "$v" "," + config_get v 'config' 'filter'; append _string "$v" "," config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," @@ -109,6 +110,7 @@ start_service() { local lldp_location local readonly_mode local agentxsocket + local filter config_load 'lldpd' config_get_bool enable_cdp 'config' 'enable_cdp' 0 @@ -119,6 +121,7 @@ start_service() { config_get lldp_location 'config' 'lldp_location' config_get_bool readonly_mode 'config' 'readonly_mode' 0 config_get agentxsocket 'config' 'agentxsocket' + config_get filter 'config' 'filter' 15 mkdir -p ${LLDPD_RUN} chown lldp:lldp ${LLDPD_RUN} @@ -137,6 +140,7 @@ start_service() { [ $readonly_mode -gt 0 ] && procd_append_param command '-r' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" + [ -n "$filter" ] && procd_append_param command -H "$filter" # ChassisID interfaces local ifnames From 59ad77fabaf234e00a0598d975af42e1fcaf762d Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 22:57:18 +0000 Subject: [PATCH 05/40] lldpd: Init adds no-version option add option to disable advertising kernel version Signed-off-by: Stephen Howell (cherry picked from commit 058f284b1a802fafafb2cfde522693bd43aeaf4d) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 48d15a48246e6..0456e7875e23b 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -36,6 +36,7 @@ get_config_restart_hash() { config_get v 'config' 'cid_interface'; append _string "$v" "," config_get v 'config' 'filter'; append _string "$v" "," config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," + config_get_bool v 'config' 'lldp_no_version'; append _string "$v" "," config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," config_get_bool v 'config' 'enable_edp'; append _string "$v" "," @@ -108,6 +109,7 @@ start_service() { local enable_edp local lldp_class local lldp_location + local lldp_no_version local readonly_mode local agentxsocket local filter @@ -119,6 +121,7 @@ start_service() { config_get_bool enable_edp 'config' 'enable_edp' 0 config_get lldp_class 'config' 'lldp_class' config_get lldp_location 'config' 'lldp_location' + config_get_bool lldp_no_version 'config' 'lldp_no_version' 0 config_get_bool readonly_mode 'config' 'readonly_mode' 0 config_get agentxsocket 'config' 'agentxsocket' config_get filter 'config' 'filter' 15 @@ -138,6 +141,7 @@ start_service() { [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' [ $enable_edp -gt 0 ] && procd_append_param command '-e' [ $readonly_mode -gt 0 ] && procd_append_param command '-r' + [ $lldp_no_version -gt 0 ] && procd_append_param command '-k' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" [ -n "$filter" ] && procd_append_param command -H "$filter" From 15e6259231226148a100e7107c09dccf033babd9 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 23:08:08 +0000 Subject: [PATCH 06/40] lldpd: option to disable LLDP-MED inventory TLV add option to disable LLDP-MED inventory TLV transmission Signed-off-by: Stephen Howell (cherry picked from commit 1753498b01d86b8d63349b01cb04026c07c343d9) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 4 ++++ package/network/services/lldpd/files/lldpd.init | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 289adc55c9407..9e4ee0727e370 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -82,6 +82,10 @@ endif ifneq ($(CONFIG_LLDPD_WITH_SNMP),y) sed -i -e '/agentxsocket/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd endif +ifneq ($(CONFIG_LLDPD_WITH_LLDPMED),y) + sed -i -e 's/CONFIG_LLDPD_WITH_LLDPMED=y/CONFIG_LLDPD_WITH_LLDPMED=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/agentxsocket/d' $(1)/etc/config/lldpd +endif endef define Package/lldpd/conffiles diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 0456e7875e23b..4eca9ac8f40d3 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -4,6 +4,8 @@ START=90 STOP=01 +CONFIG_LLDPD_WITH_LLDPMED=y + USE_PROCD=1 LLDPDBIN=/usr/sbin/lldpd LLDPCLI=/usr/sbin/lldpcli @@ -37,6 +39,9 @@ get_config_restart_hash() { config_get v 'config' 'filter'; append _string "$v" "," config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," config_get_bool v 'config' 'lldp_no_version'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + config_get_bool v 'config' 'lldpmed_no_inventory'; append _string "$v" "," + fi config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," config_get_bool v 'config' 'enable_edp'; append _string "$v" "," @@ -110,6 +115,7 @@ start_service() { local lldp_class local lldp_location local lldp_no_version + local lldpmed_no_inventory local readonly_mode local agentxsocket local filter @@ -122,6 +128,9 @@ start_service() { config_get lldp_class 'config' 'lldp_class' config_get lldp_location 'config' 'lldp_location' config_get_bool lldp_no_version 'config' 'lldp_no_version' 0 + if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + config_get_bool lldpmed_no_inventory 'config' 'lldpmed_no_inventory' 0 + fi config_get_bool readonly_mode 'config' 'readonly_mode' 0 config_get agentxsocket 'config' 'agentxsocket' config_get filter 'config' 'filter' 15 @@ -142,6 +151,7 @@ start_service() { [ $enable_edp -gt 0 ] && procd_append_param command '-e' [ $readonly_mode -gt 0 ] && procd_append_param command '-r' [ $lldp_no_version -gt 0 ] && procd_append_param command '-k' + [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" [ -n "$filter" ] && procd_append_param command -H "$filter" From be4824977bf7a61aceb0df7743d32cbcc4e128cb Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 23:46:53 +0000 Subject: [PATCH 07/40] lldpd: add LLDP MED options add option to enable LLDP MED fast-start and set fast-start timer Signed-off-by: Stephen Howell (cherry picked from commit 24176a6bdd8f26040a97960868fd0d9ee968d695) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- .../network/services/lldpd/files/lldpd.init | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 4eca9ac8f40d3..55fbe61fc4d60 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -94,6 +94,14 @@ write_lldpd_conf() local lldp_syscapabilities config_get lldp_syscapabilities 'config' 'lldp_syscapabilities' + if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + local lldpmed_fast_start + config_get_bool lldpmed_fast_start 'config' 'lldpmed_fast_start' 0 + + local lldpmed_fast_start_tx_interval + config_get lldpmed_fast_start_tx_interval 'config' 'lldpmed_fast_start_tx_interval' 0 + fi + # Clear out the config file first echo -n > "$LLDPD_CONF" [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" @@ -101,6 +109,14 @@ write_lldpd_conf() [ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF" [ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF" [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled" "\"$lldp_syscapabilities\"" >> "$LLDPD_CONF" + if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_fast_start -gt 0 ]; then + if [ $lldpmed_fast_start_tx_interval -gt 0 ]; then + echo "configure med fast-start tx-interval" "\"$lldpmed_fast_start_tx_interval\"" >> "$LLDPD_CONF" + else + echo "configure med fast-start" "enable" >> "$LLDPD_CONF" + fi + fi + # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR @@ -192,7 +208,7 @@ reload_service() { restart return 0 fi - + $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF pause unconfigure lldp custom-tlv @@ -201,6 +217,11 @@ reload_service() { unconfigure system hostname unconfigure system ip management pattern EOF + if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF + unconfigure med fast-start + EOF + fi # Rewrite lldpd.conf # If something changed it should be included by the lldpcli call write_lldpd_conf From 6cbc1007627a7e7a2ce10de1a4721107adf248da Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 23:49:21 +0000 Subject: [PATCH 08/40] lldpd: add agent-type option add option to set agent-type to control propogation Signed-off-by: Stephen Howell (cherry picked from commit c98ee4dbb3db0f064d990941cdd82e872da76946) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 55fbe61fc4d60..31dca872cc490 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -102,6 +102,9 @@ write_lldpd_conf() config_get lldpmed_fast_start_tx_interval 'config' 'lldpmed_fast_start_tx_interval' 0 fi + local lldp_agenttype + config_get lldp_agenttype 'config' 'lldp_agenttype' 'nearest-bridge' + # Clear out the config file first echo -n > "$LLDPD_CONF" [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" @@ -116,6 +119,7 @@ write_lldpd_conf() echo "configure med fast-start" "enable" >> "$LLDPD_CONF" fi fi + [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR From ed3f182d63c13dfe5bf386242de128b16da6c66f Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 16 Dec 2023 23:49:44 +0000 Subject: [PATCH 09/40] lldpd: add portidsubtype option add option portidsubtype to correct port identifiers and descriptions Signed-off-by: Stephen Howell (cherry picked from commit ac771313ebedd2c4bfda8adef47650d45d77c32d) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 31dca872cc490..db81f8a9aed94 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -105,6 +105,9 @@ write_lldpd_conf() local lldp_agenttype config_get lldp_agenttype 'config' 'lldp_agenttype' 'nearest-bridge' + local lldp_portidsubtype + config_get lldp_portidsubtype 'config' 'lldp_portidsubtype' 'macaddress' + # Clear out the config file first echo -n > "$LLDPD_CONF" [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" @@ -120,7 +123,7 @@ write_lldpd_conf() fi fi [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" - + [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR From 7f58fc14d8356b84bfe5d43339720f721111a877 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:17:14 +0000 Subject: [PATCH 10/40] lldpd: allow disabling LLDP protcol add option to allow LLDP disabling while using other supported protocols Signed-off-by: Stephen Howell (cherry picked from commit 61dbe756d8edc1adcd152920f71d6dce26232662) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index db81f8a9aed94..98e7e97193b29 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -43,6 +43,7 @@ get_config_restart_hash() { config_get_bool v 'config' 'lldpmed_no_inventory'; append _string "$v" "," fi config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," + config_get_bool v 'config' 'force_lldp'; append _string "$v" "," config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," config_get_bool v 'config' 'enable_edp'; append _string "$v" "," config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," @@ -131,6 +132,8 @@ write_lldpd_conf() start_service() { + local enable_lldp + local force_lldp local enable_cdp local enable_fdp local enable_sonmp @@ -144,6 +147,8 @@ start_service() { local filter config_load 'lldpd' + config_get_bool enable_lldp 'config' 'enable_lldp' 1 + config_get_bool force_lldp 'config' 'force_lldp' 0 config_get_bool enable_cdp 'config' 'enable_cdp' 0 config_get_bool enable_fdp 'config' 'enable_fdp' 0 config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 @@ -168,6 +173,15 @@ start_service() { procd_set_param command ${LLDPDBIN} procd_append_param command -d + if [ $enable_lldp -gt 0 ]; then + if [ $force_lldp -gt 0 ]; then + procd_append_param command '-l' + fi + else + # Disable LLDP + procd_append_param command '-ll' + fi + [ $enable_cdp -gt 0 ] && procd_append_param command '-c' [ $enable_fdp -gt 0 ] && procd_append_param command '-f' [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' From d6da0952ab510b933d8f047f4f235bae2426a41f Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:21:12 +0000 Subject: [PATCH 11/40] lldpd: set CDP version and allow forcing CDP on add option to specify CDPv1 or CDPv2 and separately enable or force each Signed-off-by: Stephen Howell (cherry picked from commit b67182008fd124706be0ec3ce67347447554ffd5) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 3 +- .../network/services/lldpd/files/lldpd.init | 44 +++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 9e4ee0727e370..a83378bcba0de 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -68,7 +68,8 @@ define Package/lldpd/install $(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd $(INSTALL_CONF) ./files/lldpd.config $(1)/etc/config/lldpd ifneq ($(CONFIG_LLDPD_WITH_CDP),y) - sed -i -e '/cdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd + sed -i -e 's/CONFIG_LLDPD_WITH_CDP=y/CONFIG_LLDPD_WITH_CDP=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/cdp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_FDP),y) sed -i -e '/fdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 98e7e97193b29..faf100b1989d2 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -4,6 +4,7 @@ START=90 STOP=01 +CONFIG_LLDPD_WITH_CDP=y CONFIG_LLDPD_WITH_LLDPMED=y USE_PROCD=1 @@ -44,7 +45,12 @@ get_config_restart_hash() { fi config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," config_get_bool v 'config' 'force_lldp'; append _string "$v" "," - config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_CDP" == "y" ]; then + config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," + config_get v 'config' 'cdp_version'; append _string "$v" "," + config_get_bool v 'config' 'force_cdp'; append _string "$v" "," + config_get_bool v 'config' 'force_cdpv2'; append _string "$v" "," + fi config_get_bool v 'config' 'enable_edp'; append _string "$v" "," config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," config_get_bool v 'config' 'enable_sonmp'; append _string "$v" "," @@ -135,6 +141,9 @@ start_service() { local enable_lldp local force_lldp local enable_cdp + local cdp_version + local force_cdp + local force_cdpv2 local enable_fdp local enable_sonmp local enable_edp @@ -149,7 +158,12 @@ start_service() { config_load 'lldpd' config_get_bool enable_lldp 'config' 'enable_lldp' 1 config_get_bool force_lldp 'config' 'force_lldp' 0 - config_get_bool enable_cdp 'config' 'enable_cdp' 0 + if [ "$CONFIG_LLDPD_WITH_CDP" == "y" ]; then + config_get_bool enable_cdp 'config' 'enable_cdp' 0 + config_get cdp_version 'config' 'cdp_version' 'cdpv1v2' + config_get_bool force_cdp 'config' 'force_cdp' 0 + config_get_bool force_cdpv2 'config' 'force_cdpv2' 0 + fi config_get_bool enable_fdp 'config' 'enable_fdp' 0 config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 config_get_bool enable_edp 'config' 'enable_edp' 0 @@ -182,12 +196,34 @@ start_service() { procd_append_param command '-ll' fi - [ $enable_cdp -gt 0 ] && procd_append_param command '-c' + if [ "$CONFIG_LLDPD_WITH_CDP" == "y" ] && [ $enable_cdp -gt 0 ]; then + if [ $cdp_version == "cdpv2" ]; then + if [ $force_cdp -gt 0 ]; then + # CDPv1 disabled, CDPv2 forced + procd_append_param command '-ccccc' + else + # CDPv1 disabled, CDPv2 enabled + procd_append_param command '-cccc' + fi + elif [ $cdp_version == "cdpv1v2" ]; then + if [ $force_cdp -gt 0 ] && [ $force_cdpv2 -gt 0 ]; then + # CDPv1 enabled, CDPv2 forced + procd_append_param command '-ccc' + elif [ $force_cdp -gt 0 ]; then + # CDPv1 forced, CDPv2 enabled + procd_append_param command '-cc' + else + # CDPv1 and CDPv2 enabled + procd_append_param command '-c' + fi + fi + fi + [ $enable_fdp -gt 0 ] && procd_append_param command '-f' [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' [ $enable_edp -gt 0 ] && procd_append_param command '-e' [ $readonly_mode -gt 0 ] && procd_append_param command '-r' - [ $lldp_no_version -gt 0 ] && procd_append_param command '-k' + [ $lldp_no_version -gt 0 ] && procd_append_param commanpackage/network/services/lldpd/Makefile package/network/services/lldpd/files/lldpd.initd '-k' [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" From 1201a69664061e5c349b9da5387f2c8d23797692 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:26:21 +0000 Subject: [PATCH 12/40] lldpd: add option to force FDP on add option to force FDP when no peers detected Signed-off-by: Stephen Howell (cherry picked from commit 1be2088a5247b2cfabe8be991c1e52ddaf780a16) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 3 ++- .../network/services/lldpd/files/lldpd.init | 27 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index a83378bcba0de..4dade4a14817c 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -72,7 +72,8 @@ ifneq ($(CONFIG_LLDPD_WITH_CDP),y) sed -i -e '/cdp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_FDP),y) - sed -i -e '/fdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd + sed -i -e 's/CONFIG_LLDPD_WITH_FDP=y/CONFIG_LLDPD_WITH_FDP=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/fdp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_EDP),y) sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index faf100b1989d2..bd90cea85b221 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -5,6 +5,7 @@ START=90 STOP=01 CONFIG_LLDPD_WITH_CDP=y +CONFIG_LLDPD_WITH_FDP=y CONFIG_LLDPD_WITH_LLDPMED=y USE_PROCD=1 @@ -52,7 +53,10 @@ get_config_restart_hash() { config_get_bool v 'config' 'force_cdpv2'; append _string "$v" "," fi config_get_bool v 'config' 'enable_edp'; append _string "$v" "," - config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then + config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," + config_get_bool v 'config' 'force_fdp'; append _string "$v" "," + fi config_get_bool v 'config' 'enable_sonmp'; append _string "$v" "," _hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'` @@ -60,8 +64,7 @@ get_config_restart_hash() { } get_config_cid_ifaces() { - local _ifaces - config_get _ifaces 'config' 'cid_interface' + local _ifacesCONFIG_LLDPD_WITH_FDP local _iface _ifnames="" for _iface in $_ifaces; do @@ -145,6 +148,7 @@ start_service() { local force_cdp local force_cdpv2 local enable_fdp + local force_fdp local enable_sonmp local enable_edp local lldp_class @@ -164,7 +168,10 @@ start_service() { config_get_bool force_cdp 'config' 'force_cdp' 0 config_get_bool force_cdpv2 'config' 'force_cdpv2' 0 fi - config_get_bool enable_fdp 'config' 'enable_fdp' 0 + if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then + config_get_bool enable_fdp 'config' 'enable_fdp' 0 + config_get_bool force_fdp 'config' 'force_fdp' 0 + fi config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 config_get_bool enable_edp 'config' 'enable_edp' 0 config_get lldp_class 'config' 'lldp_class' @@ -219,7 +226,16 @@ start_service() { fi fi - [ $enable_fdp -gt 0 ] && procd_append_param command '-f' + if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ] && [ $enable_fdp -gt 0 ]; then + if [ $force_fdp -gt 0 ]; then + # FDP enbled and forced + procd_append_param command '-ff' + else + # FDP enabled + procd_append_param command '-f' + fi + fi + [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' [ $enable_edp -gt 0 ] && procd_append_param command '-e' [ $readonly_mode -gt 0 ] && procd_append_param command '-r' @@ -278,6 +294,7 @@ reload_service() { $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF unconfigure med fast-start EOF + fi # Rewrite lldpd.conf # If something changed it should be included by the lldpcli call From 18fc86a0f5802809fc0b1623e78b464a23376a26 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:28:43 +0000 Subject: [PATCH 13/40] lldpd: add option to force SONMP enabled add option to force SONMP to be enabled even when no peer detected Signed-off-by: Stephen Howell (cherry picked from commit 4ac134aa78d2b4441b0afd485d1d26dbd53d7276) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 3 ++- .../network/services/lldpd/files/lldpd.init | 24 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 4dade4a14817c..02ef2d7520aa6 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -79,7 +79,8 @@ ifneq ($(CONFIG_LLDPD_WITH_EDP),y) sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_SONMP),y) - sed -i -e '/sonmp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd + sed -i -e 's/CONFIG_LLDPD_WITH_SONMP=y/CONFIG_LLDPD_WITH_SONMP=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/sonmp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_SNMP),y) sed -i -e '/agentxsocket/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index bd90cea85b221..8e825e4f879ff 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -7,6 +7,7 @@ STOP=01 CONFIG_LLDPD_WITH_CDP=y CONFIG_LLDPD_WITH_FDP=y CONFIG_LLDPD_WITH_LLDPMED=y +CONFIG_LLDPD_WITH_SONMP=y USE_PROCD=1 LLDPDBIN=/usr/sbin/lldpd @@ -57,7 +58,10 @@ get_config_restart_hash() { config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," config_get_bool v 'config' 'force_fdp'; append _string "$v" "," fi - config_get_bool v 'config' 'enable_sonmp'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ]; then + config_get_bool v 'config' 'enable_sonmp'; append _string "$v" "," + config_get_bool v 'config' 'force_sonmp'; append _string "$v" "," + fi _hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'` export -n "$var=$_hash" @@ -150,6 +154,7 @@ start_service() { local enable_fdp local force_fdp local enable_sonmp + local force_sonmp local enable_edp local lldp_class local lldp_location @@ -172,7 +177,10 @@ start_service() { config_get_bool enable_fdp 'config' 'enable_fdp' 0 config_get_bool force_fdp 'config' 'force_fdp' 0 fi - config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 + if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ]; then + config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 + config_get_bool force_sonmp 'config' 'force_sonmp' 0 + fi config_get_bool enable_edp 'config' 'enable_edp' 0 config_get lldp_class 'config' 'lldp_class' config_get lldp_location 'config' 'lldp_location' @@ -236,8 +244,18 @@ start_service() { fi fi - [ $enable_sonmp -gt 0 ] && procd_append_param command '-s' + if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ] && [ $enable_sonmp -gt 0 ]; then + if [ $force_sonmp -gt 0 ]; then + # SONMP enabled and forced + procd_append_param command '-ss' + else + # SONMP enabled + procd_append_param command '-s' + fi + fi + [ $enable_edp -gt 0 ] && procd_append_param command '-e' + [ $readonly_mode -gt 0 ] && procd_append_param command '-r' [ $lldp_no_version -gt 0 ] && procd_append_param commanpackage/network/services/lldpd/Makefile package/network/services/lldpd/files/lldpd.initd '-k' [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i' From b2008404abd3cad31a1999a0720e61453e453b67 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:34:37 +0000 Subject: [PATCH 14/40] lldpd: add option to set system platform add option to override system platform instead of using kernel name Signed-off-by: Stephen Howell (cherry picked from commit 4159acceebeec646fb2ebecdd85561ba140f1ce4) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 8e825e4f879ff..656128ef5d882 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -122,6 +122,9 @@ write_lldpd_conf() local lldp_portidsubtype config_get lldp_portidsubtype 'config' 'lldp_portidsubtype' 'macaddress' + local lldp_platform + config_get lldp_platform 'config' 'lldp_platform' "" + # Clear out the config file first echo -n > "$LLDPD_CONF" [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" @@ -138,6 +141,7 @@ write_lldpd_conf() fi [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" + [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR @@ -307,6 +311,7 @@ reload_service() { unconfigure system description unconfigure system hostname unconfigure system ip management pattern + unconfigure system platform EOF if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF From a7f749ded4a6d4c3d597052182b632c2d435b6d5 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:39:48 +0000 Subject: [PATCH 15/40] lldpd: add option for tx delay and tx hold add option to set LLDP transmit delay, hold timers to set update frequency Signed-off-by: Stephen Howell (cherry picked from commit a5f715da713304972467612d6934130ce3aa2837) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 656128ef5d882..b69ec16086732 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -125,6 +125,12 @@ write_lldpd_conf() local lldp_platform config_get lldp_platform 'config' 'lldp_platform' "" + local lldp_tx_interval + config_get lldp_tx_interval 'config' 'lldp_tx_interval' 0 + + local lldp_tx_hold + config_get lldp_tx_hold 'config' 'lldp_tx_hold' 0 + # Clear out the config file first echo -n > "$LLDPD_CONF" [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" @@ -142,6 +148,8 @@ write_lldpd_conf() [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" + [ $lldp_tx_interval -gt 0 ] && echo "configure lldp tx-interval" "$lldp_tx_interval" >> "$LLDPD_CONF" + [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold" "$lldp_tx_hold" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR From 02e3845890f933ab4527b57cc96806285fb3e5a8 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sun, 17 Dec 2023 00:43:09 +0000 Subject: [PATCH 16/40] lldpd: Update Makefile package release increment Makefile package release to reflect changes to init script Signed-off-by: Stephen Howell (cherry picked from commit 1b36d44323cdd467980f83318be0837b8a1fd487) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 02ef2d7520aa6..fa4143c713ae9 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lldpd PKG_VERSION:=1.0.17 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/lldpd/lldpd/releases/download/$(PKG_VERSION)/ From 13193cb070353dba1c276a79e6f0ec9c2e5a3001 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 3 Feb 2024 13:51:49 +0000 Subject: [PATCH 17/40] lldpd: only use snmp options when compiled in prevent SNMP options being passed unless lldpd supports them Signed-off-by: Stephen Howell (cherry picked from commit 8b2d02e48cd2559a52e1cbf04143028e50da6a88) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 3 ++- package/network/services/lldpd/files/lldpd.init | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index fa4143c713ae9..bd01077b66697 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -83,7 +83,8 @@ ifneq ($(CONFIG_LLDPD_WITH_SONMP),y) sed -i -e '/sonmp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_SNMP),y) - sed -i -e '/agentxsocket/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd + sed -i -e 's/CONFIG_LLDPD_WITH_SNMP=y/CONFIG_LLDPD_WITH_SNMP=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/agentxsocket/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_LLDPMED),y) sed -i -e 's/CONFIG_LLDPD_WITH_LLDPMED=y/CONFIG_LLDPD_WITH_LLDPMED=n/g' $(1)/etc/init.d/lldpd diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index b69ec16086732..98769688ecf8b 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -7,6 +7,7 @@ STOP=01 CONFIG_LLDPD_WITH_CDP=y CONFIG_LLDPD_WITH_FDP=y CONFIG_LLDPD_WITH_LLDPMED=y +CONFIG_LLDPD_WITH_SNMP=y CONFIG_LLDPD_WITH_SONMP=y USE_PROCD=1 @@ -37,7 +38,9 @@ get_config_restart_hash() { config_load 'lldpd' config_get v 'config' 'lldp_class'; append _string "$v" "," - config_get v 'config' 'agentxsocket'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ]; then + config_get v 'config' 'agentxsocket'; append _string "$v" "," + fi config_get v 'config' 'cid_interface'; append _string "$v" "," config_get v 'config' 'filter'; append _string "$v" "," config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," @@ -201,7 +204,9 @@ start_service() { config_get_bool lldpmed_no_inventory 'config' 'lldpmed_no_inventory' 0 fi config_get_bool readonly_mode 'config' 'readonly_mode' 0 - config_get agentxsocket 'config' 'agentxsocket' + if [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ]; then + config_get agentxsocket 'config' 'agentxsocket' + fi config_get filter 'config' 'filter' 15 mkdir -p ${LLDPD_RUN} @@ -272,7 +277,7 @@ start_service() { [ $lldp_no_version -gt 0 ] && procd_append_param commanpackage/network/services/lldpd/Makefile package/network/services/lldpd/files/lldpd.initd '-k' [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" - [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" + [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ] && [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" [ -n "$filter" ] && procd_append_param command -H "$filter" # ChassisID interfaces From 4ebd60b0835819a83f54ba5a8c34803cdff1ce66 Mon Sep 17 00:00:00 2001 From: Stephen Howell Date: Sat, 3 Feb 2024 14:16:09 +0000 Subject: [PATCH 18/40] lldpd: add option to force EDP allow EDP support if compiled and add force EDP option Signed-off-by: Stephen Howell (cherry picked from commit d274867c217cade795537af93ff9b209e472e19c) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 3 ++- .../network/services/lldpd/files/lldpd.init | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index bd01077b66697..1f8d1e546b0d5 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -76,7 +76,8 @@ ifneq ($(CONFIG_LLDPD_WITH_FDP),y) sed -i -e '/fdp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_EDP),y) - sed -i -e '/edp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd + sed -i -e 's/CONFIG_LLDPD_WITH_EDP=y/CONFIG_LLDPD_WITH_EDP=n/g' $(1)/etc/init.d/lldpd + sed -i -e '/edp/d' $(1)/etc/config/lldpd endif ifneq ($(CONFIG_LLDPD_WITH_SONMP),y) sed -i -e 's/CONFIG_LLDPD_WITH_SONMP=y/CONFIG_LLDPD_WITH_SONMP=n/g' $(1)/etc/init.d/lldpd diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 98769688ecf8b..f90b4a237cd0b 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -5,6 +5,7 @@ START=90 STOP=01 CONFIG_LLDPD_WITH_CDP=y +CONFIG_LLDPD_WITH_EDP=y CONFIG_LLDPD_WITH_FDP=y CONFIG_LLDPD_WITH_LLDPMED=y CONFIG_LLDPD_WITH_SNMP=y @@ -56,7 +57,10 @@ get_config_restart_hash() { config_get_bool v 'config' 'force_cdp'; append _string "$v" "," config_get_bool v 'config' 'force_cdpv2'; append _string "$v" "," fi - config_get_bool v 'config' 'enable_edp'; append _string "$v" "," + if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ]; then + config_get_bool v 'config' 'enable_edp'; append _string "$v" "," + config_get_bool v 'config' 'force_edp'; append _string "$v" "," + fi if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," config_get_bool v 'config' 'force_fdp'; append _string "$v" "," @@ -171,6 +175,7 @@ start_service() { local enable_sonmp local force_sonmp local enable_edp + local force_edp local lldp_class local lldp_location local lldp_no_version @@ -196,7 +201,10 @@ start_service() { config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 config_get_bool force_sonmp 'config' 'force_sonmp' 0 fi - config_get_bool enable_edp 'config' 'enable_edp' 0 + if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ]; then + config_get_bool enable_edp 'config' 'enable_edp' 0 + config_get_bool force_edp 'config' 'force_edp' 0 + fi config_get lldp_class 'config' 'lldp_class' config_get lldp_location 'config' 'lldp_location' config_get_bool lldp_no_version 'config' 'lldp_no_version' 0 @@ -271,7 +279,15 @@ start_service() { fi fi - [ $enable_edp -gt 0 ] && procd_append_param command '-e' + if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ] && [ $enable_edp -gt 0 ]; then + if [ $force_edp -gt 0 ]; then + # EDP enbled and forced + procd_append_param command '-ee' + else + # EDP enbled + procd_append_param command '-e' + fi + fi [ $readonly_mode -gt 0 ] && procd_append_param command '-r' [ $lldp_no_version -gt 0 ] && procd_append_param commanpackage/network/services/lldpd/Makefile package/network/services/lldpd/files/lldpd.initd '-k' From 1d14e0abfc354487d27df4e0ec933f67583cf2db Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 15:57:28 +0100 Subject: [PATCH 19/40] lldpd: fix -k 'lldp_no_version' row Supplementary fix for PR #14193 and commit b67182008fd124706be0ec3ce67347447554ffd5 Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 97eb3bf76c17328f80554e6a3603de00d835e4c5) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index f90b4a237cd0b..d4642238a3e27 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -290,7 +290,7 @@ start_service() { fi [ $readonly_mode -gt 0 ] && procd_append_param command '-r' - [ $lldp_no_version -gt 0 ] && procd_append_param commanpackage/network/services/lldpd/Makefile package/network/services/lldpd/files/lldpd.initd '-k' + [ $lldp_no_version -gt 0 ] && procd_append_param command '-k' [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ] && [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" From c0217ef8f82c206240cab9f35d5e85a8bd8be28a Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 15:59:27 +0100 Subject: [PATCH 20/40] lldpd: spell fixes Supplementary fix for PR #14193 Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 1909b6f8835c1381f859c85394defe993e016edd) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index d4642238a3e27..c6d7b82c2c45d 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -261,7 +261,7 @@ start_service() { if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ] && [ $enable_fdp -gt 0 ]; then if [ $force_fdp -gt 0 ]; then - # FDP enbled and forced + # FDP enabled and forced procd_append_param command '-ff' else # FDP enabled @@ -281,10 +281,10 @@ start_service() { if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ] && [ $enable_edp -gt 0 ]; then if [ $force_edp -gt 0 ]; then - # EDP enbled and forced + # EDP enabled and forced procd_append_param command '-ee' else - # EDP enbled + # EDP enabled procd_append_param command '-e' fi fi From b1ddf0a859cdd257aa0cae823e34515fa0d29582 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 20:26:13 +0100 Subject: [PATCH 21/40] lldpd: fix a paste error from commit 1be2088a5247b2cfabe8be991c1e52ddaf780a16 The original PR #13018 did not exhibit this. Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 4fb8fea6de363aeeeca029ed9801b85cdbf45f0c) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index c6d7b82c2c45d..fc24b9f7cd358 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -75,7 +75,8 @@ get_config_restart_hash() { } get_config_cid_ifaces() { - local _ifacesCONFIG_LLDPD_WITH_FDP + local _ifaces + config_get _ifaces 'config' 'cid_interface' local _iface _ifnames="" for _iface in $_ifaces; do From 4446346fdd097adaee9d85c4bb610f6ee4156b84 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 21:31:57 +0100 Subject: [PATCH 22/40] lldpd: remove unneeded quotes and variable quoting from commit 24176a6bdd8f26040a97960868fd0d9ee968d695 Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 20a4dddeb0366a56c14f9128392ffe8d0b62e32d) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index fc24b9f7cd358..47354f3c4e0b2 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -148,7 +148,7 @@ write_lldpd_conf() [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled" "\"$lldp_syscapabilities\"" >> "$LLDPD_CONF" if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_fast_start -gt 0 ]; then if [ $lldpmed_fast_start_tx_interval -gt 0 ]; then - echo "configure med fast-start tx-interval" "\"$lldpmed_fast_start_tx_interval\"" >> "$LLDPD_CONF" + echo "configure med fast-start tx-interval $lldpmed_fast_start_tx_interval" >> "$LLDPD_CONF" else echo "configure med fast-start" "enable" >> "$LLDPD_CONF" fi From 50135a03a614182c75a51643c365a06e31fa1e8e Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 21:31:29 +0100 Subject: [PATCH 23/40] lldpd: remove unneeded quotes from commit 3ce909914a12647bec52bcee0a162dd6d158a4f6 Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 82ec853284e44fb85ad702879d18857bd566c7db) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 47354f3c4e0b2..6af15691e7ea1 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -150,7 +150,7 @@ write_lldpd_conf() if [ $lldpmed_fast_start_tx_interval -gt 0 ]; then echo "configure med fast-start tx-interval $lldpmed_fast_start_tx_interval" >> "$LLDPD_CONF" else - echo "configure med fast-start" "enable" >> "$LLDPD_CONF" + echo "configure med fast-start enable" >> "$LLDPD_CONF" fi fi [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" From 89759ee4bb9f48d744cd1a176d9b6e56f91b9047 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 21:29:37 +0100 Subject: [PATCH 24/40] lldpd: remove unneeded quotes and variable quoting from commit 3ce909914a12647bec52bcee0a162dd6d158a4f6 'capabilities enabled x' where x is a string of CSV Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit b039641071b1e9ee9654513ef3229bb97cc379af) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 6af15691e7ea1..3fc47bb3e37fe 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -145,7 +145,7 @@ write_lldpd_conf() [ -n "$lldp_description" ] && echo "configure system description" "\"$lldp_description\"" >> "$LLDPD_CONF" [ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF" [ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF" - [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled" "\"$lldp_syscapabilities\"" >> "$LLDPD_CONF" + [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled $lldp_syscapabilities" >> "$LLDPD_CONF" if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_fast_start -gt 0 ]; then if [ $lldpmed_fast_start_tx_interval -gt 0 ]; then echo "configure med fast-start tx-interval $lldpmed_fast_start_tx_interval" >> "$LLDPD_CONF" From 64b38f3bd564eda2a473fbb06cf0fa56f54ec10e Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 21:42:11 +0100 Subject: [PATCH 25/40] lldpd: remove unneeded quotes and variable quoting from commit c98ee4dbb3db0f064d990941cdd82e872da76946 agent-type takes 1 of 3 possible keywords which do not require quoting: configure lldp agent-type nearest-bridge | nearest-non-tpmr-bridge | nearest-customer-bridge Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 24a4da527f7e70d9916439a78298de2f4e4af653) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 3fc47bb3e37fe..243a32c9378fc 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -153,7 +153,7 @@ write_lldpd_conf() echo "configure med fast-start enable" >> "$LLDPD_CONF" fi fi - [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" + [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type $lldp_agenttype" >> "$LLDPD_CONF" [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" [ $lldp_tx_interval -gt 0 ] && echo "configure lldp tx-interval" "$lldp_tx_interval" >> "$LLDPD_CONF" From 8766fed5cdc016e9fff402990f57c31384e2336c Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 21:44:56 +0100 Subject: [PATCH 26/40] lldpd: remove unneeded quotes and variable quoting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from commit ac771313ebedd2c4bfda8adef47650d45d77c32d portidsubtype takes 1 of 2 possible keywords which do not need quoting: configure lldp portidsubtype ifname | macaddress The third keyword 'local' is used in the syntax when individual ports are being defined: configure [ports ethX [,…]] lldp portidsubtype local value When this syntax is used, quoting is useful (see test cases for lldpd). In the init file, the 'local' syntax is unused. Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit bd1b17d589bc622408cebdd9fa0f43386cc3ef5a) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 243a32c9378fc..5d06e13aa51ee 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -154,7 +154,7 @@ write_lldpd_conf() fi fi [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type $lldp_agenttype" >> "$LLDPD_CONF" - [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" + [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype $lldp_portidsubtype" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" [ $lldp_tx_interval -gt 0 ] && echo "configure lldp tx-interval" "$lldp_tx_interval" >> "$LLDPD_CONF" [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold" "$lldp_tx_hold" >> "$LLDPD_CONF" From 74581b02b292816331de445948eae3a54fc586b7 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 21:54:35 +0100 Subject: [PATCH 27/40] lldpd: remove unneeded quotes from commit a5f715da713304972467612d6934130ce3aa2837 Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 4dcece46a7b4ede7d05d8fb9d31d62406bca74d0) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 5d06e13aa51ee..4841027432150 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -156,8 +156,8 @@ write_lldpd_conf() [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type $lldp_agenttype" >> "$LLDPD_CONF" [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype $lldp_portidsubtype" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" - [ $lldp_tx_interval -gt 0 ] && echo "configure lldp tx-interval" "$lldp_tx_interval" >> "$LLDPD_CONF" - [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold" "$lldp_tx_hold" >> "$LLDPD_CONF" + [ $lldp_tx_interval -gt 0 ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" + [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR From b88694869247cb1eaa9aca11a3d4e0f5f4f5ee6b Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 22:05:11 +0100 Subject: [PATCH 28/40] lldpd: refactor out ifaces derivation; reuse function from commit 909f0630663d7ae1471c76154516e3299992a150 Now pass two params to get_config_cid_ifaces() for: cid_interface interface Each of which is a CSV of interfaces. Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 228d4e7f1b759c11897043dc73ef3c576bc13f7f) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- .../network/services/lldpd/files/lldpd.init | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 4841027432150..e13128e2d6bfc 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -76,7 +76,7 @@ get_config_restart_hash() { get_config_cid_ifaces() { local _ifaces - config_get _ifaces 'config' 'cid_interface' + config_get _ifaces 'config' "$2" local _iface _ifnames="" for _iface in $_ifaces; do @@ -99,16 +99,8 @@ write_lldpd_conf() local lldp_hostname config_get lldp_hostname 'config' 'lldp_hostname' "$(cat /proc/sys/kernel/hostname)" - local ifaces - config_get ifaces 'config' 'interface' - - local iface ifnames="" - for iface in $ifaces; do - local ifname="" - if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then - append ifnames "${ifname:-$iface}" "," - fi - done + local ifnames + get_config_cid_ifaces ifnames "interface" local lldp_mgmt_ip config_get lldp_mgmt_ip 'config' 'lldp_mgmt_ip' @@ -141,7 +133,7 @@ write_lldpd_conf() # Clear out the config file first echo -n > "$LLDPD_CONF" - [ -n "$ifnames" ] && echo "configure system interface pattern" "$ifnames" >> "$LLDPD_CONF" + [ -n "$ifnames" ] && echo "configure system interface pattern $ifnames" >> "$LLDPD_CONF" [ -n "$lldp_description" ] && echo "configure system description" "\"$lldp_description\"" >> "$LLDPD_CONF" [ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF" [ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF" @@ -299,7 +291,8 @@ start_service() { # ChassisID interfaces local ifnames - get_config_cid_ifaces ifnames + get_config_cid_ifaces ifnames "cid_interface" + [ -n "$ifnames" ] && procd_append_param command -C "$ifnames" # Overwrite default configuration locations processed by lldpcli at start From 7542e7927b6ca472ae7c2f38e1e8705c17cccb9a Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 23:37:13 +0100 Subject: [PATCH 29/40] lldpd: fix error "sh: XXXms: bad number" from commit 3ce909914a12647bec52bcee0a162dd6d158a4f6 The lldpd man page says that "configure lldp tx-interval" can specify an interval value in milliseconds by appending a "ms" suffix to the figure. Thus mandating string handling, and not integer comparison. Tested on 22.03.5 Signed-off-by: Paul Donald (cherry picked from commit 79ee4cb0397eb9eae34369e33d66b5a1d837a652) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index e13128e2d6bfc..97c572d3471f4 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -148,7 +148,7 @@ write_lldpd_conf() [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type $lldp_agenttype" >> "$LLDPD_CONF" [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype $lldp_portidsubtype" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" - [ $lldp_tx_interval -gt 0 ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" + [ -n $lldp_tx_interval ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR From 56675166e85b80b6896ba420ea394bfcd5a894a9 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 19:15:55 +0100 Subject: [PATCH 30/40] lldpd: Implement location parameter Previously only partially implemented. After commit 5007f488bb5e1b556052ef246bd3822fed8d09d2 lldp_location was never removed Now, add the value of lldp_location to the generated config. The location param has a few syntaxes, so the config acquires the first usage from the man page: 'address country EU' Supplementary fix for PR #14193 (this param was included in the original PR #13018 but the lldp_location fixes were absent from PR #14193). Tested on 22.03.5, 22.03.6 Signed-off-by: Paul Donald (cherry picked from commit 53252eeb3b6177b77e23235436b04818a88eafe0) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- .../network/services/lldpd/files/lldpd.config | 2 +- package/network/services/lldpd/files/lldpd.init | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.config b/package/network/services/lldpd/files/lldpd.config index 5e7c51ba7e593..fa9fe2b4f89ab 100644 --- a/package/network/services/lldpd/files/lldpd.config +++ b/package/network/services/lldpd/files/lldpd.config @@ -7,7 +7,7 @@ config lldpd config option agentxsocket /var/run/agentx.sock option lldp_class 4 - option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4" + option lldp_location "address country EU" # if empty, the distribution description is sent #option lldp_description "OpenWrt System" diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 97c572d3471f4..498c9e615e8fc 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -114,6 +114,10 @@ write_lldpd_conf() local lldpmed_fast_start_tx_interval config_get lldpmed_fast_start_tx_interval 'config' 'lldpmed_fast_start_tx_interval' 0 + + local lldp_location + config_get lldp_location 'config' 'lldp_location' + fi local lldp_agenttype @@ -145,8 +149,15 @@ write_lldpd_conf() echo "configure med fast-start enable" >> "$LLDPD_CONF" fi fi - [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type $lldp_agenttype" >> "$LLDPD_CONF" - [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype $lldp_portidsubtype" >> "$LLDPD_CONF" + if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + # other 'configure med xxx' statements go here + + [ -n "$lldp_location" ] && echo "configure med location" "$lldp_location" >> "$LLDPD_CONF" + + fi + + [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" + [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" [ -n $lldp_tx_interval ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" @@ -170,7 +181,6 @@ start_service() { local enable_edp local force_edp local lldp_class - local lldp_location local lldp_no_version local lldpmed_no_inventory local readonly_mode @@ -199,7 +209,6 @@ start_service() { config_get_bool force_edp 'config' 'force_edp' 0 fi config_get lldp_class 'config' 'lldp_class' - config_get lldp_location 'config' 'lldp_location' config_get_bool lldp_no_version 'config' 'lldp_no_version' 0 if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then config_get_bool lldpmed_no_inventory 'config' 'lldpmed_no_inventory' 0 From 601bbdda6a838713d440951aab9b8d59e9a575c7 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 8 Feb 2024 20:35:31 +0100 Subject: [PATCH 31/40] lldpd: implement lldp_policy parameter For certain lldp_class scenarios (2 & 3) a policy must be set also. Class 4 is default, although it's good to handle the policy eventuality. Here, set a default lldp_policy for all lldp_class scenarios. Any lldp_policy can now be set. Depends on PR #14584 (which introduced an `if` block) Tested on 22.03.5, 22.03.6 Signed-off-by: Paul Donald (cherry picked from commit 497fafb8aea48e764ce0e456f20ab346691e585f) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 2 +- package/network/services/lldpd/files/lldpd.config | 2 ++ package/network/services/lldpd/files/lldpd.init | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 1f8d1e546b0d5..ffe2a8d015254 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lldpd PKG_VERSION:=1.0.17 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/lldpd/lldpd/releases/download/$(PKG_VERSION)/ diff --git a/package/network/services/lldpd/files/lldpd.config b/package/network/services/lldpd/files/lldpd.config index fa9fe2b4f89ab..6df3f73bf727e 100644 --- a/package/network/services/lldpd/files/lldpd.config +++ b/package/network/services/lldpd/files/lldpd.config @@ -7,6 +7,8 @@ config lldpd config option agentxsocket /var/run/agentx.sock option lldp_class 4 + # lldp_policy only needed for lldp_class 2-3 + # option lldp_policy 'application streaming-video unknown' option lldp_location "address country EU" # if empty, the distribution description is sent diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 498c9e615e8fc..0ba438c379f11 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -118,6 +118,12 @@ write_lldpd_conf() local lldp_location config_get lldp_location 'config' 'lldp_location' + local lldp_class + config_get lldp_class 'config' 'lldp_class' + + local lldp_policy + config_get lldp_policy 'config' 'lldp_policy' + fi local lldp_agenttype @@ -154,6 +160,12 @@ write_lldpd_conf() [ -n "$lldp_location" ] && echo "configure med location" "$lldp_location" >> "$LLDPD_CONF" + # Manual states that if Class (-M) is 2 or 3, at least one network policy must be defined + case "$lldp_class" in + 2 | 3 ) [ -n "$lldp_policy" ] && echo "configure med policy $lldp_policy" >> "$LLDPD_CONF" + ;; + esac + fi [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" From d7765c488c399444c3fd64cfd64add3a175dfa77 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Mon, 11 Mar 2024 23:33:47 +0100 Subject: [PATCH 32/40] lldpd: shellcheck fixes No functionality/behaviour changes; code is synonymous Tested on: 22.03.6 Signed-off-by: Paul Donald (cherry picked from commit 5364fe0f01ca11b47c55d78f756d3176748dd0c2) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- .../network/services/lldpd/files/lldpd.init | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 0ba438c379f11..67ee011ae2354 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -1,5 +1,6 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2008-2015 OpenWrt.org +# shellcheck disable=1091,2034,3037,3043,3045 START=90 STOP=01 @@ -39,38 +40,38 @@ get_config_restart_hash() { config_load 'lldpd' config_get v 'config' 'lldp_class'; append _string "$v" "," - if [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_SNMP" = "y" ]; then config_get v 'config' 'agentxsocket'; append _string "$v" "," fi config_get v 'config' 'cid_interface'; append _string "$v" "," config_get v 'config' 'filter'; append _string "$v" "," config_get_bool v 'config' 'readonly_mode'; append _string "$v" "," config_get_bool v 'config' 'lldp_no_version'; append _string "$v" "," - if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then config_get_bool v 'config' 'lldpmed_no_inventory'; append _string "$v" "," fi config_get_bool v 'config' 'enable_lldp' 1; append _string "$v" "," config_get_bool v 'config' 'force_lldp'; append _string "$v" "," - if [ "$CONFIG_LLDPD_WITH_CDP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_CDP" = "y" ]; then config_get_bool v 'config' 'enable_cdp'; append _string "$v" "," config_get v 'config' 'cdp_version'; append _string "$v" "," config_get_bool v 'config' 'force_cdp'; append _string "$v" "," config_get_bool v 'config' 'force_cdpv2'; append _string "$v" "," fi - if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_EDP" = "y" ]; then config_get_bool v 'config' 'enable_edp'; append _string "$v" "," config_get_bool v 'config' 'force_edp'; append _string "$v" "," fi - if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_FDP" = "y" ]; then config_get_bool v 'config' 'enable_fdp'; append _string "$v" "," config_get_bool v 'config' 'force_fdp'; append _string "$v" "," fi - if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_SONMP" = "y" ]; then config_get_bool v 'config' 'enable_sonmp'; append _string "$v" "," config_get_bool v 'config' 'force_sonmp'; append _string "$v" "," fi - _hash=`echo -n "${_string}" | md5sum | awk '{ print \$1 }'` + _hash=$(echo -n "${_string}" | md5sum | awk '{ print $1 }') export -n "$var=$_hash" } @@ -108,7 +109,7 @@ write_lldpd_conf() local lldp_syscapabilities config_get lldp_syscapabilities 'config' 'lldp_syscapabilities' - if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then local lldpmed_fast_start config_get_bool lldpmed_fast_start 'config' 'lldpmed_fast_start' 0 @@ -148,14 +149,14 @@ write_lldpd_conf() [ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF" [ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF" [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled $lldp_syscapabilities" >> "$LLDPD_CONF" - if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_fast_start -gt 0 ]; then - if [ $lldpmed_fast_start_tx_interval -gt 0 ]; then + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ] && [ "$lldpmed_fast_start" -gt 0 ]; then + if [ "$lldpmed_fast_start_tx_interval" -gt 0 ]; then echo "configure med fast-start tx-interval $lldpmed_fast_start_tx_interval" >> "$LLDPD_CONF" else echo "configure med fast-start enable" >> "$LLDPD_CONF" fi fi - if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then # other 'configure med xxx' statements go here [ -n "$lldp_location" ] && echo "configure med location" "$lldp_location" >> "$LLDPD_CONF" @@ -171,11 +172,11 @@ write_lldpd_conf() [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF" [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF" [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" - [ -n $lldp_tx_interval ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" - [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" + [ -n "$lldp_tx_interval" ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" + [ "$lldp_tx_hold" -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR - [ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR + [ -e "$LLDPD_CONFS_DIR" ] || ln -s /etc/lldpd.d "$LLDPD_CONFS_DIR" } start_service() { @@ -202,31 +203,31 @@ start_service() { config_load 'lldpd' config_get_bool enable_lldp 'config' 'enable_lldp' 1 config_get_bool force_lldp 'config' 'force_lldp' 0 - if [ "$CONFIG_LLDPD_WITH_CDP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_CDP" = "y" ]; then config_get_bool enable_cdp 'config' 'enable_cdp' 0 config_get cdp_version 'config' 'cdp_version' 'cdpv1v2' config_get_bool force_cdp 'config' 'force_cdp' 0 config_get_bool force_cdpv2 'config' 'force_cdpv2' 0 fi - if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_FDP" = "y" ]; then config_get_bool enable_fdp 'config' 'enable_fdp' 0 config_get_bool force_fdp 'config' 'force_fdp' 0 fi - if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_SONMP" = "y" ]; then config_get_bool enable_sonmp 'config' 'enable_sonmp' 0 config_get_bool force_sonmp 'config' 'force_sonmp' 0 fi - if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_EDP" = "y" ]; then config_get_bool enable_edp 'config' 'enable_edp' 0 config_get_bool force_edp 'config' 'force_edp' 0 fi config_get lldp_class 'config' 'lldp_class' config_get_bool lldp_no_version 'config' 'lldp_no_version' 0 - if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then config_get_bool lldpmed_no_inventory 'config' 'lldpmed_no_inventory' 0 fi config_get_bool readonly_mode 'config' 'readonly_mode' 0 - if [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ]; then + if [ "$CONFIG_LLDPD_WITH_SNMP" = "y" ]; then config_get agentxsocket 'config' 'agentxsocket' fi config_get filter 'config' 'filter' 15 @@ -241,8 +242,8 @@ start_service() { procd_set_param command ${LLDPDBIN} procd_append_param command -d - if [ $enable_lldp -gt 0 ]; then - if [ $force_lldp -gt 0 ]; then + if [ "$enable_lldp" -gt 0 ]; then + if [ "$force_lldp" -gt 0 ]; then procd_append_param command '-l' fi else @@ -250,20 +251,20 @@ start_service() { procd_append_param command '-ll' fi - if [ "$CONFIG_LLDPD_WITH_CDP" == "y" ] && [ $enable_cdp -gt 0 ]; then - if [ $cdp_version == "cdpv2" ]; then - if [ $force_cdp -gt 0 ]; then + if [ "$CONFIG_LLDPD_WITH_CDP" = "y" ] && [ "$enable_cdp" -gt 0 ]; then + if [ "$cdp_version" = "cdpv2" ]; then + if [ "$force_cdp" -gt 0 ]; then # CDPv1 disabled, CDPv2 forced procd_append_param command '-ccccc' else # CDPv1 disabled, CDPv2 enabled procd_append_param command '-cccc' fi - elif [ $cdp_version == "cdpv1v2" ]; then - if [ $force_cdp -gt 0 ] && [ $force_cdpv2 -gt 0 ]; then + elif [ "$cdp_version" = "cdpv1v2" ]; then + if [ "$force_cdp" -gt 0 ] && [ "$force_cdpv2" -gt 0 ]; then # CDPv1 enabled, CDPv2 forced procd_append_param command '-ccc' - elif [ $force_cdp -gt 0 ]; then + elif [ "$force_cdp" -gt 0 ]; then # CDPv1 forced, CDPv2 enabled procd_append_param command '-cc' else @@ -273,8 +274,8 @@ start_service() { fi fi - if [ "$CONFIG_LLDPD_WITH_FDP" == "y" ] && [ $enable_fdp -gt 0 ]; then - if [ $force_fdp -gt 0 ]; then + if [ "$CONFIG_LLDPD_WITH_FDP" = "y" ] && [ "$enable_fdp" -gt 0 ]; then + if [ "$force_fdp" -gt 0 ]; then # FDP enabled and forced procd_append_param command '-ff' else @@ -283,8 +284,8 @@ start_service() { fi fi - if [ "$CONFIG_LLDPD_WITH_SONMP" == "y" ] && [ $enable_sonmp -gt 0 ]; then - if [ $force_sonmp -gt 0 ]; then + if [ "$CONFIG_LLDPD_WITH_SONMP" = "y" ] && [ "$enable_sonmp" -gt 0 ]; then + if [ "$force_sonmp" -gt 0 ]; then # SONMP enabled and forced procd_append_param command '-ss' else @@ -293,8 +294,8 @@ start_service() { fi fi - if [ "$CONFIG_LLDPD_WITH_EDP" == "y" ] && [ $enable_edp -gt 0 ]; then - if [ $force_edp -gt 0 ]; then + if [ "$CONFIG_LLDPD_WITH_EDP" = "y" ] && [ "$enable_edp" -gt 0 ]; then + if [ "$force_edp" -gt 0 ]; then # EDP enabled and forced procd_append_param command '-ee' else @@ -303,11 +304,11 @@ start_service() { fi fi - [ $readonly_mode -gt 0 ] && procd_append_param command '-r' - [ $lldp_no_version -gt 0 ] && procd_append_param command '-k' - [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ] && [ $lldpmed_no_inventory -gt 0 ] && procd_append_param command '-i' + [ "$readonly_mode" -gt 0 ] && procd_append_param command '-r' + [ "$lldp_no_version" -gt 0 ] && procd_append_param command '-k' + [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ] && [ "$lldpmed_no_inventory" -gt 0 ] && procd_append_param command '-i' [ -n "$lldp_class" ] && procd_append_param command -M "$lldp_class" - [ "$CONFIG_LLDPD_WITH_SNMP" == "y" ] && [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" + [ "$CONFIG_LLDPD_WITH_SNMP" = "y" ] && [ -n "$agentxsocket" ] && procd_append_param command -x -X "$agentxsocket" [ -n "$filter" ] && procd_append_param command -H "$filter" # ChassisID interfaces @@ -321,7 +322,7 @@ start_service() { local restart_hash get_config_restart_hash restart_hash - echo -n "$restart_hash" > $LLDPD_RESTART_HASH + echo -n "$restart_hash" > "$LLDPD_RESTART_HASH" # set auto respawn behavior procd_set_param respawn @@ -339,7 +340,7 @@ reload_service() { local config_hash="" get_config_restart_hash config_hash - if [ -f ${LLDPD_RESTART_HASH} ]; then running_hash=`cat $LLDPD_RESTART_HASH`; fi + [ -f ${LLDPD_RESTART_HASH} ] && running_hash=$(cat "$LLDPD_RESTART_HASH") if [ "x$running_hash" != "x$config_hash" ]; then # Restart LLDPd @@ -348,7 +349,7 @@ reload_service() { return 0 fi - $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF + $LLDPCLI -u "$LLDPSOCKET" 2>&1 /dev/null <<-EOF pause unconfigure lldp custom-tlv unconfigure system interface pattern @@ -357,8 +358,8 @@ reload_service() { unconfigure system ip management pattern unconfigure system platform EOF - if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then - $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then + $LLDPCLI -u "$LLDPSOCKET" 2>&1 /dev/null <<-EOF unconfigure med fast-start EOF @@ -366,9 +367,9 @@ reload_service() { # Rewrite lldpd.conf # If something changed it should be included by the lldpcli call write_lldpd_conf - $LLDPCLI -u $LLDPSOCKET -c $LLDPD_CONF -c $LLDPD_CONFS_DIR &> /dev/null + $LLDPCLI -u "$LLDPSOCKET" -c "$LLDPD_CONF" -c "$LLDPD_CONFS_DIR" 2>&1 /dev/null # Broadcast update over the wire - $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF + $LLDPCLI -u "$LLDPSOCKET" 2>&1 /dev/null <<-EOF resume update EOF @@ -376,6 +377,6 @@ reload_service() { } stop_service() { - rm -rf ${LLDPD_RUN} $LLDPSOCKET 2>/dev/null + rm -rf ${LLDPD_RUN} "$LLDPSOCKET" 2> /dev/null } From 3d3dad61b2e06c07324088a6ef4e30c0f706f5e8 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Tue, 12 Mar 2024 00:31:15 +0100 Subject: [PATCH 33/40] lldpd: update URL update Makefile URL Signed-off-by: Paul Donald (cherry picked from commit f753d3152f81bd037e9b7abb1b8c5bf9fe54596b) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index ffe2a8d015254..18cdda33ce725 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -31,7 +31,7 @@ define Package/lldpd CATEGORY:=Network SUBMENU:=Routing and Redirection TITLE:=Link Layer Discovery Protocol daemon - URL:=https://vincentbernat.github.io/lldpd/ + URL:=https://lldpd.github.io/ DEPENDS:=+libcap +libevent2 +USE_GLIBC:libbsd +LLDPD_WITH_JSON:libjson-c +LLDPD_WITH_SNMP:libnetsnmp USERID:=lldp=121:lldp=129 MENU:=1 From ca0c2363c2c158d73e3c4cc8f62270f672601373 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Tue, 2 Apr 2024 13:42:20 +0200 Subject: [PATCH 34/40] lldpd: fix restart Redirection broke in 5364fe0f01ca ("lldpd: shellcheck fixes") redirects to /dev/null shall be handled correctly (i.e. last). This fixes these errors on `/etc/init.d/lldpd reload`: 2024-03-16T20:39:00 [WARN/lldpctl] unknown command from argument 1: `/dev/null` 2024-03-16T20:39:00 [WARN/lldpctl] unknown command from argument 1: `/dev/null` 2024-03-16T20:39:00 [WARN/lldpctl] unknown command from argument 1: `/dev/null` 2024-03-16T20:39:00 [WARN/lldpctl] unknown command from argument 1: `/dev/null` Tested-on: 22.03.6 Fixes: 5364fe0f01ca ("lldpd: shellcheck fixes") Signed-off-by: Paul Donald [ improve commit description, add fixes tag ] Signed-off-by: Christian Marangi (cherry picked from commit 8cf1dce428b11740d8335d167b9c1f297d1752d0) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 67ee011ae2354..ca09a501f6b56 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -349,7 +349,7 @@ reload_service() { return 0 fi - $LLDPCLI -u "$LLDPSOCKET" 2>&1 /dev/null <<-EOF + $LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF pause unconfigure lldp custom-tlv unconfigure system interface pattern @@ -359,7 +359,7 @@ reload_service() { unconfigure system platform EOF if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then - $LLDPCLI -u "$LLDPSOCKET" 2>&1 /dev/null <<-EOF + $LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF unconfigure med fast-start EOF @@ -367,9 +367,9 @@ reload_service() { # Rewrite lldpd.conf # If something changed it should be included by the lldpcli call write_lldpd_conf - $LLDPCLI -u "$LLDPSOCKET" -c "$LLDPD_CONF" -c "$LLDPD_CONFS_DIR" 2>&1 /dev/null + $LLDPCLI -u "$LLDPSOCKET" -c "$LLDPD_CONF" -c "$LLDPD_CONFS_DIR" >/dev/null 2>&1 # Broadcast update over the wire - $LLDPCLI -u "$LLDPSOCKET" 2>&1 /dev/null <<-EOF + $LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF resume update EOF @@ -377,6 +377,6 @@ reload_service() { } stop_service() { - rm -rf ${LLDPD_RUN} "$LLDPSOCKET" 2> /dev/null + rm -rf ${LLDPD_RUN} "$LLDPSOCKET" >/dev/null 2>&1 } From cec02193d54723a3a5eebddb5ac547639ad54096 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Tue, 2 Apr 2024 13:42:35 +0200 Subject: [PATCH 35/40] lldpd: note about capabilities only available from >= 1.0.15 Comments are useful. Apparently this config parameter was committed when openwrt used an older version of lldpd which did not yet support it. Signed-off-by: Paul Donald (cherry picked from commit b4769175029ad23833b21960d1b605f629537ad7) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 1 + 1 file changed, 1 insertion(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index ca09a501f6b56..6707476e553bf 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -106,6 +106,7 @@ write_lldpd_conf() local lldp_mgmt_ip config_get lldp_mgmt_ip 'config' 'lldp_mgmt_ip' + # Configurable capabilities in lldpd >= v1.0.15 local lldp_syscapabilities config_get lldp_syscapabilities 'config' 'lldp_syscapabilities' From af6a852ced9f11d162f678c2496e8f6594c10caf Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Wed, 3 Apr 2024 14:06:29 +0200 Subject: [PATCH 36/40] lldpd: make capabilities advertisement controllable Defaults to off. Only available from >= 1.0.15 These capabilities are sent in TLV. Signed-off-by: Paul Donald (cherry picked from commit 4d8f56bd59f457fd815e2bb4f87df8c7dad2d4fd) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 6707476e553bf..6685aa11af82a 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -110,6 +110,10 @@ write_lldpd_conf() local lldp_syscapabilities config_get lldp_syscapabilities 'config' 'lldp_syscapabilities' + # Configurable capabilities in lldpd >= v1.0.15 + local lldp_capability_advertisements + config_get_bool lldp_capability_advertisements 'config' 'lldp_capability_advertisements' 0 + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then local lldpmed_fast_start config_get_bool lldpmed_fast_start 'config' 'lldpmed_fast_start' 0 @@ -150,6 +154,7 @@ write_lldpd_conf() [ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF" [ -n "$lldp_mgmt_ip" ] && echo "configure system ip management pattern" "\"$lldp_mgmt_ip\"" >> "$LLDPD_CONF" [ -n "$lldp_syscapabilities" ] && echo "configure system capabilities enabled $lldp_syscapabilities" >> "$LLDPD_CONF" + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ] && [ "$lldpmed_fast_start" -gt 0 ]; then if [ "$lldpmed_fast_start_tx_interval" -gt 0 ]; then echo "configure med fast-start tx-interval $lldpmed_fast_start_tx_interval" >> "$LLDPD_CONF" @@ -175,6 +180,7 @@ write_lldpd_conf() [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" [ -n "$lldp_tx_interval" ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" [ "$lldp_tx_hold" -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" + [ "$lldp_capability_advertisements" -gt 0 ] && echo "configure lldp capabilities-advertisements" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e "$LLDPD_CONFS_DIR" ] || ln -s /etc/lldpd.d "$LLDPD_CONFS_DIR" @@ -353,6 +359,7 @@ reload_service() { $LLDPCLI -u "$LLDPSOCKET" >/dev/null 2>&1 <<-EOF pause unconfigure lldp custom-tlv + unconfigure lldp capabilities-advertisements unconfigure system interface pattern unconfigure system description unconfigure system hostname From 7ee813b3ef02d28fa741218918f85c93bb7a8b03 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Tue, 2 Apr 2024 13:43:03 +0200 Subject: [PATCH 37/40] lldpd: make management address advertisement controllable Defaults to off. Available from >= 0.7.15 These are sent in TLV Signed-off-by: Paul Donald (cherry picked from commit 50021d3222667a9a239451de0422f0508aef4419) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/files/lldpd.init | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 6685aa11af82a..31cd7fd389cb3 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -114,6 +114,10 @@ write_lldpd_conf() local lldp_capability_advertisements config_get_bool lldp_capability_advertisements 'config' 'lldp_capability_advertisements' 0 + # Broadcast management address in lldpd >= 0.7.15 + local lldp_mgmt_addr_advertisements + config_get_bool lldp_mgmt_addr_advertisements 'config' 'lldp_mgmt_addr_advertisements' 0 + if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then local lldpmed_fast_start config_get_bool lldpmed_fast_start 'config' 'lldpmed_fast_start' 0 @@ -181,6 +185,7 @@ write_lldpd_conf() [ -n "$lldp_tx_interval" ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" [ "$lldp_tx_hold" -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" [ "$lldp_capability_advertisements" -gt 0 ] && echo "configure lldp capabilities-advertisements" >> "$LLDPD_CONF" + [ "$lldp_mgmt_addr_advertisements" -gt 0 ] && echo "configure lldp management-addresses-advertisements" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e "$LLDPD_CONFS_DIR" ] || ln -s /etc/lldpd.d "$LLDPD_CONFS_DIR" @@ -360,6 +365,7 @@ reload_service() { pause unconfigure lldp custom-tlv unconfigure lldp capabilities-advertisements + unconfigure lldp management-addresses-advertisements unconfigure system interface pattern unconfigure system description unconfigure system hostname From 0b48b832a945e7153b0028e7b08098e7d6a6ee4a Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Fri, 12 Apr 2024 21:27:56 +0200 Subject: [PATCH 38/40] lldpd: extended interface(s) parsing to handle patterns For interface type parameters, the man page documents patterns: ``` *,!eth*,!!eth1 uses all interfaces, except interfaces starting with "eth", but including "eth1". ``` * Renamed `_ifname` to `_l2dev`. * get the l2dev via network_get_physdev (and not l3dev) * Glob pattern `*` is also valid - use noglob for this The net result is that now interface 'names' including globs '*' and '!' inversions are included in the generated lldpd configs. Temporarily `set -o noglob` and then `set +o noglob` to disable & enable globbing respectively, because when we pass `*` as an interface choice, other file and pathnames get sucked in from where the init script runs, and the `*` never makes it to lldpd. Tested extensively on: 22.03.6, 23.05.3 Signed-off-by: Paul Donald [ squash with commit bumping release version ] Signed-off-by: Christian Marangi (cherry picked from commit 4a81d868db85a7954a73bc6dc4a957bbd6abc813) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 2 +- package/network/services/lldpd/files/lldpd.init | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 18cdda33ce725..5a9a9732d2052 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lldpd PKG_VERSION:=1.0.17 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/lldpd/lldpd/releases/download/$(PKG_VERSION)/ diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index 31cd7fd389cb3..dbe79d2f4a176 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -80,12 +80,20 @@ get_config_cid_ifaces() { config_get _ifaces 'config' "$2" local _iface _ifnames="" + # Set noglob to prevent '*' capturing diverse file names in the for ... in + set -o noglob for _iface in $_ifaces; do - local _ifname="" - if network_get_device _ifname "$_iface" || [ -e "/sys/class/net/$_iface" ]; then - append _ifnames "${_ifname:-$_iface}" "," + + local _l2device="" + if network_get_physdev _l2device "$_iface" || [ -e "/sys/class/net/$_iface" ]; then + append _ifnames "${_l2device:-$_iface}" "," + else + # Glob case (interface is e.g. '!eth1' or 'eth*' or '*') + append _ifnames "$_iface" "," fi done + # Turn noglob off i.e. enable glob again + set +o noglob export -n "${1}=$_ifnames" } From e3bb35811e8d92a5c9aaee7549e3ddea32751d8c Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Mon, 22 Apr 2024 15:17:33 +0200 Subject: [PATCH 39/40] lldpd: fix reload bug: advertisements shall default to on Because these capability advertisements default to on in lldpd, they became absent at reload, and not restart, due to how the reload logic works ( keep daemon running, send unconfigured and then the new config via socket ), and it was not evident unless you happened to be looking for it (e.g. via pcap or tcpdump). It was also not evident from the manpage ( have now sent patches upstream ). At reload time, the unconfigure logic disabled them unless they were explicitly enabled (compare with other settings where 'unconfigure' just resets them). Now they default to on/enabled at init time, and are explicitly 'unconfigure'd at startup if the user disables them via: lldp_mgmt_addr_advertisements=0 lldp_capability_advertisements=0 In other words: explicit is necessary to disable the advertisements. The same applies to 'configure system capabilities enabled'. Technically 'unconfigure'd is the default but now it is explicit at reload. Tested on: 23.05.3 Signed-off-by: Paul Donald (cherry picked from commit 708101c1412c42c7fb1d838024513a34424c50ff) Link: https://github.com/openwrt/openwrt/pull/15299 Signed-off-by: Robert Marko --- package/network/services/lldpd/Makefile | 2 +- .../network/services/lldpd/files/lldpd.init | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile index 5a9a9732d2052..f34cd28faac96 100644 --- a/package/network/services/lldpd/Makefile +++ b/package/network/services/lldpd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=lldpd PKG_VERSION:=1.0.17 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://github.com/lldpd/lldpd/releases/download/$(PKG_VERSION)/ diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init index dbe79d2f4a176..3922b676b52e6 100644 --- a/package/network/services/lldpd/files/lldpd.init +++ b/package/network/services/lldpd/files/lldpd.init @@ -114,17 +114,17 @@ write_lldpd_conf() local lldp_mgmt_ip config_get lldp_mgmt_ip 'config' 'lldp_mgmt_ip' - # Configurable capabilities in lldpd >= v1.0.15 + # Configurable capabilities in lldpd >= v1.0.15: defaults to 'unconfigured' i.e. kernel info local lldp_syscapabilities config_get lldp_syscapabilities 'config' 'lldp_syscapabilities' - # Configurable capabilities in lldpd >= v1.0.15 + # Configurable capabilities in lldpd >= v1.0.15: defaults to on in lldpd local lldp_capability_advertisements - config_get_bool lldp_capability_advertisements 'config' 'lldp_capability_advertisements' 0 + config_get_bool lldp_capability_advertisements 'config' 'lldp_capability_advertisements' 1 - # Broadcast management address in lldpd >= 0.7.15 + # Broadcast management address in lldpd >= 0.7.15: defaults to on in lldpd local lldp_mgmt_addr_advertisements - config_get_bool lldp_mgmt_addr_advertisements 'config' 'lldp_mgmt_addr_advertisements' 0 + config_get_bool lldp_mgmt_addr_advertisements 'config' 'lldp_mgmt_addr_advertisements' 1 if [ "$CONFIG_LLDPD_WITH_LLDPMED" = "y" ]; then local lldpmed_fast_start @@ -192,8 +192,10 @@ write_lldpd_conf() [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF" [ -n "$lldp_tx_interval" ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF" [ "$lldp_tx_hold" -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF" - [ "$lldp_capability_advertisements" -gt 0 ] && echo "configure lldp capabilities-advertisements" >> "$LLDPD_CONF" - [ "$lldp_mgmt_addr_advertisements" -gt 0 ] && echo "configure lldp management-addresses-advertisements" >> "$LLDPD_CONF" + [ "$lldp_capability_advertisements" -gt 0 ] && echo "configure lldp capabilities-advertisements" >> "$LLDPD_CONF" ||\ + echo "unconfigure lldp capabilities-advertisements" >> "$LLDPD_CONF" + [ "$lldp_mgmt_addr_advertisements" -gt 0 ] && echo "configure lldp management-addresses-advertisements" >> "$LLDPD_CONF" ||\ + echo "unconfigure lldp management-addresses-advertisements" >> "$LLDPD_CONF" # Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR [ -e "$LLDPD_CONFS_DIR" ] || ln -s /etc/lldpd.d "$LLDPD_CONFS_DIR" @@ -374,6 +376,8 @@ reload_service() { unconfigure lldp custom-tlv unconfigure lldp capabilities-advertisements unconfigure lldp management-addresses-advertisements + # unconfigures user-configured system capabilities, and instead uses the kernel information: + unconfigure system capabilities enabled unconfigure system interface pattern unconfigure system description unconfigure system hostname From 4d7ad378914382759e66dc32f1ffcab58639309a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Sun, 15 Sep 2024 23:35:08 +0200 Subject: [PATCH 40/40] ramips: mt7621: use lzma-loader for Sercomm NA502s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a well-known "LZMA ERROR 1" error on Sercomm NA502s, reported on the OpneWrt forum [0]. [0] https://forum.openwrt.org/t/206640 Signed-off-by: Andreas Böhler (cherry picked from commit 6d89aa29878a93c744e8c752a68bc05d41252cfc) Link: https://github.com/openwrt/openwrt/pull/16412 Signed-off-by: Hauke Mehrtens --- target/linux/ramips/image/mt7621.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 504c56e2b875c..a5dc68c84d66e 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -2068,6 +2068,7 @@ TARGET_DEVICES += sercomm_na502 define Device/sercomm_na502s $(Device/nand) + $(Device/uimage-lzma-loader) IMAGE_SIZE := 20971520 DEVICE_VENDOR := SERCOMM DEVICE_MODEL := NA502S