Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nemu3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
nemu3
Commits
60a471f6
Commit
60a471f6
authored
Nov 03, 2013
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug introduced by change in iproute single-line output.
parent
a0056b9d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
src/nemu/iproute.py
src/nemu/iproute.py
+29
-21
No files found.
src/nemu/iproute.py
View file @
60a471f6
...
@@ -422,40 +422,48 @@ def change_netns(iface, netns):
...
@@ -422,40 +422,48 @@ def change_netns(iface, netns):
# Address handling
# Address handling
def
get_addr_data
():
def
get_addr_data
():
ipdata
=
backticks
([
IP_PATH
,
"
-o"
,
"
addr"
,
"list"
])
ipdata
=
backticks
([
IP_PATH
,
"addr"
,
"list"
])
byidx
=
{}
byidx
=
{}
bynam
=
{}
bynam
=
{}
current
=
None
for
line
in
ipdata
.
split
(
"
\
n
"
):
for
line
in
ipdata
.
split
(
"
\
n
"
):
if
line
==
""
:
if
line
==
""
:
continue
continue
match
=
re
.
search
(
r'^(\
d+):
\s+(\
S+
?)(:?)
\s+(.*)
'
,
line
)
match
=
re
.
search
(
r'^(\
d+):
\s+(\
S+
):
', line)
if
not
match
:
if match:
raise
RuntimeError
(
"Invalid `ip' command output"
)
# First line of output.
idx = int(match.group(1))
idx = int(match.group(1))
name = match.group(2)
name = match.group(2)
if
name
not
in
bynam
:
current = name
if name in bynam:
raise RuntimeError("Invalid `ip'
command
output
")
bynam[name] = byidx[idx] = []
bynam[name] = byidx[idx] = []
if
match
.
group
(
3
):
# BBB: old iproute also shows link info
continue
continue
bynam
[
name
].
append
(
_parse_ip_addr
(
match
.
group
(
4
)))
return
byidx
,
bynam
def
_parse_ip_addr
(
line
):
if not current:
match
=
re
.
search
(
r'^inet ([0-9.]+)/(\
d+)(?:
brd ([0-9.]+))?'
,
line
)
raise RuntimeError("
Invalid
`
ip
' command output")
if
match
!=
None
:
return
ipv4address
(
match = re.search(r'
^
\
s
*
inet
([
0
-
9.
]
+
)
/
(
\
d
+
)(
?
:
brd
([
0
-
9.
]
+
))
?
', line)
if match:
bynam[current].append(ipv4address(
address = match.group(1),
address = match.group(1),
prefix_len = match.group(2),
prefix_len = match.group(2),
broadcast
=
match
.
group
(
3
))
broadcast = match.group(3)))
continue
match
=
re
.
search
(
r'^
inet6 ([0-9a-f:]+)/(\
d+)
', line)
match = re.search(r'
^
\
s
*
inet6
([
0
-
9
a
-
f
:]
+
)
/
(
\
d
+
)
', line)
if match != None
:
if match
:
return
ipv6address(
bynam[current].append(
ipv6address(
address = match.group(1),
address = match.group(1),
prefix_len = match.group(2))
prefix_len = match.group(2)))
continue
raise RuntimeError("Problems parsing ip command output")
# Extra info, ignored.
continue
return byidx, bynam
def add_addr(iface, address):
def add_addr(iface, address):
ifname = _get_if_name(iface)
ifname = _get_if_name(iface)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment