Merge "Support 32 match types in UidOwnerValue rule" am: ad5b0d96ef
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2096813 Change-Id: I394085b1c0ab861ec2750d30bc2de2e320d82487 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
08ad1023e8
@@ -194,7 +194,7 @@ static inline int bpf_owner_match(struct __sk_buff* skb, uint32_t uid, int direc
|
|||||||
BpfConfig enabledRules = getConfig(UID_RULES_CONFIGURATION_KEY);
|
BpfConfig enabledRules = getConfig(UID_RULES_CONFIGURATION_KEY);
|
||||||
|
|
||||||
UidOwnerValue* uidEntry = bpf_uid_owner_map_lookup_elem(&uid);
|
UidOwnerValue* uidEntry = bpf_uid_owner_map_lookup_elem(&uid);
|
||||||
uint8_t uidRules = uidEntry ? uidEntry->rule : 0;
|
uint32_t uidRules = uidEntry ? uidEntry->rule : 0;
|
||||||
uint32_t allowed_iif = uidEntry ? uidEntry->iif : 0;
|
uint32_t allowed_iif = uidEntry ? uidEntry->iif : 0;
|
||||||
|
|
||||||
if (enabledRules) {
|
if (enabledRules) {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ static_assert(BPF_PERMISSION_UPDATE_DEVICE_STATS == INetd::PERMISSION_UPDATE_DEV
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
const std::string uidMatchTypeToString(uint8_t match) {
|
const std::string uidMatchTypeToString(uint32_t match) {
|
||||||
std::string matchType;
|
std::string matchType;
|
||||||
FLAG_MSG_TRANS(matchType, HAPPY_BOX_MATCH, match);
|
FLAG_MSG_TRANS(matchType, HAPPY_BOX_MATCH, match);
|
||||||
FLAG_MSG_TRANS(matchType, PENALTY_BOX_MATCH, match);
|
FLAG_MSG_TRANS(matchType, PENALTY_BOX_MATCH, match);
|
||||||
@@ -272,7 +272,7 @@ Status TrafficController::removeRule(uint32_t uid, UidOwnerMatchType match) {
|
|||||||
if (oldMatch.ok()) {
|
if (oldMatch.ok()) {
|
||||||
UidOwnerValue newMatch = {
|
UidOwnerValue newMatch = {
|
||||||
.iif = (match == IIF_MATCH) ? 0 : oldMatch.value().iif,
|
.iif = (match == IIF_MATCH) ? 0 : oldMatch.value().iif,
|
||||||
.rule = static_cast<uint8_t>(oldMatch.value().rule & ~match),
|
.rule = oldMatch.value().rule & ~match,
|
||||||
};
|
};
|
||||||
if (newMatch.rule == 0) {
|
if (newMatch.rule == 0) {
|
||||||
RETURN_IF_NOT_OK(mUidOwnerMap.deleteValue(uid));
|
RETURN_IF_NOT_OK(mUidOwnerMap.deleteValue(uid));
|
||||||
@@ -296,13 +296,13 @@ Status TrafficController::addRule(uint32_t uid, UidOwnerMatchType match, uint32_
|
|||||||
if (oldMatch.ok()) {
|
if (oldMatch.ok()) {
|
||||||
UidOwnerValue newMatch = {
|
UidOwnerValue newMatch = {
|
||||||
.iif = iif ? iif : oldMatch.value().iif,
|
.iif = iif ? iif : oldMatch.value().iif,
|
||||||
.rule = static_cast<uint8_t>(oldMatch.value().rule | match),
|
.rule = oldMatch.value().rule | match,
|
||||||
};
|
};
|
||||||
RETURN_IF_NOT_OK(mUidOwnerMap.writeValue(uid, newMatch, BPF_ANY));
|
RETURN_IF_NOT_OK(mUidOwnerMap.writeValue(uid, newMatch, BPF_ANY));
|
||||||
} else {
|
} else {
|
||||||
UidOwnerValue newMatch = {
|
UidOwnerValue newMatch = {
|
||||||
.iif = iif,
|
.iif = iif,
|
||||||
.rule = static_cast<uint8_t>(match),
|
.rule = match,
|
||||||
};
|
};
|
||||||
RETURN_IF_NOT_OK(mUidOwnerMap.writeValue(uid, newMatch, BPF_ANY));
|
RETURN_IF_NOT_OK(mUidOwnerMap.writeValue(uid, newMatch, BPF_ANY));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user