Commit Graph

34 Commits

Author SHA1 Message Date
Maciej Żenczykowski
2c337c22b6 Merge "Add java class for Ingress discard bpf map key value" into main am: 8bc6ee5b7a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2795708

Change-Id: Ife0df1d8a10d760dfab8989c7eb69ab3203307a5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-27 19:47:18 +00:00
Motomu Utsumi
d4fe2c3a50 Add java class for Ingress discard bpf map key value
Bug: 295800201
Test: TH
Change-Id: Ic9ac423aee2a8fb9709b0acf012ec57cdfa019f9
2023-10-26 15:48:22 +09:00
Junyu Lai
bfd5e9d274 Merge "Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."" into main am: 0cfaea8d98
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2801074

Change-Id: Idf9003f52a119033cd76cde87b6becf70fa03f15
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-25 02:28:36 +00:00
Junyu Lai
0cfaea8d98 Merge "Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."" into main 2023-10-25 01:59:12 +00:00
Junyu Lai
df210365fe Revert "Revert "[BR07.1] Expose setDataSaverEnabled from Connect..."
Revert submission 2799494-revert-2745215-npmsbpf-OBOPDXREUI

Reason for revert: Need to 1. Merge API first. 2. Wait for prebuilt. 3. Merge the caller.

Reverted changes: /q/submissionid:2799494-revert-2745215-npmsbpf-OBOPDXREUI

Change-Id: Icd5f3d40595a0d2a221b016cec70568bf3597c16
2023-10-24 07:30:23 +00:00
Junyu Lai
8f1730ebf9 Merge "[BR01.1] Support BpfNetMapsReader" into main am: a62eed380c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2725213

Change-Id: I0a9955e7fa9d51b423f8cd1113553dd492caf843
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-24 06:19:04 +00:00
Jordan Silva
842bdb6564 Merge "Revert "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager"" into main am: 118c2646f3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2799494

Change-Id: Ifcb1c1db20028880aaa192db5827d98253f8c7c8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-23 15:34:59 +00:00
Jordan Silva
457ae0f00f Revert "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager"
Revert submission 2745215-npmsbpf

DroidMonitor: Potential culprit for Bug 307256512 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.


Reason for revert: 307256512

Reverted changes: /q/submissionid:2745215-npmsbpf

Change-Id: I27119a7484453d1369bbdf71ad2479edec7d664f
2023-10-23 13:23:01 +00:00
Junyu Lai
626045a601 [BR01.1] Support BpfNetMapsReader
A helper class to *read* java BpfMaps. This is designed to
provide direct bpf access in the caller process through
ConnectivityManager APIs.

The change also removes any statical link to
net-utils-device-common-struct from service-connectivity.
This is because net-utils-device-common-struct is already
included in framework-connectivity. Including it again in
service-connectivity would create a r8 build fail by circular
dependency.

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.StructTest
Test: atest FrameworksNetTests:android.net.connectivity.android.net.BpfNetMapsReaderTest
Bug: 297836825
Change-Id: I7a6d2eb816d0dc7343167bddd672806b199f44fe
2023-10-23 20:11:02 +08:00
Junyu Lai
ee6724e314 Merge "[BR07.1] Expose setDataSaverEnabled from ConnectivityManager" into main am: d88205a1ae
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2745215

Change-Id: Ic4b0a41f288398a5334377d5aaab40f3fe0ef07a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-23 11:43:33 +00:00
Junyu Lai
c279f1830e [BR07.1] Expose setDataSaverEnabled from ConnectivityManager
Currently, data saver switch is controlled in NPMS, which
calls into NetworkManagementService and netd when switching
status. In netd, BandwidthController manipulates the
bw_data_saver chain to control the overall behavior.

However, this code are all platform implementation, which
are not updatable. In order to migrate data saver switch
from iptables to bpf, this API is needed for Connectivity to
change the implementation to directly write bpf in later
patches.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideRestrictBackgroundNetworkTests
Test: atest FrameworksServicesTests:NetworkManagementServiceTest
Bug: 297836825
Change-Id: I71fa41ca739fef8e191fba91b02758ad5f732d5c
2023-10-19 17:43:44 +08:00
Paul Hu
0a9fc24345 Merge "Add expired services removal flag" into main am: 322a322687
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2788017

