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
797224c2
Commit
797224c2
authored
Jun 23, 2015
by
Yonghong Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use new get_table interface to avoid specify key/leaf type in py code
Signed-off-by:
Yonghong Song
<
yhs@plumgrid.com
>
parent
eb697e29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
25 deletions
+16
-25
tests/cc/test_brb.py
tests/cc/test_brb.py
+14
-23
tests/cc/test_brb2.py
tests/cc/test_brb2.py
+2
-2
No files found.
tests/cc/test_brb.py
View file @
797224c2
...
...
@@ -74,13 +74,6 @@ import struct
arg1
=
sys
.
argv
.
pop
(
1
)
class
Bpf_Dest
(
Structure
):
_fields_
=
[(
"prog_id"
,
c_uint
),
(
"port_id"
,
c_uint
)]
class
Eth_Addr
(
Structure
):
_fields_
=
[(
"addr"
,
c_ulonglong
)]
class
TestBPFSocket
(
TestCase
):
def
setup_vm_ns
(
self
,
ns
,
veth_in
,
veth_out
):
subprocess
.
call
([
"ip"
,
"link"
,
"add"
,
veth_in
,
"type"
,
"veth"
,
"peer"
,
"name"
,
veth_out
])
...
...
@@ -132,32 +125,30 @@ class TestBPFSocket(TestCase):
self
.
vm2_rtr_mask
=
"200.1.1.0"
def
get_table
(
self
,
b
):
self
.
jump
=
b
.
get_table
(
"jump"
,
c_uint
,
c_uint
)
self
.
jump
=
b
.
get_table
(
"jump"
)
self
.
pem_dest
=
b
.
get_table
(
"pem_dest"
,
c_uint
,
Bpf_Dest
)
self
.
pem_port
=
b
.
get_table
(
"pem_port"
,
c_uint
,
c_uint
)
self
.
pem_ifindex
=
b
.
get_table
(
"pem_ifindex"
,
c_uint
,
c_uint
)
self
.
pem_stats
=
b
.
get_table
(
"pem_stats"
,
c_uint
,
c_uint
)
self
.
pem_dest
=
b
.
get_table
(
"pem_dest"
)
self
.
pem_port
=
b
.
get_table
(
"pem_port"
)
self
.
pem_ifindex
=
b
.
get_table
(
"pem_ifindex"
)
self
.
pem_stats
=
b
.
get_table
(
"pem_stats"
)
self
.
br1_dest
=
b
.
get_table
(
"br1_dest"
,
c_uint
,
Bpf_Dest
)
self
.
br1_mac
=
b
.
get_table
(
"br1_mac"
,
Eth_Addr
,
c_uint
)
self
.
br1_rtr
=
b
.
get_table
(
"br1_rtr"
,
c_uint
,
c_uint
)
self
.
br1_dest
=
b
.
get_table
(
"br1_dest"
)
self
.
br1_mac
=
b
.
get_table
(
"br1_mac"
)
self
.
br1_rtr
=
b
.
get_table
(
"br1_rtr"
)
self
.
br2_dest
=
b
.
get_table
(
"br2_dest"
,
c_uint
,
Bpf_Dest
)
self
.
br2_mac
=
b
.
get_table
(
"br2_mac"
,
Eth_Addr
,
c_uint
)
self
.
br2_rtr
=
b
.
get_table
(
"br2_rtr"
,
c_uint
,
c_uint
)
self
.
br2_dest
=
b
.
get_table
(
"br2_dest"
)
self
.
br2_mac
=
b
.
get_table
(
"br2_mac"
)
self
.
br2_rtr
=
b
.
get_table
(
"br2_rtr"
)
def
connect_ports
(
self
,
prog_id_pem
,
prog_id_br
,
curr_pem_pid
,
curr_br_pid
,
ip
,
br_dest_map
,
br_mac_map
,
ns_eth_out
,
vm_mac
,
vm_ip
):
val
=
Bpf_Dest
(
prog_id_br
,
curr_br_pid
)
self
.
pem_dest
[
c_uint
(
curr_pem_pid
)]
=
val
val
=
Bpf_Dest
(
prog_id_pem
,
curr_pem_pid
)
br_dest_map
[
c_uint
(
curr_br_pid
)]
=
val
self
.
pem_dest
[
c_uint
(
curr_pem_pid
)]
=
self
.
pem_dest
.
Leaf
(
prog_id_br
,
curr_br_pid
)
br_dest_map
[
c_uint
(
curr_br_pid
)]
=
br_dest_map
.
Leaf
(
prog_id_pem
,
curr_pem_pid
)
ifindex
=
ip
.
link_lookup
(
ifname
=
ns_eth_out
)[
0
]
self
.
pem_port
[
c_uint
(
curr_pem_pid
)]
=
c_uint
(
ifindex
)
self
.
pem_ifindex
[
c_uint
(
ifindex
)]
=
c_uint
(
curr_pem_pid
)
mac_addr
=
Eth_Addr
(
int
(
EUI
(
vm_mac
.
decode
())))
mac_addr
=
br_mac_map
.
Key
(
int
(
EUI
(
vm_mac
.
decode
())))
br_mac_map
[
mac_addr
]
=
c_uint
(
curr_br_pid
)
def
attach_filter
(
self
,
ip
,
ifname
,
fd
,
name
):
...
...
tests/cc/test_brb2.py
View file @
797224c2
...
...
@@ -143,8 +143,8 @@ class TestBPFSocket(TestCase):
def
config_maps
(
self
):
b
=
BPF
(
src_file
=
arg1
,
debug
=
0
)
pem_fn
=
b
.
load_func
(
"pem"
,
BPF
.
SCHED_CLS
)
self
.
pem_dest
=
b
.
get_table
(
"pem_dest"
,
c_uint
,
c_uint
)
self
.
pem_stats
=
b
.
get_table
(
"pem_stats"
,
c_uint
,
c_uint
)
self
.
pem_dest
=
b
.
get_table
(
"pem_dest"
)
self
.
pem_stats
=
b
.
get_table
(
"pem_stats"
)
ip
=
IPRoute
()
# pem just relays packets between VM and its corresponding
...
...
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