Commit bb2a6abf authored by Tom Niget's avatar Tom Niget

Upstream parsing patch from re6st

parent 43b11a47
...@@ -645,16 +645,17 @@ def get_all_route_data(): ...@@ -645,16 +645,17 @@ def get_all_route_data():
for line in ipdata.split("\n"): for line in ipdata.split("\n"):
if line == "": if line == "":
continue continue
match = re.match(r'(?:(unicast|local|broadcast|multicast|throw|' + match = re.match('(?:(unicast|local|broadcast|multicast|throw|'
r'unreachable|prohibit|blackhole|nat) )?' + r'unreachable|prohibit|blackhole|nat) )?(\S+)(?: from (\S+))?'
r'(\S+)(?: via (\S+))? dev (\S+).*(?: metric (\d+))?', line) r'(?: via (\S+))?(?: dev (\S+))?.*(?: metric (\d+))?', line)
if not match: if not match:
raise RuntimeError("Invalid output from `ip route': `%s'" % line) raise RuntimeError("Invalid output from `ip route': `%s'" % line)
tipe = match.group(1) or "unicast" tipe = match.group(1) or "unicast"
prefix = match.group(2) prefix = match.group(2)
nexthop = match.group(3) _src = match.group(3)
interface = ifdata[match.group(4)] nexthop = match.group(4)
metric = match.group(5) interface = ifdata[match.group(5) or "lo"] # 'dev' is missing on 'unreachable' ipv4 routes
metric = match.group(6)
if prefix == "default" or re.search(r'/0$', prefix): if prefix == "default" or re.search(r'/0$', prefix):
prefix = None prefix = None
prefix_len = 0 prefix_len = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment