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
c3ad0982
Commit
c3ad0982
authored
Sep 14, 2015
by
affansyed
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
d96f6ca1
67337ad9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
tests/cc/test_xlate1.c
tests/cc/test_xlate1.c
+1
-1
tests/cc/test_xlate1.py
tests/cc/test_xlate1.py
+7
-4
No files found.
tests/cc/test_xlate1.c
View file @
c3ad0982
...
...
@@ -92,5 +92,5 @@ int on_packet(struct __sk_buff *skb) {
}
EOP:
return
1
;
return
0
;
}
tests/cc/test_xlate1.py
View file @
c3ad0982
...
...
@@ -4,7 +4,7 @@
from
netaddr
import
IPAddress
from
bcc
import
BPF
from
pyroute2
import
IPRoute
from
pyroute2
import
IPRoute
,
protocols
from
socket
import
socket
,
AF_INET
,
SOCK_DGRAM
from
subprocess
import
call
import
sys
...
...
@@ -19,7 +19,7 @@ if len(sys.argv) > 1:
class
TestBPFFilter
(
TestCase
):
def
setUp
(
self
):
b
=
BPF
(
arg1
,
arg2
,
debug
=
0
)
fn
=
b
.
load_func
(
"on_packet"
,
BPF
.
SCHED_
CLS
)
fn
=
b
.
load_func
(
"on_packet"
,
BPF
.
SCHED_
ACT
)
ip
=
IPRoute
()
ifindex
=
ip
.
link_lookup
(
ifname
=
"eth0"
)[
0
]
# set up a network to change the flow:
...
...
@@ -31,8 +31,11 @@ class TestBPFFilter(TestCase):
ip
.
tc
(
"add"
,
"ingress"
,
ifindex
,
"ffff:"
)
ip
.
tc
(
"add"
,
"sfq"
,
ifindex
,
"1:"
)
# add same program to both ingress/egress, so pkt is translated in both directions
ip
.
tc
(
"add-filter"
,
"bpf"
,
ifindex
,
":1"
,
fd
=
fn
.
fd
,
name
=
fn
.
name
,
parent
=
"ffff:"
,
action
=
"ok"
,
classid
=
1
)
ip
.
tc
(
"add-filter"
,
"bpf"
,
ifindex
,
":2"
,
fd
=
fn
.
fd
,
name
=
fn
.
name
,
parent
=
"1:"
,
action
=
"ok"
,
classid
=
1
)
action
=
{
"kind"
:
"bpf"
,
"fd"
:
fn
.
fd
,
"name"
:
fn
.
name
,
"action"
:
"ok"
}
ip
.
tc
(
"add-filter"
,
"u32"
,
ifindex
,
":1"
,
parent
=
"ffff:"
,
action
=
[
action
],
protocol
=
protocols
.
ETH_P_ALL
,
classid
=
1
,
target
=
0x10002
,
keys
=
[
'0x0/0x0+0'
])
ip
.
tc
(
"add-filter"
,
"u32"
,
ifindex
,
":2"
,
parent
=
"1:"
,
action
=
[
action
],
protocol
=
protocols
.
ETH_P_ALL
,
classid
=
1
,
target
=
0x10002
,
keys
=
[
'0x0/0x0+0'
])
self
.
xlate
=
b
.
get_table
(
"xlate"
)
def
test_xlate
(
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