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
67337ad9
Commit
67337ad9
authored
Sep 13, 2015
by
4ast
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #214 from iovisor/bblanco_dev
Change test_xlate1 to use act_bpf instead of cls_bpf
parents
8ddb79d3
b4111178
Changes
2
Hide 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 @
67337ad9
...
@@ -92,5 +92,5 @@ int on_packet(struct __sk_buff *skb) {
...
@@ -92,5 +92,5 @@ int on_packet(struct __sk_buff *skb) {
}
}
EOP:
EOP:
return
1
;
return
0
;
}
}
tests/cc/test_xlate1.py
View file @
67337ad9
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
from
netaddr
import
IPAddress
from
netaddr
import
IPAddress
from
bcc
import
BPF
from
bcc
import
BPF
from
pyroute2
import
IPRoute
from
pyroute2
import
IPRoute
,
protocols
from
socket
import
socket
,
AF_INET
,
SOCK_DGRAM
from
socket
import
socket
,
AF_INET
,
SOCK_DGRAM
from
subprocess
import
call
from
subprocess
import
call
import
sys
import
sys
...
@@ -19,7 +19,7 @@ if len(sys.argv) > 1:
...
@@ -19,7 +19,7 @@ if len(sys.argv) > 1:
class
TestBPFFilter
(
TestCase
):
class
TestBPFFilter
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
b
=
BPF
(
arg1
,
arg2
,
debug
=
0
)
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
()
ip
=
IPRoute
()
ifindex
=
ip
.
link_lookup
(
ifname
=
"eth0"
)[
0
]
ifindex
=
ip
.
link_lookup
(
ifname
=
"eth0"
)[
0
]
# set up a network to change the flow:
# set up a network to change the flow:
...
@@ -31,8 +31,11 @@ class TestBPFFilter(TestCase):
...
@@ -31,8 +31,11 @@ class TestBPFFilter(TestCase):
ip
.
tc
(
"add"
,
"ingress"
,
ifindex
,
"ffff:"
)
ip
.
tc
(
"add"
,
"ingress"
,
ifindex
,
"ffff:"
)
ip
.
tc
(
"add"
,
"sfq"
,
ifindex
,
"1:"
)
ip
.
tc
(
"add"
,
"sfq"
,
ifindex
,
"1:"
)
# add same program to both ingress/egress, so pkt is translated in both directions
# 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
)
action
=
{
"kind"
:
"bpf"
,
"fd"
:
fn
.
fd
,
"name"
:
fn
.
name
,
"action"
:
"ok"
}
ip
.
tc
(
"add-filter"
,
"bpf"
,
ifindex
,
":2"
,
fd
=
fn
.
fd
,
name
=
fn
.
name
,
parent
=
"1:"
,
action
=
"ok"
,
classid
=
1
)
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"
)
self
.
xlate
=
b
.
get_table
(
"xlate"
)
def
test_xlate
(
self
):
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