Change-Id: I59fd7682b000d1510f9c5587622dc685492e7fd3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-19 06:46:44 +00:00
Paul Hu
f3fe3333d3 Add expired services removal flag
The TTL check and removal of expired services is currently only
performed when a mDNS query is sent. This can result in expired
services remaining in the cache if no queries are sent. To
address this, the remaining TTL will be checked when retrieving
services from the MdnsServiceCache. Add a new flag to enable
the expired services removal feature. This feature will be
implemented in subsequent changes.

Bug: 265787401
Bug: 304649384
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I30f0eea568ee45d363cc02821de0921d6040f981
2023-10-18 17:48:46 +08:00
Jean Chalard
de72505109 Merge changes Ibb8d33b7,Ie168fe1f,I9f699b63 into main am: 02193c0cce
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2775660

Change-Id: I08e845ac61b6e37e88eacc3f48964742da708b61
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-10-12 02:48:04 +00:00
Treehugger Robot
4a01efa882 Merge "Add TrunkStable.bp" into udc-mainline-prod 2023-10-11 10:13:40 +00:00
Chalard Jean
cf7dbcae41 Prepare exposing Network{Request,Caps}.forbiddenCapabilities
This is useful going forward in particular because there will
be a default forbidden capability for LOCAL_NETWORKS. This
means it will be useful to be able to remove it.

It is also generally useful and we have been wanting to open
this API to the public, so this is a good opportunity to do so.

Test: new tests for NetworkRequest
      NetworkCapabilitiesTest already has tests because it
      already was @SystemApi
Change-Id: Ibb8d33b799f2d274326fd9cd0b05a2c33a18032a
2023-10-11 17:02:52 +09:00
Motomu Utsumi
d590d88294 Add TrunkStable.bp
All the branches except udc-mainline-prod have TrunkStable.bp.
So this CL adds this file to avoid conflicts.
TrunkStable.bp is not included by Android.bp in udc-mainline-prod.
So, this CL is a no-op.

AOSP-first: TrunkStable.bp exists in aosp
Test: TH
Merged-In: Ib69d2fdc1d73b36a08a3d8ae1f2c45b2bcffae64

Change-Id: Ib3fe0774086ab5531f0e4d776da23667d32daad4
2023-10-11 06:56:09 +00:00
Motomu Utsumi
e63d38ff37 Add aconfig_declarations for flags in android_core_networking
Add aconfig_declarations so that platform code can use this flag.
Following CLs(aosp/2606670) use this flag to sync the mainline behavior
change and platform behavior change.
Having merged-in to avoid being merged to udc-mainline-prod where
aconfig soong targets are not supported

Bug: 267870186
Test: TH
Merged-In: I4870fbe882ce0ec995dcaeb8a2624071fee6dce7
Change-Id: I2260dc3d60689da9328fe4f98c3f3048d96bbf6d
2023-10-06 20:10:20 +09:00
Motomu Utsumi
dca83676dd Add aconfig flag file
This CL does not have Merged-In since all the branches should have the
aconfig file so that adding flags to the file does not have conflicts.
Following CL adds aconfig_declarations to Android.bp only on branches
where aconfig soong targets are supported

Bug: 267870186
Test: TH
Change-Id: I621228a2c9594bf7bfe1cf335619c417e9339743
2023-10-06 10:51:23 +09:00
Maciej Żenczykowski
3fa9dceabc Connectivity: bump min sdk 29(Q) to 30(R)
Mainline push to Q was stopped in February 2023.

Test: TreeHugger
Bug: 283996141
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic645cce4df5780cdd62eda4e8c596396c2f83b25
2023-06-15 00:22:48 +00:00
Cole Faust
22f05839f5 Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:

BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower

