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
8ebd2773
Commit
8ebd2773
authored
Jul 13, 2015
by
yonghong-song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #85 from iovisor/bblanco_dev
Change to simulator arguments for readability
parents
0afb0a21
9d2f33a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
examples/simulation.py
examples/simulation.py
+12
-9
tests/cc/test_brb.py
tests/cc/test_brb.py
+1
-1
No files found.
examples/simulation.py
View file @
8ebd2773
...
...
@@ -18,13 +18,19 @@ class Simulation(object):
# if called directly outside Simulation class, "ifc_base_name" should be
# different from "name", the "ifc_base_name" and "name" are the same for
# the first ifc created by namespace
def
_ns_add_ifc
(
self
,
name
,
ns_ifc
,
ifc_base_name
,
in_ifc
=
None
,
out
_ifc
=
None
,
ipaddr
=
None
,
macaddr
=
None
,
fn
=
None
,
cmd
=
None
,
action
=
"ok"
,
disable_ipv6
=
False
):
def
_ns_add_ifc
(
self
,
name
,
ns_ifc
,
ifc_base_name
=
None
,
in
_ifc
=
None
,
out_ifc
=
None
,
ipaddr
=
None
,
macaddr
=
None
,
fn
=
None
,
cmd
=
None
,
action
=
"ok"
,
disable_ipv6
=
False
):
if
name
in
self
.
ipdbs
:
ns_ipdb
=
self
.
ipdbs
[
name
]
else
:
ns_ipdb
=
IPDB
(
nl
=
NetNS
(
name
))
if
disable_ipv6
:
cmd
=
[
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf.default.disable_ipv6=1"
]
nsp
=
NSPopen
(
ns_ipdb
.
nl
.
netns
,
cmd
)
nsp
.
wait
();
nsp
.
release
()
ns_ipdb
.
interfaces
.
lo
.
up
().
commit
()
if
in_ifc
:
in_ifname
=
in_ifc
.
ifname
else
:
...
...
@@ -43,13 +49,10 @@ class Simulation(object):
if
ipaddr
:
v
.
add_ip
(
"%s"
%
ipaddr
)
if
macaddr
:
v
.
address
=
macaddr
v
.
up
()
# if required, disable ipv6 before attaching the filter
if
disable_ipv6
:
subprocess
.
call
([
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf."
+
out_ifc
.
ifname
+
".disable_ipv6=1"
])
nsp
=
NSPopen
(
ns_ipdb
.
nl
.
netns
,
[
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf."
+
ns_ifc
+
".disable_ipv6=1"
])
nsp
.
wait
();
nsp
.
release
()
cmd
=
[
"sysctl"
,
"-q"
,
"-w"
,
"net.ipv6.conf.%s.disable_ipv6=1"
%
out_ifc
.
ifname
]
subprocess
.
call
(
cmd
)
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"
,
...
...
tests/cc/test_brb.py
View file @
8ebd2773
...
...
@@ -109,7 +109,7 @@ class TestBPFSocket(TestCase):
br_dest_map
[
c_uint
(
curr_br_pid
)]
=
br_dest_map
.
Leaf
(
prog_id_pem
,
curr_pem_pid
)
self
.
pem_port
[
c_uint
(
curr_pem_pid
)]
=
c_uint
(
ifindex
)
self
.
pem_ifindex
[
c_uint
(
ifindex
)]
=
c_uint
(
curr_pem_pid
)
mac_addr
=
br_mac_map
.
Key
(
int
(
EUI
(
vm_mac
.
decode
()
)))
mac_addr
=
br_mac_map
.
Key
(
int
(
EUI
(
vm_mac
)))
br_mac_map
[
mac_addr
]
=
c_uint
(
curr_br_pid
)
def
config_maps
(
self
):
...
...
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