openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
4.01k stars 3.49k forks source link

mwan3: 2.8.3-2 /usr/sbin/mwan3track: line 139: : not found #11965

Closed jamesmacwhite closed 4 years ago

jamesmacwhite commented 4 years ago

Maintainer: @feckert Environment: OpenWrt 19.07.2

Description:

I upgraded to the latest master version due to issues with ping and IPv6 interfaces, however I think this commit 6721587e8b491f1a539cdcc507b0f4811ff2b448 is causing /usr/sbin/mwan3track: line 139: : not found errors to be spammed in terminal every few seconds (the check interval) when mwan3 is enabled. It doesn't happen on 2.8.1.

jamesmacwhite commented 4 years ago

@brianjmurrell Just also pinging you, as it seems to be related to the recent IPv6 ping changes. Although, I understand the reason for the changes because ping with IPv6 interfaces isn't working well currently.

I can post my network interfaces/config if it helps.

feckert commented 4 years ago

Maybe we have a problem with the tools (busybox vs. linux-tools)? @jamesmacwhite what version of ip and sed habe you installed on your system? I am using the following versions in the master branch

jamesmacwhite commented 4 years ago

Thanks.

My sed version is from BusyBox v1.30.1 and I do also have ip-full installed (5.0.0-2.1)

I think the tool versions are OK, I've ran command the ADDR variable is doing and it works fine through SSH and reporting the correct data, it's when mwan3track is being called I get the not found error.

feckert commented 4 years ago

Thanks, I think the PATH variable is not correct when calling the script?

jamesmacwhite commented 4 years ago

It's not potentially a sh vs bash thing is it? Is use of :- safe with sh?

brianjmurrell commented 4 years ago
# /bin/bash
# unset b
# a=${b:-notset}
# echo $a
notset
# exit
exit
# /bin/sh

BusyBox v1.30.1 () built-in shell (ash)

# unset b
# a=${b:-notset}
# echo $a
notset

Seems to work fine with /bin/sh

brianjmurrell commented 4 years ago

@jamesmacwhite what does /bin/sh -c 'unset b; a=${b:-notset}; echo $a' report on your system?

jamesmacwhite commented 4 years ago

No worries, just a thought, I'm struggling to understand why not found gets thrown, when the command works fine outside of mwan3track.

I get notset reported when running the above.

brianjmurrell commented 4 years ago

If you put:

set -x
exec 2>/tmp/mw3track.debug

after line 4 of /usr/sbin/mwan3track that will log the xtrace to /tmp/mw3track.debug so that you can see exactly what's causing that to be printed.

jamesmacwhite commented 4 years ago

@brianjmurrell Thanks!

This is what's being reported.

+ echo 2001:4860:4860::8888
+ grep -q :
+ ip -6 addr ls dev 6in4-wan6
+ sed -ne 's/ *inet6 \([^ \/]*\).* scope global.*/\1/p'
+ ' ' 'ADDR=2001:470:xxxx:xx::2'
/usr/sbin/mwan3track: line 142:  : not found
jamesmacwhite commented 4 years ago

I think I've found the issue. It's weird though. There is a weird character on the line that's being referenced on the /usr/bin/mwan3track script.

image

I've confirmed it's not something I've caused locally, as I extracted the contents from the ipk from recent snapshot. Something to do with encoding?

jamesmacwhite commented 4 years ago

It's present in the source code too. I didn't notice it before, but that's the reason why it's blowing up!

https://github.com/openwrt/packages/blob/6721587e8b491f1a539cdcc507b0f4811ff2b448/net/mwan3/files/usr/sbin/mwan3track#L139

jamesmacwhite commented 4 years ago

@feckert Thank you!

feckert commented 4 years ago

@jamesmacwhite Thanks for the report