diff mbox

[OpenWrt-Devel] lldpd: fix init script for multiple interfaces

Message ID 1425054196-18340-1-git-send-email-ardeleanalex@gmail.com
State Rejected
Headers show

Commit Message

Alexandru Ardelean Feb. 27, 2015, 4:23 p.m. UTC
The lldpd daemon requires only 1 -I parameter with all interfaces
joined with commas.

So, it needs:
  /usr/sbin/lldpd -I lan1,lan2,...,lanX
versus
  /usr/sbin/lldpd -I lan1 -I lan2 ... -I lanX

The latter seems to take into consideration only lanX,
while other devices are ignored by lldpd.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
---
 package/network/services/lldpd/files/lldpd.init | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Sergey Ryazanov Feb. 27, 2015, 6:35 p.m. UTC | #1
2015-02-27 19:23 GMT+03:00 Alexandru Ardelean <ardeleanalex@gmail.com>:
> The lldpd daemon requires only 1 -I parameter with all interfaces
> joined with commas.
>
> So, it needs:
>   /usr/sbin/lldpd -I lan1,lan2,...,lanX
> versus
>   /usr/sbin/lldpd -I lan1 -I lan2 ... -I lanX
>
> The latter seems to take into consideration only lanX,
> while other devices are ignored by lldpd.
>
> Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>

Yep, lldpd needs exactly one -I option. Thanks for the fix of script.

Please find the one small question below.

> ---
>  package/network/services/lldpd/files/lldpd.init | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
> index b2eea70..d29980e 100644
> --- a/package/network/services/lldpd/files/lldpd.init
> +++ b/package/network/services/lldpd/files/lldpd.init
> @@ -37,13 +37,18 @@ start() {
>         local ifaces
>         config_get ifaces 'config' 'interface'
>
> +       local ifnames_joined=""
>         local iface
>         for iface in $ifaces; do
>                 local ifname=""
>                 if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
> -                       append args "-I ${ifname:-$iface}"
> +                       append ifnames_joined "${ifname:-$iface}"
>                 fi
>         done
> +       if [ -n "$ifnames_joined" ]; then
> +               ifnames_joined=`echo $ifnames_joined | tr " " ","`
> +               append args "-I $ifnames_joined"

Maybe you could merge this two lines and did not use temporary variable?

> +       fi
>
>         [ $enable_cdp -gt 0 ] && append args '-c'
>         [ $enable_fdp -gt 0 ] && append args '-f'
diff mbox

Patch

diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
index b2eea70..d29980e 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -37,13 +37,18 @@  start() {
 	local ifaces
 	config_get ifaces 'config' 'interface'
 
+	local ifnames_joined=""
 	local iface
 	for iface in $ifaces; do
 		local ifname=""
 		if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
-			append args "-I ${ifname:-$iface}"
+			append ifnames_joined "${ifname:-$iface}"
 		fi
 	done
+	if [ -n "$ifnames_joined" ]; then
+		ifnames_joined=`echo $ifnames_joined | tr " " ","`
+		append args "-I $ifnames_joined"
+	fi
 
 	[ $enable_cdp -gt 0 ] && append args '-c'
 	[ $enable_fdp -gt 0 ] && append args '-f'