luci-app-olsr: use luci.ip.routes() to find default gw
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 22 Jan 2015 14:12:56 +0000 (15:12 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 22 Jan 2015 14:12:56 +0000 (15:12 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
applications/luci-app-olsr/luasrc/controller/olsr.lua

index 3615372909f3243e3e6efe2e949455b554563556..80f99addc6c7b257121d1f01ccdf2e1895f9ba38 100644 (file)
@@ -108,16 +108,10 @@ function action_neigh(json)
        local assoclist = {}
        --local neightbl = require "neightbl"
        local ipc = require "luci.ip"
+       local defaultgw
 
-       luci.sys.net.routes(function(r) 
-               if r.dest:prefix() == 0 then 
-                       defaultgw = r.gateway:string() 
-               end
-       end)
-
-       if not defaultgw then
-               defaultgw = luci.util.exec("ip route list exact 0.0.0.0/0 table all"):match(" via (%S+)")
-       end
+       ipc.routes({ family = 4, type = 1, dest_exact = "0.0.0.0/0" },
+               function(rt) defaultgw = rt.gw end)
 
        local function compare(a,b)
                if a.proto == b.proto then