diff options
author | Florian Eckert <fe@dev.tdt.de> | 2018-05-09 13:48:27 +0200 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2018-05-09 14:20:03 +0200 |
commit | ee54a9542f7685ffa7c41ceaacedc0af9004d1a0 (patch) | |
tree | a39c9e8322105b3faa2b7504cf3c9bb94e2899f1 | |
parent | f50de419592d58160f15a04978b0de6e94b854fb (diff) |
luci-app-mwan3: pin diag ping command to interface device
If the physical device is not set in the diag_command then the ping will
always use the route with the lowest metric from the default routing
table.
To fix this add the physical device of the logical interface to the ping
command.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
-rw-r--r-- | applications/luci-app-mwan3/luasrc/controller/mwan3.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua index 01e40d994..18c2135e4 100644 --- a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua +++ b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua @@ -97,9 +97,9 @@ function diagnosticsData(interface, task) return interfaceNumber end - function diag_command(cmd, addr) + function diag_command(cmd, device, addr) if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then - local util = io.popen(cmd % ut.shellquote(addr)) + local util = io.popen(cmd %{ut.shellquote(device), ut.shellquote(addr)}) if util then while true do local ln = util:read("*l") @@ -145,7 +145,7 @@ function diagnosticsData(interface, task) if task == "ping_gateway" then local gateway = get_gateway(interface) if gateway ~= nil then - diag_command("ping -c 5 -W 1 %s 2>&1", gateway) + diag_command("ping -I %s -c 5 -W 1 %s 2>&1", device, gateway) else luci.http.prepare_content("text/plain") luci.http.write(string.format("No gateway for interface %s found.", interface)) @@ -154,7 +154,7 @@ function diagnosticsData(interface, task) local trackips = uci:get("mwan3", interface, "track_ip") if #trackips > 0 then for i in pairs(trackips) do - diag_command("ping -c 5 -W 1 %s 2>&1", trackips[i]) + diag_command("ping -I %s -c 5 -W 1 %s 2>&1", device, trackips[i]) end else luci.http.write(string.format("No tracking Hosts for interface %s defined.", interface)) |