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
10f718f4
Commit
10f718f4
authored
Jul 12, 2018
by
Teng Qin
Committed by
GitHub
Jul 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1884 from netgroup-polito/fix-get-table-offline-percpu
fix get_table_offline for percpu hash table
parents
1cf67ae2
b5cadaff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
src/cc/api/BPFTable.h
src/cc/api/BPFTable.h
+4
-1
tests/cc/test_hash_table.cc
tests/cc/test_hash_table.cc
+33
-0
No files found.
src/cc/api/BPFTable.h
View file @
10f718f4
...
...
@@ -232,11 +232,14 @@ class BPFHashTable : public BPFTableBase<KeyType, ValueType> {
KeyType
cur
;
ValueType
value
;
StatusTuple
r
(
0
);
if
(
!
this
->
first
(
&
cur
))
return
res
;
while
(
true
)
{
if
(
!
this
->
lookup
(
&
cur
,
&
value
))
r
=
get_value
(
cur
,
value
);
if
(
r
.
code
()
!=
0
)
break
;
res
.
emplace_back
(
cur
,
value
);
if
(
!
this
->
next
(
&
cur
,
&
cur
))
...
...
tests/cc/test_hash_table.cc
View file @
10f718f4
...
...
@@ -84,6 +84,10 @@ TEST_CASE("test hash table", "[hash_table]") {
REQUIRE
(
pair
.
first
%
3
==
0
);
REQUIRE
(
pair
.
first
/
3
==
pair
.
second
);
}
// clear table
t
.
clear_table_non_atomic
();
REQUIRE
(
t
.
get_table_offline
().
size
()
==
0
);
}
}
...
...
@@ -156,5 +160,34 @@ TEST_CASE("percpu hash table", "[percpu_hash_table]") {
res
=
t
.
get_value
(
k
,
v2
);
REQUIRE
(
res
.
code
()
!=
0
);
}
SECTION
(
"walk table"
)
{
std
::
vector
<
uint64_t
>
v
(
ncpus
);
for
(
int
k
=
3
;
k
<=
30
;
k
+=
3
)
{
for
(
size_t
cpu
=
0
;
cpu
<
ncpus
;
cpu
++
)
{
v
[
cpu
]
=
k
*
cpu
;
}
res
=
t
.
update_value
(
k
,
v
);
REQUIRE
(
res
.
code
()
==
0
);
}
// get whole table
auto
offline
=
t
.
get_table_offline
();
REQUIRE
(
offline
.
size
()
==
10
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
// check the key
REQUIRE
(
offline
.
at
(
i
).
first
%
3
==
0
);
// check value
for
(
size_t
cpu
=
0
;
cpu
<
ncpus
;
cpu
++
)
{
REQUIRE
(
offline
.
at
(
i
).
second
.
at
(
cpu
)
==
cpu
*
offline
.
at
(
i
).
first
);
}
}
// clear table
t
.
clear_table_non_atomic
();
REQUIRE
(
t
.
get_table_offline
().
size
()
==
0
);
}
}
#endif
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