From 7b4e31888952fe11dcd1abcc5695d26f80ca38a3 Mon Sep 17 00:00:00 2001 From: Junyu Lai Date: Mon, 2 Sep 2024 14:25:31 +0800 Subject: [PATCH] Return false when tetherOffloadRuleAdd doesn't really add items This is needed for the follow-up CLs to check whether an item was added when calling tetherOffloadRuleAdd. This is safe since no one is actually checking the return value of this method. Test: atest TetheringTests Bug: 354619988 Change-Id: I28bafe3145bd2f62f9a7db9d0a300d2c7a148040 --- .../tethering/apishim/api31/BpfCoordinatorShimImpl.java | 1 + .../tethering/apishim/common/BpfCoordinatorShim.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java b/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java index 4d1e7ef482..e6e99f4c2c 100644 --- a/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java +++ b/Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java @@ -359,6 +359,7 @@ public class BpfCoordinatorShimImpl } catch (IllegalStateException e) { // Silent if the rule already exists. Note that the errno EEXIST was rethrown as // IllegalStateException. See BpfMap#insertEntry. + return false; } return true; } diff --git a/Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java b/Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java index d28a397cb4..026b1c39d0 100644 --- a/Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java +++ b/Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java @@ -140,6 +140,8 @@ public abstract class BpfCoordinatorShim { /** * Adds a tethering IPv4 offload rule to appropriate BPF map. + * + * @return true iff the map was modified, false if the key already exists or there was an error. */ public abstract boolean tetherOffloadRuleAdd(boolean downstream, @NonNull Tether4Key key, @NonNull Tether4Value value);