diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2011-02-12 19:32:36 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2011-02-12 19:32:36 +0000 |
commit | 68b51e15273380e9e3531762124e535f472d90d5 (patch) | |
tree | 57958228f393bda124b69e58733a9a16b8a424d7 /libs/sys | |
parent | f04acc4b948a45bcfbd22f219df001f96064edf7 (diff) |
libs/sys: fix parsing of model and cpu info, consider 2000::/3 as IPv6 default route if no ::/0 route exists (#200)
Diffstat (limited to 'libs/sys')
-rw-r--r-- | libs/sys/luasrc/sys.lua | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/libs/sys/luasrc/sys.lua b/libs/sys/luasrc/sys.lua index 1333cd8593..722d5a381d 100644 --- a/libs/sys/luasrc/sys.lua +++ b/libs/sys/luasrc/sys.lua @@ -171,23 +171,23 @@ function sysinfo() local cpuinfo = fs.readfile("/proc/cpuinfo") local meminfo = fs.readfile("/proc/meminfo") - local system = cpuinfo:match("system typ.-:%s*([^\n]+)") - local model = "" local memtotal = tonumber(meminfo:match("MemTotal:%s*(%d+)")) local memcached = tonumber(meminfo:match("\nCached:%s*(%d+)")) local memfree = tonumber(meminfo:match("MemFree:%s*(%d+)")) local membuffers = tonumber(meminfo:match("Buffers:%s*(%d+)")) local bogomips = tonumber(cpuinfo:match("BogoMIPS.-:%s*([^\n]+)")) - if not system then - system = nixio.uname().machine - model = cpuinfo:match("model name.-:%s*([^\n]+)") - if not model then - model = cpuinfo:match("Processor.-:%s*([^\n]+)") - end - else - model = cpuinfo:match("cpu model.-:%s*([^\n]+)") - end + local system = + cpuinfo:match("system type\t+: ([^\n]+)") or + cpuinfo:match("Processor\t+: ([^\n]+)") or + cpuinfo:match("model name\t+: ([^\n]+)") + + local model = + cpuinfo:match("machine\t+: ([^\n]+)") or + cpuinfo:match("Hardware\t+: ([^\n]+)") or + fs.readfile("/proc/diag/model") or + nixio.uname().machine() or + system return system, model, memtotal, memcached, membuffers, memfree, bogomips end @@ -307,6 +307,17 @@ function net.defaultroute6() end end) + if not route then + local global_unicast = luci.ip.IPv6("2000::/3") + net.routes6(function(rt) + if rt.dest:equal(global_unicast) and + (not route or route.metric > rt.metric) + then + route = rt + end + end) + end + return route end |