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
5c483e30
Commit
5c483e30
authored
Jun 10, 2015
by
Yonghong Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use ethernet->src/dst to get mac address instead of primitive load_* functions
Signed-off-by:
Yonghong Song
<
yhs@plumgrid.com
>
parent
febb97e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
tests/cc/test_brb.c
tests/cc/test_brb.c
+6
-10
No files found.
tests/cc/test_brb.c
View file @
5c483e30
...
...
@@ -2,9 +2,7 @@
// Licensed under the Apache License, Version 2.0 (the "License")
#include <bcc/proto.h>
/* compiler workaround */
#define _htonl __builtin_bswap32
#define _htons __builtin_bswap16
#define _memcpy __builtin_memcpy
// meta data passed between bpf programs
typedef
struct
bpf_metadata
{
...
...
@@ -117,6 +115,7 @@ static int br_common(struct __sk_buff *skb, int which_br) {
u32
tx_port_id
;
bpf_dest_t
*
dest_p
;
u32
index
,
*
rtrif_p
;
u64
mac_addr
;
if
(
skb
->
tc_index
==
0
)
{
skb
->
tc_index
=
1
;
...
...
@@ -129,9 +128,8 @@ static int br_common(struct __sk_buff *skb, int which_br) {
BEGIN
(
ethernet
);
PROTO
(
ethernet
)
{
// ethernet->dst seems not working, so tentatively use the primitive C API.
*
(
__u32
*
)
&
dmac
.
addr
[
0
]
=
_htonl
(
load_word
(
skb
,
0
));
*
(
__u16
*
)
&
dmac
.
addr
[
4
]
=
_htons
(
load_half
(
skb
,
4
));
mac_addr
=
bpf_htonll
(
ethernet
->
dst
);
_memcpy
(
dmac
.
addr
,
(
u8
*
)
&
mac_addr
+
2
,
6
);
if
(
meta
.
prog_id
!=
0
)
{
/* send to the router */
if
(
dmac
.
addr
[
0
]
&
dmac
.
addr
[
1
]
&
dmac
.
addr
[
2
]
&
dmac
.
addr
[
3
]
&
dmac
.
addr
[
4
]
&
dmac
.
addr
[
5
]
==
0xff
)
{
...
...
@@ -172,7 +170,6 @@ static int br_common(struct __sk_buff *skb, int which_br) {
PROTO
(
arp
)
{
/* mac learning */
// arpop = load_half(skb, 20);
arpop
=
arp
->
oper
;
if
(
arpop
==
2
)
{
index
=
0
;
...
...
@@ -184,9 +181,8 @@ static int br_common(struct __sk_buff *skb, int which_br) {
__u32
ifindex
=
*
rtrif_p
;
eth_addr_t
smac
;
*
(
__u16
*
)
&
smac
.
addr
[
0
]
=
_htons
(
load_half
(
skb
,
6
));
*
(
__u16
*
)
&
smac
.
addr
[
2
]
=
_htons
(
load_half
(
skb
,
8
));
*
(
__u16
*
)
&
smac
.
addr
[
4
]
=
_htons
(
load_half
(
skb
,
10
));
mac_addr
=
bpf_htonll
(
ethernet
->
src
);
_memcpy
(
smac
.
addr
,
(
u8
*
)
&
mac_addr
+
2
,
6
);
if
(
which_br
==
1
)
br1_mac_ifindex
.
update
(
&
smac
,
&
ifindex
);
else
...
...
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