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

Sergey Ryazanov ryazanov.s.a at gmail.com
Fri Feb 27 13:35:39 EST 2015


2015-02-27 19:23 GMT+03:00 Alexandru Ardelean <ardeleanalex at 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 at 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'

-- 
Sergey
_______________________________________________
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