Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
8cb8e966
Commit
8cb8e966
authored
Aug 10, 2015
by
Yonghong Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing more ctrl-c problem
Signed-off-by:
Yonghong Song
<
yhs@plumgrid.com
>
parent
949e9eb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
examples/distributed_bridge/main.py
examples/distributed_bridge/main.py
+5
-2
examples/simulation.py
examples/simulation.py
+5
-4
No files found.
examples/distributed_bridge/main.py
View file @
8cb8e966
...
@@ -45,9 +45,12 @@ try:
...
@@ -45,9 +45,12 @@ try:
sim
=
TunnelSimulation
(
ipdb
)
sim
=
TunnelSimulation
(
ipdb
)
sim
.
start
()
sim
.
start
()
input
(
"Press enter to quit:"
)
input
(
"Press enter to quit:"
)
for
p
in
sim
.
processes
:
p
.
communicate
(
b"
\
n
"
)
except
:
if
"sim"
in
locals
():
for
p
in
sim
.
processes
:
p
.
kill
();
p
.
wait
()
finally
:
finally
:
if
"br-fabric"
in
ipdb
.
interfaces
:
ipdb
.
interfaces
[
"br-fabric"
].
remove
().
commit
()
if
"br-fabric"
in
ipdb
.
interfaces
:
ipdb
.
interfaces
[
"br-fabric"
].
remove
().
commit
()
for
p
in
sim
.
processes
:
p
.
communicate
(
b"
\
n
"
)
if
"sim"
in
locals
():
sim
.
release
()
sim
.
release
()
ipdb
.
release
()
ipdb
.
release
()
null
.
close
()
null
.
close
()
examples/simulation.py
View file @
8cb8e966
import
subprocess
import
subprocess
import
pyroute2
from
pyroute2
import
IPRoute
,
NetNS
,
IPDB
,
NSPopen
from
pyroute2
import
IPRoute
,
NetNS
,
IPDB
,
NSPopen
class
Simulation
(
object
):
class
Simulation
(
object
):
...
@@ -34,9 +35,9 @@ class Simulation(object):
...
@@ -34,9 +35,9 @@ class Simulation(object):
ns_ipdb
=
IPDB
(
nl
)
ns_ipdb
=
IPDB
(
nl
)
self
.
ipdbs
[
nl
.
netns
]
=
ns_ipdb
self
.
ipdbs
[
nl
.
netns
]
=
ns_ipdb
if
disable_ipv6
:
if
disable_ipv6
:
cmd
=
[
"sysctl"
,
"-q"
,
"-w"
,
cmd
1
=
[
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf.default.disable_ipv6=1"
]
"net.ipv6.conf.default.disable_ipv6=1"
]
nsp
=
NSPopen
(
ns_ipdb
.
nl
.
netns
,
cmd
)
nsp
=
NSPopen
(
ns_ipdb
.
nl
.
netns
,
cmd
1
)
nsp
.
wait
();
nsp
.
release
()
nsp
.
wait
();
nsp
.
release
()
ns_ipdb
.
interfaces
.
lo
.
up
().
commit
()
ns_ipdb
.
interfaces
.
lo
.
up
().
commit
()
if
in_ifc
:
if
in_ifc
:
...
@@ -67,9 +68,9 @@ class Simulation(object):
...
@@ -67,9 +68,9 @@ class Simulation(object):
if
macaddr
:
v
.
address
=
macaddr
if
macaddr
:
v
.
address
=
macaddr
v
.
up
()
v
.
up
()
if
disable_ipv6
:
if
disable_ipv6
:
cmd
=
[
"sysctl"
,
"-q"
,
"-w"
,
cmd
1
=
[
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf.%s.disable_ipv6=1"
%
out_ifc
.
ifname
]
"net.ipv6.conf.%s.disable_ipv6=1"
%
out_ifc
.
ifname
]
subprocess
.
call
(
cmd
)
subprocess
.
call
(
cmd
1
)
if
fn
and
out_ifc
:
if
fn
and
out_ifc
:
self
.
ipdb
.
nl
.
tc
(
"add"
,
"ingress"
,
out_ifc
[
"index"
],
"ffff:"
)
self
.
ipdb
.
nl
.
tc
(
"add"
,
"ingress"
,
out_ifc
[
"index"
],
"ffff:"
)
self
.
ipdb
.
nl
.
tc
(
"add-filter"
,
"bpf"
,
out_ifc
[
"index"
],
":1"
,
self
.
ipdb
.
nl
.
tc
(
"add-filter"
,
"bpf"
,
out_ifc
[
"index"
],
":1"
,
...
...
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