See https://errorprone.info/bugpatterns for more
information on the checks.

Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I7625fa386afe93823b97cb2ecb8fd09a5856c05b
2022-11-02 10:13:14 -07:00
Maciej Żenczykowski
0ba23a5ac8 CookieTagMapValue.java - uid U32 -> S32
The kernel is actually not consistent in whether uids & gids
are signed or unsigned, and neither is our Java code, which
also commonly uses just 'int' for uid.  In practice values
greater or equal to 2**31 often don't quite work right.
For example icmp sockets are enabled via a sysctl that
takes a minimum and maximum gid - and these are signed int32s.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6576798cfeb52bf5574bf6853f0f7378022b3a2f
2022-09-17 01:53:47 +00:00
Maciej Żenczykowski
e1e03ea435 Merge "ClatEgress4Value.java - replace U32 ifindex with S32" 2022-09-16 17:58:32 +00:00
Maciej Żenczykowski
53a5c00d41 Merge "ClatEgress4Key.java - replace U32 ifindex with S32" 2022-09-16 17:54:30 +00:00
Maciej Żenczykowski
6dbae5ceef Merge changes I9008e20f,I96403646,Ic05adfc4
* changes:
  ClatIngress6Key.java - replace U32 ifindex with S32
  TetherStatsKey.java - replace U32 ifindex with S32
  handle "TODO: remove equals/hashCode/toString once aosp/1536721 merged"
2022-09-16 17:52:14 +00:00
Maciej Żenczykowski
def4359b85 ClatEgress4Value.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9c157a57278dcd43b464c853d1107a933c1fd8df
2022-09-16 06:57:45 +00:00
Maciej Żenczykowski
b62de2887b ClatIngress6Value.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iab2d4a13bf7ba45bbe8627adfdfb830f3219bc7b
2022-09-16 06:57:40 +00:00
Maciej Żenczykowski
5d034e7f7a ClatEgress4Key.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Surprisingly it appears no further fixups are required
to make this compile, due to other places already being 'int's.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5a48f12e0fc6274debf645a087f5f3857d90be62
2022-09-16 06:40:07 +00:00
Maciej Żenczykowski
b56f69c600 ClatIngress6Key.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Surprisingly it appears no further fixups are required
to make this compile, due to other places already being 'int's.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9008e20f40c983a1bb8a0547a61190f28042b22a
2022-09-16 06:39:57 +00:00
Maciej Żenczykowski
fb8e40eaed TetherStatsKey.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I964036469fe7e0cfa77d9b062bfdbf5d2ae99bf2
2022-09-16 06:36:57 +00:00
Maciej Żenczykowski
49e9660e0e handle "TODO: remove equals/hashCode/toString once aosp/1536721 merged"
aosp/1536721 is merged, so this code duplication should not be needed any more.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic05adfc46495086d7f681322aac7acddc30a2260
2022-09-16 06:35:32 +00:00
Maciej Żenczykowski
09813ced3e replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbb7139e9118dd2d0c52e83c5874132e03760b30
2022-08-18 01:07:11 +00:00
Hungming Chen
ef0280288e Move struct CookieTagMap{Key, Value} to Connectivity/common
Need to share struct CookieTagMap{Key, Value} with:
service/src/com/android/server/connectivity/ClatCoordinator.java
service-t/src/com/android/server/net/NetworkStatsService.java
tests/unit/java/com/android/server/connectivity/ClatCoordinatorTest.java
tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java

These files only have different package name as expected.

$ diff common/src/com/android/net/module/util/bpf/CookieTagMapKey.java service-t/src/com/android/server/net/CookieTagMapKey.java
  17c17
  <- package com.android.net.module.util.bpf;
  ---
  -> package com.android.server.net;

$ diff common/src/com/android/net/module/util/bpf/CookieTagMapValue.java service-t/src/com/android/server/net/CookieTagMapValue.java
  17c17
  <- package com.android.net.module.util.bpf;
  ---
  -> package com.android.server.net;

Bug: 237369591
Test: atest ConnectivityCoverageTests
Change-Id: Ibede81376382f0dd7a032c8c988dd84c7422eece
2022-07-23 03:18:55 +08:00
Hungming Chen
01f2550ac4 Move struct {Clat*, Tether4*, TetherStats*} to connectivity module
Needed because these struct classes should not be exposed.
Only used for the connectivity module and its tests.

Bug: 234160319
Test: atest ConnectivityCoverageTests

The moved files are identical.

diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatIngress6Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatIngress6Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatIngress6Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatIngress6Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/Tether4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/Tether4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/TetherStatsKey.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsKey.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/TetherStatsValue.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsValue.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Key.java
(no diff)

Change-Id: I4ce8045150bdbf04c63c5262c58a0ebcc30d395c
2022-06-29 11:34:19 +00:00