Changeset 8886

Show
Ignore:
Timestamp:
07/18/12 12:22:10 (10 months ago)
Author:
jow
Message:

libs/sys: workaround broken entries in /proc/net/ipv6_route, observed on brcm-2.4

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/sys/luasrc/sys.lua

    r8794 r8886  
    452452            ) 
    453453 
    454             src_ip = luci.ip.Hex( 
    455                 src_ip, tonumber(src_prefix, 16), luci.ip.FAMILY_INET6, false 
    456             ) 
    457  
    458             dst_ip = luci.ip.Hex( 
    459                 dst_ip, tonumber(dst_prefix, 16), luci.ip.FAMILY_INET6, false 
    460             ) 
    461  
    462             nexthop = luci.ip.Hex( nexthop, 128, luci.ip.FAMILY_INET6, false ) 
    463  
    464             local rt = { 
    465                 source   = src_ip, 
    466                 dest     = dst_ip, 
    467                 nexthop  = nexthop, 
    468                 metric   = tonumber(metric, 16), 
    469                 refcount = tonumber(refcnt, 16), 
    470                 usecount = tonumber(usecnt, 16), 
    471                 flags    = tonumber(flags, 16), 
    472                 device   = dev, 
    473  
    474                 -- lua number is too small for storing the metric 
    475                 -- add a metric_raw field with the original content 
    476                 metric_raw = metric 
    477             } 
    478  
    479             if callback then 
    480                 callback(rt) 
    481             else 
    482                 routes[#routes+1] = rt 
     454            if dst_ip and dst_prefix and 
     455               src_ip and src_prefix and 
     456               nexthop and metric and 
     457               refcnt and usecnt and 
     458               flags and dev 
     459            then 
     460                src_ip = luci.ip.Hex( 
     461                    src_ip, tonumber(src_prefix, 16), luci.ip.FAMILY_INET6, false 
     462                ) 
     463 
     464                dst_ip = luci.ip.Hex( 
     465                    dst_ip, tonumber(dst_prefix, 16), luci.ip.FAMILY_INET6, false 
     466                ) 
     467 
     468                nexthop = luci.ip.Hex( nexthop, 128, luci.ip.FAMILY_INET6, false ) 
     469 
     470                local rt = { 
     471                    source   = src_ip, 
     472                    dest     = dst_ip, 
     473                    nexthop  = nexthop, 
     474                    metric   = tonumber(metric, 16), 
     475                    refcount = tonumber(refcnt, 16), 
     476                    usecount = tonumber(usecnt, 16), 
     477                    flags    = tonumber(flags, 16), 
     478                    device   = dev, 
     479 
     480                    -- lua number is too small for storing the metric 
     481                    -- add a metric_raw field with the original content 
     482                    metric_raw = metric 
     483                } 
     484 
     485                if callback then 
     486                    callback(rt) 
     487                else 
     488                    routes[#routes+1] = rt 
     489                end 
    483490            end 
    484491        end