| --- a/package/network/services/lldpd/Makefile |
| +++ b/package/network/services/lldpd/Makefile |
| @@ -8,18 +8,20 @@ |
| include $(TOPDIR)/rules.mk |
| |
| PKG_NAME:=lldpd |
| -PKG_VERSION:=1.0.7 |
| -PKG_RELEASE:=1 |
| +PKG_VERSION:=1.0.17 |
| +PKG_RELEASE:=3 |
| |
| PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz |
| -PKG_SOURCE_URL:=https://media.luffy.cx/files/lldpd |
| -PKG_HASH:=1df79179d489c841b49265f2ab5ff05f284a647e95862d2f3c02b3fb079a87e1 |
| +PKG_SOURCE_URL:=https://github.com/lldpd/lldpd/releases/download/$(PKG_VERSION)/ |
| +PKG_HASH:=89ae691a4917ac9e0ec3b8b2c1e634cc402d43b804f98850c73bd1c7df380882 |
| |
| PKG_MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be> |
| PKG_LICENSE:=ISC |
| +PKG_CPE_ID:=cpe:/a:lldpd_project:lldpd |
| |
| PKG_FIXUP:=autoreconf |
| PKG_BUILD_PARALLEL:=1 |
| +PKG_BUILD_FLAGS:=lto |
| PKG_INSTALL:=1 |
| |
| include $(INCLUDE_DIR)/package.mk |
| @@ -29,8 +31,8 @@ define Package/lldpd |
| CATEGORY:=Network |
| SUBMENU:=Routing and Redirection |
| TITLE:=Link Layer Discovery Protocol daemon |
| - URL:=https://vincentbernat.github.io/lldpd/ |
| - DEPENDS:=+libevent2 +USE_GLIBC:libbsd +LLDPD_WITH_JSON:libjson-c +LLDPD_WITH_SNMP:libnetsnmp |
| + 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 |
| endef |
| @@ -66,19 +68,28 @@ 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 |
| + 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 |
| + 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 '/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 |
| + 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 |
| + sed -i -e '/agentxsocket/d' $(1)/etc/config/lldpd |
| endif |
| endef |
| |
| @@ -110,4 +121,6 @@ CONFIGURE_ARGS += \ |
| $(if $(CONFIG_LLDPD_WITH_SNMP),--with-snmp,) \ |
| $(if $(CONFIG_USE_GLIBC),,--without-libbsd) |
| |
| +TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed |
| + |
| $(eval $(call BuildPackage,lldpd)) |
| --- a/package/network/services/lldpd/files/lldpd.config |
| +++ b/package/network/services/lldpd/files/lldpd.config |
| @@ -7,7 +7,9 @@ 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" |
| + # 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 |
| #option lldp_description "OpenWrt System" |
| --- a/package/network/services/lldpd/files/lldpd.init |
| +++ b/package/network/services/lldpd/files/lldpd.init |
| @@ -1,15 +1,29 @@ |
| #!/bin/sh /etc/rc.common |
| # Copyright (C) 2008-2015 OpenWrt.org |
| +# shellcheck disable=1091,2034,3037,3043,3045 |
| |
| 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 |
| +CONFIG_LLDPD_WITH_SONMP=y |
| + |
| 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 +33,65 @@ 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" "," |
| + 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 |
| + 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 |
| + 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 |
| + 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" "," |
| + fi |
| + 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" |
| +} |
| + |
| +get_config_cid_ifaces() { |
| + local _ifaces |
| + config_get _ifaces 'config' "$2" |
| + |
| + 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() |
| { |
| - . /lib/functions/network.sh |
| - |
| local lldp_description |
| |
| config_load 'lldpd' |
| @@ -31,91 +100,276 @@ 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' |
| |
| + 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 |
| + |
| + 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 |
| + config_get lldp_agenttype 'config' 'lldp_agenttype' 'nearest-bridge' |
| + |
| + local lldp_portidsubtype |
| + config_get lldp_portidsubtype 'config' 'lldp_portidsubtype' 'macaddress' |
| + |
| + 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" |
| + [ -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" |
| + 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 |
| + # other 'configure med xxx' statements go here |
| + |
| + [ -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" |
| + [ -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" |
| |
| # 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() { |
| |
| + local enable_lldp |
| + local force_lldp |
| local enable_cdp |
| + local cdp_version |
| + local force_cdp |
| + local force_cdpv2 |
| local enable_fdp |
| + local force_fdp |
| local enable_sonmp |
| + local force_sonmp |
| local enable_edp |
| + local force_edp |
| local lldp_class |
| - local lldp_location |
| + local lldp_no_version |
| + local lldpmed_no_inventory |
| local readonly_mode |
| local agentxsocket |
| + local filter |
| |
| config_load 'lldpd' |
| - 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 |
| - config_get_bool enable_edp 'config' 'enable_edp' 0 |
| + 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 |
| + 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 |
| + 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 |
| + 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 |
| + 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 |
| + 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' |
| + if [ "$CONFIG_LLDPD_WITH_SNMP" = "y" ]; then |
| + config_get agentxsocket 'config' 'agentxsocket' |
| + fi |
| + config_get filter 'config' 'filter' 15 |
| |
| - 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 |
| - procd_append_param command -d # don't daemonize, procd will handle that for us |
| - |
| - [ $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' |
| - [ $enable_edp -gt 0 ] && procd_append_param command '-e' |
| - [ $readonly_mode -gt 0 ] && procd_append_param command '-r' |
| + 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 |
| + |
| + 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 |
| + |
| + 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 |
| + # FDP enabled |
| + procd_append_param command '-f' |
| + fi |
| + fi |
| + |
| + 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 |
| + |
| + 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 |
| + # EDP enabled |
| + procd_append_param command '-e' |
| + 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' |
| [ -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 |
| + local 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 |
| + 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 |
| - $LLDPCLI -u $LLDPSOCKET &> /dev/null <<-EOF |
| + |
| + local running_hash="" |
| + local config_hash="" |
| + |
| + get_config_restart_hash config_hash |
| + [ -f ${LLDPD_RESTART_HASH} ] && running_hash=$(cat "$LLDPD_RESTART_HASH") |
| + |
| + 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" 2>&1 /dev/null <<-EOF |
| pause |
| unconfigure lldp custom-tlv |
| unconfigure system interface pattern |
| 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" 2>&1 /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 |
| - $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 |
| @@ -123,5 +377,6 @@ reload_service() { |
| } |
| |
| stop_service() { |
| - rm -rf /var/run/lldp $LLDPSOCKET |
| + rm -rf ${LLDPD_RUN} "$LLDPSOCKET" 2> /dev/null |
| } |
| + |
| --- a/package/network/services/lldpd/patches/001-disable_libcap.patch |
| +++ /dev/null |
| @@ -1,17 +0,0 @@ |
| ---- a/configure.ac |
| -+++ b/configure.ac |
| -@@ -246,7 +246,13 @@ PKG_CHECK_MODULES([check], [check >= 0.9 |
| - |
| - # Third-party libraries |
| - lldp_CHECK_LIBEVENT |
| --lldp_CHECK_LIBCAP |
| -+ |
| -+#libcap is not a core package so disable this capability |
| -+#lldp_CHECK_LIBCAP |
| -+libcap_LIBS= |
| -+libcap_CFLAGS= |
| -+AC_SUBST([libcap_LIBS]) |
| -+AC_SUBST([libcap_CFLAGS]) |
| - |
| - # Compatibility with pkg.m4 < 0.27 |
| - m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], |
| --- a/package/network/services/lldpd/patches/002-fix-AX_LIB_READLINE-macro-conflict.patch |
| +++ /dev/null |
| @@ -1,61 +0,0 @@ |
| -From 23509dc05b24a28fb46022800e0e271ae0118de2 Mon Sep 17 00:00:00 2001 |
| -From: Jo-Philipp Wich <jo@mein.io> |
| -Date: Wed, 9 Dec 2020 12:04:04 +0100 |
| -Subject: [PATCH] build: prevent conflict with official AX_LIB_READLINE macro |
| - |
| -On systems where the official AX_LIB_READLINE (ax_lib_readline.m4) is |
| -present in a globally shared autoconf include directory, auto(re)conf |
| -will prefer including that offical version over the local variant due |
| -to the offical macro having a higher serial number. |
| - |
| -As a consequence, @READLINE_LIBS@ will not be substituted in *.in files, |
| -eventually failing the compilation with errors similar to: |
| - |
| - gcc: error: READLINE_LIBS@: No such file or directory |
| - |
| -Avoid this problem by renaming the incompatible local macro to |
| -AX_LIB_READLINE_LLDPD which is sufficient to prevent any clashes. |
| - |
| -We encountered this problem on OpenWrt which uses GNU autoconf-archive |
| -to provide commonly used M4 macros through a global include directory, |
| -which happens to ship AX_LIB_READLINE as well. |
| - |
| -Signed-off-by: Jo-Philipp Wich <jo@mein.io> |
| ---- |
| - configure.ac | 2 +- |
| - m4/ax_lib_readline.m4 | 6 +++--- |
| - 2 files changed, 4 insertions(+), 4 deletions(-) |
| - |
| ---- a/configure.ac |
| -+++ b/configure.ac |
| -@@ -273,7 +273,7 @@ AC_ARG_WITH([readline], |
| - [], |
| - [with_readline=auto]) |
| - if test x"$with_readline" != x"no"; then |
| -- AX_LIB_READLINE |
| -+ AX_LIB_READLINE_LLDPD |
| - if test x"$with_readline" != x"check" -a x"$with_readline" != x"auto"; then |
| - if test x"$ax_cv_lib_readline" = x"no"; then |
| - AC_MSG_FAILURE([*** no readline support found]) |
| ---- a/m4/ax_lib_readline.m4 |
| -+++ b/m4/ax_lib_readline.m4 |
| -@@ -4,7 +4,7 @@ |
| - # |
| - # SYNOPSIS |
| - # |
| --# AX_LIB_READLINE |
| -+# AX_LIB_READLINE_LLDPD |
| - # |
| - # DESCRIPTION |
| - # |
| -@@ -66,8 +66,8 @@ |
| - |
| - #serial 6 |
| - |
| --AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE]) |
| --AC_DEFUN([AX_LIB_READLINE], [ |
| -+AU_ALIAS([VL_LIB_READLINE], [AX_LIB_READLINE_LLDPD]) |
| -+AC_DEFUN([AX_LIB_READLINE_LLDPD], [ |
| - AC_CACHE_CHECK([for a readline compatible library], |
| - ax_cv_lib_readline, [ |
| - _save_LIBS="$LIBS" |
| -- |
| 2.18.0 |
| |