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
0d7245dc
Commit
0d7245dc
authored
Aug 10, 2015
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #122 from iovisor/yhs_dev2
Fixing more ctrl-c problem
parents
0066ca5c
8cb8e966
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 @
0d7245dc
...
...
@@ -51,9 +51,12 @@ try:
sim
=
TunnelSimulation
(
ipdb
)
sim
.
start
()
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
:
if
"br-fabric"
in
ipdb
.
interfaces
:
ipdb
.
interfaces
[
"br-fabric"
].
remove
().
commit
()
for
p
in
sim
.
processes
:
p
.
communicate
(
b"
\
n
"
)
sim
.
release
()
if
"sim"
in
locals
():
sim
.
release
()
ipdb
.
release
()
null
.
close
()
examples/simulation.py
View file @
0d7245dc
import
subprocess
import
pyroute2
from
pyroute2
import
IPRoute
,
NetNS
,
IPDB
,
NSPopen
class
Simulation
(
object
):
...
...
@@ -34,9 +35,9 @@ class Simulation(object):
ns_ipdb
=
IPDB
(
nl
)
self
.
ipdbs
[
nl
.
netns
]
=
ns_ipdb
if
disable_ipv6
:
cmd
=
[
"sysctl"
,
"-q"
,
"-w"
,
cmd
1
=
[
"sysctl"
,
"-q"
,
"-w"
,
"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
()
ns_ipdb
.
interfaces
.
lo
.
up
().
commit
()
if
in_ifc
:
...
...
@@ -67,9 +68,9 @@ class Simulation(object):
if
macaddr
:
v
.
address
=
macaddr
v
.
up
()
if
disable_ipv6
:
cmd
=
[
"sysctl"
,
"-q"
,
"-w"
,
cmd
1
=
[
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf.%s.disable_ipv6=1"
%
out_ifc
.
ifname
]
subprocess
.
call
(
cmd
)
subprocess
.
call
(
cmd
1
)
if
fn
and
out_ifc
:
self
.
ipdb
.
nl
.
tc
(
"add"
,
"ingress"
,
out_ifc
[
"index"
],
"ffff:"
)
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