[OpenWrt-Devel] [PATCH 2/2] lldpd: add /lib/lldpd.unconf file for reload

Alexandru Ardelean ardeleanalex at gmail.com
Tue Jan 5 08:07:09 EST 2016


Looks like we need to call 'unconfigure' options lldpd has to offer
to do a proper (more complete) reload.

And while we're doing reload, we need to pause lldpd's execution
to prevent it sending unconfigured data/TLVs to the other side
( which could confuse the other side ).

Signed-off-by: Alexandru Ardelean <ardeleanalex at gmail.com>
---
 package/network/services/lldpd/Makefile           |  9 ++++++++-
 package/network/services/lldpd/files/lldpd.init   | 12 +++++++-----
 package/network/services/lldpd/files/lldpd.unconf |  9 +++++++++
 3 files changed, 24 insertions(+), 6 deletions(-)
 create mode 100644 package/network/services/lldpd/files/lldpd.unconf

diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile
index 5f413cf..4445867 100644
--- a/package/network/services/lldpd/Makefile
+++ b/package/network/services/lldpd/Makefile
@@ -61,11 +61,12 @@ define Package/lldpd/install
 	$(INSTALL_DIR) $(1)/etc/init.d
 	$(INSTALL_DIR) $(1)/etc/lldpd.d
 	$(INSTALL_DIR) $(1)/etc/config
-	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/sbin
+	$(INSTALL_DIR) $(1)/lib $(1)/usr/lib $(1)/usr/sbin
 	$(CP) $(PKG_INSTALL_DIR)/usr/sbin/lldp{cli,ctl,d} $(1)/usr/sbin/
 	$(CP) $(PKG_INSTALL_DIR)/usr/lib/liblldpctl.so* $(1)/usr/lib/
 	$(INSTALL_BIN) ./files/lldpd.init $(1)/etc/init.d/lldpd
 	$(INSTALL_DATA) ./files/lldpd.config $(1)/etc/config/lldpd
+	$(INSTALL_CONF) ./files/lldpd.unconf $(1)/lib
 ifneq ($(CONFIG_LLDPD_WITH_CDP),y)
 	sed -i -e '/cdp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
 endif
@@ -78,6 +79,12 @@ endif
 ifneq ($(CONFIG_LLDPD_WITH_SONMP),y)
 	sed -i -e '/sonmp/d' $(1)/etc/init.d/lldpd $(1)/etc/config/lldpd
 endif
+ifneq ($(CONFIG_LLDPD_WITH_LLDPMED),y)
+	sed -i -e '/med/d' $(1)/lib/lldpd.unconf
+endif
+ifneq ($(CONFIG_LLDPD_WITH_CUSTOM),y)
+	sed -i -e '/custom-tlv/d' $(1)/lib/lldpd.unconf
+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 064bac1..1cf3ce7 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -98,13 +98,15 @@ service_running() {
 
 reload_service() {
 	running || return 1
-	# Custom TLVs are special and should be
-	# reloaded from config during lldpd reload
-	$LLDPCLI -u $LLDPSOCKET unconfigure lldp custom-tlv &> /dev/null
+	# Pause lldpd execution so that it won't send out info during reconfig
+	$LLDPCLI -u $LLDPSOCKET pause &> /dev/null
+	$LLDPCLI -u $LLDPSOCKET -c /lib/lldpd.unconf &> /dev/null
 	write_lldpd_conf
 	$LLDPCLI -u $LLDPSOCKET -c $LLDPD_CONF -c $LLDPD_CONFS_DIR &> /dev/null
-	# Broadcast update over the wire
-	$LLDPCLI -u $LLDPSOCKET update &> /dev/null
+	$LLDPCLI -u $LLDPSOCKET &> /dev/null << EOF
+		resume
+		update
+EOF
 	return 0
 }
 
diff --git a/package/network/services/lldpd/files/lldpd.unconf b/package/network/services/lldpd/files/lldpd.unconf
new file mode 100644
index 0000000..b7bdafc
--- /dev/null
+++ b/package/network/services/lldpd/files/lldpd.unconf
@@ -0,0 +1,9 @@
+unconfigure system hostname
+unconfigure system description
+unconfigure system platform
+unconfigure system interface pattern
+unconfigure system interface description
+unconfigure system interface promiscuous
+unconfigure system ip management pattern
+unconfigure lldp custom-tlv
+unconfigure med fast-start
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list