replace TetherLimitValue with S64
(mostly autogenerated, with minor tweaks to make it build) Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Idb3706d022c3fbd86fd3abd800ff5eee8edda3cc
This commit is contained in:
parent
b28b0c70b9
commit
84ac5ae4e7
4 changed files with 11 additions and 44 deletions
|
|
@ -34,6 +34,7 @@ import com.android.net.module.util.IBpfMap;
|
|||
import com.android.net.module.util.IBpfMap.ThrowingBiConsumer;
|
||||
import com.android.net.module.util.SharedLog;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.bpf.Tether4Key;
|
||||
import com.android.net.module.util.bpf.Tether4Value;
|
||||
import com.android.net.module.util.bpf.TetherStatsValue;
|
||||
|
|
@ -43,7 +44,6 @@ import com.android.networkstack.tethering.BpfCoordinator.Ipv6UpstreamRule;
|
|||
import com.android.networkstack.tethering.BpfUtils;
|
||||
import com.android.networkstack.tethering.Tether6Value;
|
||||
import com.android.networkstack.tethering.TetherDownstream6Key;
|
||||
import com.android.networkstack.tethering.TetherLimitValue;
|
||||
import com.android.networkstack.tethering.TetherUpstream6Key;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
|
|
@ -86,7 +86,7 @@ public class BpfCoordinatorShimImpl
|
|||
|
||||
// BPF map of per-interface quota for tethering offload.
|
||||
@Nullable
|
||||
private final IBpfMap<S32, TetherLimitValue> mBpfLimitMap;
|
||||
private final IBpfMap<S32, S64> mBpfLimitMap;
|
||||
|
||||
// BPF map of interface index mapping for XDP.
|
||||
@Nullable
|
||||
|
|
@ -302,7 +302,7 @@ public class BpfCoordinatorShimImpl
|
|||
if (newLimit < rxBytes + txBytes) newLimit = QUOTA_UNLIMITED;
|
||||
|
||||
try {
|
||||
mBpfLimitMap.updateEntry(new S32(ifIndex), new TetherLimitValue(newLimit));
|
||||
mBpfLimitMap.updateEntry(new S32(ifIndex), new S64(newLimit));
|
||||
} catch (ErrnoException e) {
|
||||
mLog.e("Fail to set quota " + quotaBytes + " for interface index " + ifIndex + ": ", e);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ import com.android.net.module.util.InterfaceParams;
|
|||
import com.android.net.module.util.NetworkStackConstants;
|
||||
import com.android.net.module.util.SharedLog;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.bpf.Tether4Key;
|
||||
import com.android.net.module.util.bpf.Tether4Value;
|
||||
import com.android.net.module.util.bpf.TetherStatsValue;
|
||||
|
|
@ -459,11 +460,11 @@ public class BpfCoordinator {
|
|||
}
|
||||
|
||||
/** Get limit BPF map. */
|
||||
@Nullable public IBpfMap<S32, TetherLimitValue> getBpfLimitMap() {
|
||||
@Nullable public IBpfMap<S32, S64> getBpfLimitMap() {
|
||||
if (!isAtLeastS()) return null;
|
||||
try {
|
||||
return new BpfMap<>(TETHER_LIMIT_MAP_PATH,
|
||||
S32.class, TetherLimitValue.class);
|
||||
S32.class, S64.class);
|
||||
} catch (ErrnoException e) {
|
||||
Log.e(TAG, "Cannot create limit map: " + e);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.networkstack.tethering;
|
||||
|
||||
import com.android.net.module.util.Struct;
|
||||
import com.android.net.module.util.Struct.Field;
|
||||
import com.android.net.module.util.Struct.Type;
|
||||
|
||||
/** The value of BpfMap which is used for tethering per-interface limit. */
|
||||
public class TetherLimitValue extends Struct {
|
||||
// Use the signed long variable to store the int64 limit on limit BPF map.
|
||||
// S64 is enough for each interface limit even at 5Gbps for ~468 years.
|
||||
// 2^63 / (5 * 1000 * 1000 * 1000) * 8 / 86400 / 365 = 468.
|
||||
// Note that QUOTA_UNLIMITED (-1) indicates there is no limit.
|
||||
@Field(order = 0, type = Type.S64)
|
||||
public final long limit;
|
||||
|
||||
public TetherLimitValue(final long limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,6 +122,7 @@ import com.android.net.module.util.InterfaceParams;
|
|||
import com.android.net.module.util.NetworkStackConstants;
|
||||
import com.android.net.module.util.SharedLog;
|
||||
import com.android.net.module.util.Struct.S32;
|
||||
import com.android.net.module.util.Struct.S64;
|
||||
import com.android.net.module.util.bpf.Tether4Key;
|
||||
import com.android.net.module.util.bpf.Tether4Value;
|
||||
import com.android.net.module.util.bpf.TetherStatsValue;
|
||||
|
|
@ -481,8 +482,8 @@ public class BpfCoordinatorTest {
|
|||
spy(new TestBpfMap<>(TetherUpstream6Key.class, Tether6Value.class));
|
||||
private final IBpfMap<S32, TetherStatsValue> mBpfStatsMap =
|
||||
spy(new TestBpfMap<>(S32.class, TetherStatsValue.class));
|
||||
private final IBpfMap<S32, TetherLimitValue> mBpfLimitMap =
|
||||
spy(new TestBpfMap<>(S32.class, TetherLimitValue.class));
|
||||
private final IBpfMap<S32, S64> mBpfLimitMap =
|
||||
spy(new TestBpfMap<>(S32.class, S64.class));
|
||||
private final IBpfMap<S32, S32> mBpfDevMap =
|
||||
spy(new TestBpfMap<>(S32.class, S32.class));
|
||||
private final IBpfMap<S32, S32> mBpfErrorMap =
|
||||
|
|
@ -558,7 +559,7 @@ public class BpfCoordinatorTest {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public IBpfMap<S32, TetherLimitValue> getBpfLimitMap() {
|
||||
public IBpfMap<S32, S64> getBpfLimitMap() {
|
||||
return mBpfLimitMap;
|
||||
}
|
||||
|
||||
|
|
@ -932,7 +933,7 @@ public class BpfCoordinatorTest {
|
|||
0L /* txPackets */, 0L /* txBytes */, 0L /* txErrors */));
|
||||
}
|
||||
verifyWithOrder(inOrder, mBpfLimitMap).updateEntry(new S32(ifIndex),
|
||||
new TetherLimitValue(quotaBytes));
|
||||
new S64(quotaBytes));
|
||||
} else {
|
||||
verifyWithOrder(inOrder, mNetd).tetherOffloadSetInterfaceQuota(ifIndex, quotaBytes);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue