Skip to content
Snippets Groups Projects
Commit c806db20 authored by Suprabh Shukla's avatar Suprabh Shukla
Browse files

Use uint_32 for UidOwnerMatchType

The enum is already using 12 bits, so using fewer bits loses information.
This is in sync with the UidOwnerValue struct used to contain this data.

Test: atest resolv_integration_test
Test: atest resolv_unit_test

Bug: 325150155
Change-Id: Ide0ccea9614cda803b3700a0cc22977e9608209e
parent 901db134
No related branches found
No related tags found
No related merge requests found
......@@ -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<uint8_t>(oldMatch.value().rule | match),
.rule = static_cast<uint32_t>(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<uint8_t>(match),
.rule = static_cast<uint32_t>(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<uint8_t>(oldMatch.value().rule & ~match),
.rule = static_cast<uint32_t>(oldMatch.value().rule & ~match),
};
if (newMatch.rule == 0) {
auto res = mUidOwnerMap.deleteValue(uid);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment