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
98faabfc
Commit
98faabfc
authored
Jul 28, 2010
by
Martín Ferrari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more sanity checks
parent
8fbf9bd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
src/netns/node.py
src/netns/node.py
+13
-6
No files found.
src/netns/node.py
View file @
98faabfc
...
...
@@ -21,12 +21,15 @@ class Node(object):
If keepns is true, the network name space is not created and can be run
as a normal user, for testing. If debug is true, details of the
communication protocol are printed on stderr."""
# Initialize attributes, in case something fails during __init__
self
.
_pid
=
self
.
_debug
=
self
.
_slave
=
None
self
.
_processes
=
weakref
.
WeakValueDictionary
()
self
.
_interfaces
=
weakref
.
WeakValueDictionary
()
fd
,
pid
=
_start_child
(
debug
,
nonetns
)
self
.
_pid
=
pid
self
.
_debug
=
debug
self
.
_slave
=
netns
.
protocol
.
Client
(
fd
,
fd
,
debug
)
self
.
_processes
=
weakref
.
WeakValueDictionary
()
self
.
_interfaces
=
weakref
.
WeakValueDictionary
()
Node
.
_nodes
[
Node
.
_nextnode
]
=
self
Node
.
_nextnode
+=
1
...
...
@@ -41,13 +44,15 @@ class Node(object):
sys
.
stderr
.
write
(
"*** Node(%s) destroy
\
n
"
%
self
.
pid
)
for
p
in
self
.
_processes
.
values
():
p
.
destroy
()
del
self
.
_processes
# Use get_interfaces to force a rescan
for
i
in
self
.
get_interfaces
():
i
.
destroy
()
if
self
.
_slave
:
self
.
_slave
.
shutdown
()
del
self
.
_processes
del
self
.
_interfaces
del
self
.
_pid
self
.
_slave
.
shutdown
()
del
self
.
_slave
@
property
...
...
@@ -89,6 +94,8 @@ class Node(object):
iface
.
destroy
()
def
get_interfaces
(
self
):
if
not
self
.
_slave
:
return
[]
ifaces
=
self
.
_slave
.
get_if_data
()
ret
=
[]
for
i
in
ifaces
:
...
...
@@ -147,8 +154,8 @@ def _start_child(debug, nonetns):
if
not
nonetns
:
# create new name space
unshare
.
unshare
(
unshare
.
CLONE_NEWNET
)
# Enable packet forwarding
netns
.
iproute
.
_execute
([
'sysctl'
,
'-w'
,
'net.ipv4.ip_forward=1'
])
# Enable packet forwarding
netns
.
iproute
.
_execute
([
'sysctl'
,
'-w'
,
'net.ipv4.ip_forward=1'
])
# FIXME: ipv6?
srv
.
run
()
except
BaseException
,
e
:
...
...
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