Merge pull request #2406 from rosysong/nft-qos

luci-app-nft-qos: fix monitor doesn't work when there no ipv6 support.
This commit is contained in:
Hannu Nyman 2018-12-29 11:35:01 +02:00 committed by GitHub
commit 1d3a8739a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,12 @@ function index()
end end
function _action_rate(rv, n) function _action_rate(rv, n)
local has_ipv6 = nixio.fs.access("/proc/net/ipv6_route")
if has_ipv6 then
local c = io.popen("nft list chain inet nft-qos-monitor " .. n .. " 2>/dev/null") local c = io.popen("nft list chain inet nft-qos-monitor " .. n .. " 2>/dev/null")
else
local c = io.popen("nft list chain ip nft-qos-monitor " .. n .. " 2>/dev/null")
end
if c then if c then
for l in c:lines() do for l in c:lines() do
local _, i, p, b = l:match('^%s+ip ([^%s]+) ([^%s]+) counter packets (%d+) bytes (%d+)') local _, i, p, b = l:match('^%s+ip ([^%s]+) ([^%s]+) counter packets (%d+) bytes (%d+)')