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
7f99ebdf
Commit
7f99ebdf
authored
Feb 28, 2018
by
yonghong-song
Committed by
GitHub
Feb 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1611 from palmtenor/fix_common_include
Avoid including common.h in BPFTable.h
parents
1fe85d07
d83805d2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
8 deletions
+13
-8
src/cc/CMakeLists.txt
src/cc/CMakeLists.txt
+1
-1
src/cc/api/BPFTable.cc
src/cc/api/BPFTable.cc
+4
-0
src/cc/api/BPFTable.h
src/cc/api/BPFTable.h
+4
-3
tests/cc/test_array_table.cc
tests/cc/test_array_table.cc
+1
-1
tests/cc/test_bpf_table.cc
tests/cc/test_bpf_table.cc
+1
-1
tests/cc/test_hash_table.cc
tests/cc/test_hash_table.cc
+2
-2
No files found.
src/cc/CMakeLists.txt
View file @
7f99ebdf
...
@@ -37,7 +37,7 @@ set(bcc_table_sources table_storage.cc shared_table.cc bpffs_table.cc json_map_d
...
@@ -37,7 +37,7 @@ set(bcc_table_sources table_storage.cc shared_table.cc bpffs_table.cc json_map_d
set
(
bcc_util_sources ns_guard.cc common.cc
)
set
(
bcc_util_sources ns_guard.cc common.cc
)
set
(
bcc_sym_sources bcc_syms.cc bcc_elf.c bcc_perf_map.c bcc_proc.c
)
set
(
bcc_sym_sources bcc_syms.cc bcc_elf.c bcc_perf_map.c bcc_proc.c
)
set
(
bcc_common_headers libbpf.h perf_reader.h
)
set
(
bcc_common_headers libbpf.h perf_reader.h
)
set
(
bcc_table_headers
common.h
file_desc.h table_desc.h table_storage.h
)
set
(
bcc_table_headers file_desc.h table_desc.h table_storage.h
)
set
(
bcc_api_headers bpf_common.h bpf_module.h bcc_exception.h bcc_syms.h
)
set
(
bcc_api_headers bpf_common.h bpf_module.h bcc_exception.h bcc_syms.h
)
if
(
ENABLE_CLANG_JIT
)
if
(
ENABLE_CLANG_JIT
)
...
...
src/cc/api/BPFTable.cc
View file @
7f99ebdf
...
@@ -142,6 +142,10 @@ StatusTuple BPFTable::remove_value(const std::string& key_str) {
...
@@ -142,6 +142,10 @@ StatusTuple BPFTable::remove_value(const std::string& key_str) {
return
StatusTuple
(
0
);
return
StatusTuple
(
0
);
}
}
size_t
BPFTable
::
get_possible_cpu_count
()
{
return
get_possible_cpus
().
size
();
}
BPFStackTable
::
BPFStackTable
(
const
TableDesc
&
desc
,
BPFStackTable
::
BPFStackTable
(
const
TableDesc
&
desc
,
bool
use_debug_file
,
bool
use_debug_file
,
bool
check_debug_file_crc
)
bool
check_debug_file_crc
)
...
...
src/cc/api/BPFTable.h
View file @
7f99ebdf
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
#include "bcc_exception.h"
#include "bcc_exception.h"
#include "bcc_syms.h"
#include "bcc_syms.h"
#include "bpf_module.h"
#include "bpf_module.h"
#include "common.h"
#include "libbpf.h"
#include "libbpf.h"
#include "perf_reader.h"
#include "perf_reader.h"
#include "table_desc.h"
#include "table_desc.h"
...
@@ -105,6 +104,8 @@ class BPFTable : public BPFTableBase<void, void> {
...
@@ -105,6 +104,8 @@ class BPFTable : public BPFTableBase<void, void> {
const
std
::
vector
<
std
::
string
>&
value_str
);
const
std
::
vector
<
std
::
string
>&
value_str
);
StatusTuple
remove_value
(
const
std
::
string
&
key_str
);
StatusTuple
remove_value
(
const
std
::
string
&
key_str
);
static
size_t
get_possible_cpu_count
();
};
};
template
<
class
ValueType
>
template
<
class
ValueType
>
...
@@ -157,7 +158,7 @@ class BPFPercpuArrayTable : public BPFArrayTable<std::vector<ValueType>> {
...
@@ -157,7 +158,7 @@ class BPFPercpuArrayTable : public BPFArrayTable<std::vector<ValueType>> {
public:
public:
BPFPercpuArrayTable
(
const
TableDesc
&
desc
)
BPFPercpuArrayTable
(
const
TableDesc
&
desc
)
:
BPFArrayTable
<
std
::
vector
<
ValueType
>>
(
desc
),
:
BPFArrayTable
<
std
::
vector
<
ValueType
>>
(
desc
),
ncpus
(
get_possible_cpus
().
size
())
{
ncpus
(
BPFTable
::
get_possible_cpu_count
())
{
if
(
desc
.
type
!=
BPF_MAP_TYPE_PERCPU_ARRAY
)
if
(
desc
.
type
!=
BPF_MAP_TYPE_PERCPU_ARRAY
)
throw
std
::
invalid_argument
(
"Table '"
+
desc
.
name
+
"' is not a percpu array table"
);
throw
std
::
invalid_argument
(
"Table '"
+
desc
.
name
+
"' is not a percpu array table"
);
// leaf structures have to be aligned to 8 bytes as hardcoded in the linux kernel.
// leaf structures have to be aligned to 8 bytes as hardcoded in the linux kernel.
...
@@ -254,7 +255,7 @@ class BPFPercpuHashTable : public BPFHashTable<KeyType, std::vector<ValueType>>
...
@@ -254,7 +255,7 @@ class BPFPercpuHashTable : public BPFHashTable<KeyType, std::vector<ValueType>>
public:
public:
explicit
BPFPercpuHashTable
(
const
TableDesc
&
desc
)
explicit
BPFPercpuHashTable
(
const
TableDesc
&
desc
)
:
BPFHashTable
<
KeyType
,
std
::
vector
<
ValueType
>>
(
desc
),
:
BPFHashTable
<
KeyType
,
std
::
vector
<
ValueType
>>
(
desc
),
ncpus
(
get_possible_cpus
().
size
())
{
ncpus
(
BPFTable
::
get_possible_cpu_count
())
{
if
(
desc
.
type
!=
BPF_MAP_TYPE_PERCPU_HASH
&&
if
(
desc
.
type
!=
BPF_MAP_TYPE_PERCPU_HASH
&&
desc
.
type
!=
BPF_MAP_TYPE_LRU_PERCPU_HASH
)
desc
.
type
!=
BPF_MAP_TYPE_LRU_PERCPU_HASH
)
throw
std
::
invalid_argument
(
"Table '"
+
desc
.
name
+
"' is not a percpu hash table"
);
throw
std
::
invalid_argument
(
"Table '"
+
desc
.
name
+
"' is not a percpu hash table"
);
...
...
tests/cc/test_array_table.cc
View file @
7f99ebdf
...
@@ -108,7 +108,7 @@ TEST_CASE("percpu array table", "[percpu_array_table]") {
...
@@ -108,7 +108,7 @@ TEST_CASE("percpu array table", "[percpu_array_table]") {
REQUIRE
(
res
.
code
()
==
0
);
REQUIRE
(
res
.
code
()
==
0
);
ebpf
::
BPFPercpuArrayTable
<
uint64_t
>
t
=
bpf
.
get_percpu_array_table
<
uint64_t
>
(
"myarray"
);
ebpf
::
BPFPercpuArrayTable
<
uint64_t
>
t
=
bpf
.
get_percpu_array_table
<
uint64_t
>
(
"myarray"
);
size_t
ncpus
=
ebpf
::
get_possible_cpus
().
size
();
size_t
ncpus
=
ebpf
::
BPFTable
::
get_possible_cpu_count
();
SECTION
(
"bad table type"
)
{
SECTION
(
"bad table type"
)
{
// try to get table of wrong type
// try to get table of wrong type
...
...
tests/cc/test_bpf_table.cc
View file @
7f99ebdf
...
@@ -79,7 +79,7 @@ TEST_CASE("test bpf percpu tables", "[bpf_percpu_table]") {
...
@@ -79,7 +79,7 @@ TEST_CASE("test bpf percpu tables", "[bpf_percpu_table]") {
REQUIRE
(
res
.
code
()
==
0
);
REQUIRE
(
res
.
code
()
==
0
);
ebpf
::
BPFTable
t
=
bpf
.
get_table
(
"myhash"
);
ebpf
::
BPFTable
t
=
bpf
.
get_table
(
"myhash"
);
size_t
ncpus
=
ebpf
::
get_possible_cpus
().
size
();
size_t
ncpus
=
ebpf
::
BPFTable
::
get_possible_cpu_count
();
std
::
vector
<
std
::
string
>
v1
(
ncpus
);
std
::
vector
<
std
::
string
>
v1
(
ncpus
);
for
(
size_t
i
=
0
;
i
<
ncpus
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
ncpus
;
i
++
)
{
...
...
tests/cc/test_hash_table.cc
View file @
7f99ebdf
...
@@ -101,7 +101,7 @@ TEST_CASE("percpu hash table", "[percpu_hash_table]") {
...
@@ -101,7 +101,7 @@ TEST_CASE("percpu hash table", "[percpu_hash_table]") {
ebpf
::
BPFPercpuHashTable
<
int
,
uint64_t
>
t
=
ebpf
::
BPFPercpuHashTable
<
int
,
uint64_t
>
t
=
bpf
.
get_percpu_hash_table
<
int
,
uint64_t
>
(
"myhash"
);
bpf
.
get_percpu_hash_table
<
int
,
uint64_t
>
(
"myhash"
);
size_t
ncpus
=
ebpf
::
get_possible_cpus
().
size
();
size_t
ncpus
=
ebpf
::
BPFTable
::
get_possible_cpu_count
();
SECTION
(
"bad table type"
)
{
SECTION
(
"bad table type"
)
{
// try to get table of wrong type
// try to get table of wrong type
...
@@ -157,4 +157,4 @@ TEST_CASE("percpu hash table", "[percpu_hash_table]") {
...
@@ -157,4 +157,4 @@ TEST_CASE("percpu hash table", "[percpu_hash_table]") {
REQUIRE
(
res
.
code
()
!=
0
);
REQUIRE
(
res
.
code
()
!=
0
);
}
}
}
}
#endif
#endif
\ No newline at end of file
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