summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2022-04-29 12:16:19 +0200
committerJo-Philipp Wich <jo@mein.io>2022-04-29 12:18:46 +0200
commita993714790cfe22bfae3ccd2f8b036b1434fe244 (patch)
treea5c7807f794f19a626138e4a1dc3f45916517a02
parent0473e99fab038b84b4b66dba15d5c63b08d625c1 (diff)
luci-base: sys.lua: fix parsing conntrack entries without timeout
Flow offloaded conntrack entries carry no timeout value and trip up the record parsing routine. Adjust the code to properly deal with such entries. Ref: https://forum.openwrt.org/t/offloading-breaks-connections-list/126423 Signed-off-by: Jo-Philipp Wich <jo@mein.io> (cherry picked from commit 531c0ecff2ca57c4bc0aacee66a0746814fefc78)
-rw-r--r--modules/luci-base/luasrc/sys.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/luci-base/luasrc/sys.lua b/modules/luci-base/luasrc/sys.lua
index af345a16d5..71db04acf8 100644
--- a/modules/luci-base/luasrc/sys.lua
+++ b/modules/luci-base/luasrc/sys.lua
@@ -286,8 +286,14 @@ function net.conntrack(callback)
local line, connt = nil, (not callback) and { }
for line in nfct do
- local fam, l3, l4, timeout, tuples =
- line:match("^(ipv[46]) +(%d+) +%S+ +(%d+) +(%d+) +(.+)$")
+ local fam, l3, l4, rest =
+ line:match("^(ipv[46]) +(%d+) +%S+ +(%d+) +(.+)$")
+
+ local timeout, tuples = rest:match("^(%d+) +(.+)$")
+
+ if not tuples then
+ tuples = rest
+ end
if fam and l3 and l4 and timeout and not tuples:match("^TIME_WAIT ") then
l4 = nixio.getprotobynumber(l4)