Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Connectivity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Connectivity
Commits
60a657f4
Commit
60a657f4
authored
1 year ago
by
Maciej Żenczykowski
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "eliminate some casts" into main
parents
2e29f6dd
d7ade39c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bpf_progs/netd.h
+3
-3
3 additions, 3 deletions
bpf_progs/netd.h
tests/native/utilities/firewall.cpp
+5
-5
5 additions, 5 deletions
tests/native/utilities/firewall.cpp
with
8 additions
and
8 deletions
bpf_progs/netd.h
+
3
−
3
View file @
60a657f4
...
...
@@ -178,7 +178,7 @@ ASSERT_STRING_EQUAL(XT_BPF_DENYLIST_PROG_PATH, BPF_NETD_PATH "prog_netd_skfilte
#endif // __cplusplus
// LINT.IfChange(match_type)
enum
UidOwnerMatchType
{
enum
UidOwnerMatchType
:
uint32_t
{
NO_MATCH
=
0
,
HAPPY_BOX_MATCH
=
(
1
<<
0
),
PENALTY_BOX_MATCH
=
(
1
<<
1
),
...
...
@@ -196,14 +196,14 @@ enum UidOwnerMatchType {
};
// LINT.ThenChange(../framework/src/android/net/BpfNetMapsConstants.java)
enum
BpfPermissionMatch
{
enum
BpfPermissionMatch
:
uint8_t
{
BPF_PERMISSION_INTERNET
=
1
<<
2
,
BPF_PERMISSION_UPDATE_DEVICE_STATS
=
1
<<
3
,
};
// In production we use two identical stats maps to record per uid stats and
// do swap and clean based on the configuration specified here. The statsMapType
// value in configuration map specified which map is currently in use.
enum
StatsMapType
{
enum
StatsMapType
:
uint32_t
{
SELECT_MAP_A
,
SELECT_MAP_B
,
};
...
...
This diff is collapsed.
Click to expand it.
tests/native/utilities/firewall.cpp
+
5
−
5
View file @
60a657f4
...
...
@@ -60,10 +60,10 @@ Result<void> Firewall::addRule(uint32_t uid, UidOwnerMatchType match, uint32_t i
// iif should be non-zero if and only if match == MATCH_IIF
if
(
match
==
IIF_MATCH
&&
iif
==
0
)
{
return
Errorf
(
"Interface match {} must have nonzero interface index"
,
static_cast
<
int
>
(
match
));
static_cast
<
u
int
32_t
>
(
match
));
}
else
if
(
match
!=
IIF_MATCH
&&
iif
!=
0
)
{
return
Errorf
(
"Non-interface match {} must have zero interface index"
,
static_cast
<
int
>
(
match
));
static_cast
<
u
int
32_t
>
(
match
));
}
std
::
lock_guard
guard
(
mMutex
);
...
...
@@ -71,14 +71,14 @@ Result<void> Firewall::addRule(uint32_t uid, UidOwnerMatchType match, uint32_t i
if
(
oldMatch
.
ok
())
{
UidOwnerValue
newMatch
=
{
.
iif
=
iif
?
iif
:
oldMatch
.
value
().
iif
,
.
rule
=
static_cast
<
uint32_t
>
(
oldMatch
.
value
().
rule
|
match
)
,
.
rule
=
oldMatch
.
value
().
rule
|
match
,
};
auto
res
=
mUidOwnerMap
.
writeValue
(
uid
,
newMatch
,
BPF_ANY
);
if
(
!
res
.
ok
())
return
Errorf
(
"Failed to update rule: {}"
,
res
.
error
().
message
());
}
else
{
UidOwnerValue
newMatch
=
{
.
iif
=
iif
,
.
rule
=
static_cast
<
uint32_t
>
(
match
)
,
.
rule
=
match
,
};
auto
res
=
mUidOwnerMap
.
writeValue
(
uid
,
newMatch
,
BPF_ANY
);
if
(
!
res
.
ok
())
return
Errorf
(
"Failed to add rule: {}"
,
res
.
error
().
message
());
...
...
@@ -93,7 +93,7 @@ Result<void> Firewall::removeRule(uint32_t uid, UidOwnerMatchType match) {
UidOwnerValue
newMatch
=
{
.
iif
=
(
match
==
IIF_MATCH
)
?
0
:
oldMatch
.
value
().
iif
,
.
rule
=
static_cast
<
uint32_t
>
(
oldMatch
.
value
().
rule
&
~
match
)
,
.
rule
=
oldMatch
.
value
().
rule
&
~
match
,
};
if
(
newMatch
.
rule
==
0
)
{
auto
res
=
mUidOwnerMap
.
deleteValue
(
uid
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment