Commit Graph

1238 Commits

Author SHA1 Message Date
Patrick Rohr
149868f1b1 Merge "Add public getter for IpPrefix" into main 2023-10-26 18:21:07 +00:00
Maciej Żenczykowski
ad3badf7a8 Merge "move convenience methods from BpfMap to IBpfMap" into main 2023-10-25 22:54:04 +00:00
Patrick Rohr
6f0dc0dc95 Add public getter for IpPrefix
Test: TH
Change-Id: I8d2c8e1a6b76f04257f2137c1ce893b59e52e420
2023-10-25 15:32:06 -07:00
Maciej Żenczykowski
74641d82c4 move convenience methods from BpfMap to IBpfMap
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5f4ee8bdc3aaff1f306a36126e6e812b486e312b
2023-10-25 11:51:40 -07:00
Maciej Żenczykowski
de9d367ab2 remove dead portions of BpfUtils.java
(mostly to improve code coverage)

We can always revert if it ever turns out this is useful,
but I'd prefer for cgroup attach to be a once-at-boot
thing and handled either from bpfloader or the netd updatable
which are both directly C++ code.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I79b5ca8a47388cb6b9189234942e74ab6056aab9
2023-10-25 17:40:35 +00:00
Jean Chalard
4e47533688 Merge "Add a routing coordinator class" into main 2023-10-25 09:13:16 +00:00
Patrick Rohr
49967eab24 Merge changes Idce2024f,I7e009073,I29fe506c,I37b2a0b8,Iccb4e3ec into main
* changes:
  Add toString for more consistent logging to IaPrefixOption
  Create IpPrefix in IaPrefixOption constructor
  Add @Computed annotation to Struct
  Remove check that preferred lifetime >= t2
  Remove IA prefix option option-code from public constructor
2023-10-25 02:14:30 +00:00
Patrick Rohr
8f77f016df Add toString for more consistent logging to IaPrefixOption
toString() approximately follows the format of tcpdump logging ND
options.

Test: TH
Change-Id: Idce2024f44bba5427dc0f88128b87b367c09ccb6
2023-10-24 15:07:14 -07:00
Patrick Rohr
9f03f9e6e5 Create IpPrefix in IaPrefixOption constructor
The constructor is invoked during Struct#parse() at which point we might
as well try to create the IpPrefix object which will be used later. If
this fails for some reason (UnknownHostException or ClassCastException),
the prefix is bogus and should not be used.

Test: TH
Change-Id: I7e0090735022d017ba11aa85266ba19e65807da7
2023-10-24 15:04:19 -07:00
Patrick Rohr
3b2c559149 Add @Computed annotation to Struct
@Computed will ignore "computed" fields from struct parsing. Fields
cannot both be annotated by @Computed and @Field (though there
currently is no check for this).

Test: builds
Change-Id: I29fe506c5e3be4cc50fdaf3a07fc5e922111165b
2023-10-24 15:03:35 -07:00
Patrick Rohr
dc6c70fd5f Remove check that preferred lifetime >= t2
For a single address, DHCPv6 won't work well (i.e. potentially lose provisioning) if
the preferred lifetime is lower than t2. However, this might be a valid
scenario in a renumbering event in the presence of multiple prefixes.

Additionally, in DHCPv6 it is up to the server to configure the client
correctly.

Test: TH
Change-Id: I37b2a0b89deda85b3f7be29c8f02f685aa6e65f8
2023-10-24 11:44:46 -07:00
Chalard Jean
2fb66f1b28 Add a routing coordinator class
Test: In followup changes : RoutingCoordinatorManagerTest
Change-Id: Ia6811d614e02123a072c7638291828745abae051
2023-10-24 22:12:26 +09:00
Junyu Lai
a62eed380c Merge "[BR01.1] Support BpfNetMapsReader" into main 2023-10-24 05:56:33 +00:00
Patrick Rohr
b8af9d5c19 Remove IA prefix option option-code from public constructor
Since it is constant. Struct.parse() still requires a constructor that
includes the code field, so it is marked protected.

Test: TH
Change-Id: Iccb4e3ec4078e0dcc73836f0d1b721146153da50
2023-10-23 14:28:19 -07: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
Chalard Jean
a27dca2fdc Fix arg order to set-package-network-enabled in the CTS preparer
Test: manual
Change-Id: Ife55ed9dc152cd2c21e56b84201b9c34dbb04d46
2023-10-23 17:26:53 +09:00
Jean Chalard
dab9125464 Merge "Reapply "Simplify addRoutesToLocalNetwork calls"" into main 2023-10-21 16:25:58 +00:00
Xiao Ma
26af70f5fe Merge "Add method to check if IA prefix option takes 0 lifetimes." into main 2023-10-20 05:37:26 +00:00
Junyu Lai
155760b57b Dump bpf program status in dumpsys
Sample output:
Bpf Program Status:
  CGROUP_INET_INGRESS: 21
  CGROUP_INET_EGRESS: 22
  CGROUP_INET_SOCK_CREATE: 28
  CGROUP_INET4_BIND: 30
  CGROUP_INET6_BIND: 31

Test: adb shell dumpsys connectivity
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.ConnectivityServiceTest#testDumpDoesNotCrash
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest#testDumpDoesNotCrash
Bug: 292156770
Change-Id: I312c90c524af12d093536156d6d5c6febd64305a
2023-10-18 16:05:55 +08:00
Chalard Jean
7f2b3dabcd Reapply "Simplify addRoutesToLocalNetwork calls"
This reverts commit 316346be6e.

Change-Id: I86977f6e7a5451d037c7ea6fee5c4bc7082935ff
2023-10-18 15:50:02 +09:00
Anton Kulakov
316346be6e Revert "Simplify addRoutesToLocalNetwork calls"
Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: I516d40b20d775e9c61b2f825bc094329d016d0c3
2023-10-13 15:15:50 +00:00
Chalard Jean
cf70df3e9b Simplify addRoutesToLocalNetwork calls
There are only three calls to this method, and two of them
are with a list of 1 address which means it's simpler inlined.

The last call will be replaced with calls to RouteController
in a followup, meaning we addRoutesToLocalNetwork can be removed.

Test: RouterAdvertisementDaemonTest
      NetdUtilsTest
Change-Id: I3b6ee1db40f09954b336321000735a66306bf000
2023-10-13 16:19:25 +09:00
Xiao Ma
cc9b86c647 Add method to check if IA prefix option takes 0 lifetimes.
Bug: 260934173
Test: TH
Change-Id: If49a888198a52bf0cfefc125e0aa9636c1692279
2023-10-12 23:36:59 +09:00
Chalard Jean
d6f4efb1a8 Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0
2023-10-12 13:30:49 +09:00
Xiao Ma
a1eb2e453f Merge "Move the delegated prefix validity check to IaPrefixOption class." into main 2023-10-10 03:27:35 +00:00
Xiao Ma
fac8a33763 Move the delegated prefix validity check to IaPrefixOption class.
Bug: 260934173
Test: TH
Change-Id: Idc6e32f8dbaf3b0e3c57eff496a006fafee02b5e
2023-10-08 14:33:25 +09:00
Maciej Żenczykowski
3a64568abb type safety for kernel version
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If05c0c5383dceeb65964143f5574d2ee1a484907
2023-10-06 15:54:38 -07:00
Maciej Żenczykowski
6dec6e9374 type safety for bool ignore_on_{eng,user,userdebug}
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia85e16d1a7f8d1b21e4ce4c306db6bbea06138e0
2023-10-06 14:57:12 -07:00
Maciej Żenczykowski
f2466ef4bb type safety for bool optional
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6f10395ca6f1c73f3513031f561fdf1b1dedf451
2023-10-06 14:48:43 -07:00
Maciej Żenczykowski
a262bd3d1e type safety for bool shared
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4883eab734f47522fec718f0709475f7e6dd0a53
2023-10-06 14:46:11 -07:00
Maciej Żenczykowski
10da6d4e61 move PRIVATE/SHARED/MANDATORY/OPTIONAL/{LOAD,IGNORE}_ON_* into core headers
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7053ab46e73b763f64f36baf5e7ab64b62421045
2023-10-06 14:25:41 -07:00
Maciej Żenczykowski
1e32277fff BpfClassic.h - add missing commas
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ife32fa36808de13c5f37ace497395dcc381ca336
2023-10-06 13:50:13 -07:00
Maciej Żenczykowski
d5bf2061f3 more classic bpf macros
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5c7fd55301cd5aa44502f8481923c86bc49ea914
2023-10-04 22:41:21 +00:00
Maciej Żenczykowski
f24beefe55 TcUtils jni: jobject clazz -> jclass clazz
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0a06d2627ef06fe4606b3d1a6525af767d218945
2023-10-04 19:15:53 +00:00
Maciej Żenczykowski
b0f8d31e7d BpfUtils jni: jobject clazz -> jclass clazz
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3fd51ad129873782b74c7c47b50e16f1f1f0fa6e
2023-10-04 19:15:44 +00:00
Maciej Żenczykowski
85ac050b35 bpf jni: add native_getProgramIdFromCgroup
Test: TreeHugger
Bug: 292156770
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib7b194b9cbf6519f9fbcfd1fcefcbe5d825f5c3a
2023-10-04 19:14:43 +00:00
Maciej Żenczykowski
340e2ff355 BpfSyscallWrappers: add queryProgram()
Test: TreeHugger
Bug: 292156770
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0f77220a6c4b13efb5630d7a5ade1db39c59901e
2023-10-04 19:12:25 +00:00
Motomu Utsumi
30ef5308d6 Merge "Remove lint-baseline in staticlibs" into main 2023-10-04 06:45:02 +00:00
Treehugger Robot
a675e966b2 Merge "Remove defaultEnabled arg from isNetworkStackFeatureEnabled" into main 2023-10-03 11:51:32 +00:00
Maciej Żenczykowski
73df7414f1 BpfClassic.h - more helpers
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie0eb8895c2d887b71ba886735ad106c1118ebeac
2023-10-02 20:03:41 +00:00
Maciej Żenczykowski
b900201ffe rename BPF2_REJECT_IF_ANY_BITS_SET -> BPF2_REJECT_IF_ANY_MASKED_BITS_SET
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I54a189f0f7b73917aa3fd049fe2eca387aaca250
2023-10-02 16:09:05 +00:00
Treehugger Robot
f74f42b4c0 Merge "Add method to read trunk stable flag" into main 2023-10-02 13:17:53 +00:00
Motomu Utsumi
b0f489021b Add method to read trunk stable flag
aconfig soong modules should be used to read the trunk stable flag.
However they are not available in the mainline branch.
So this CL adds the method to check if the trunk stable flag is enabled
or not by directly reading from DeviceConfig.
It's expected that this does not work correctly if flag value is not
stored in the DeviceConfig.
But for the time being, this method can be used to keep development.
Once the mainline branch supports the aconfig soong modules, method
added by this CL must be removed and java_aconfig_library should be
used instead.

Test: adb shell device_config put android_core_networking \
Test: com.android.net.flags.test_feature true
Test: Compares the value from java_aconfig_library and DeviceConfigUtils
Change-Id: I8e35b33a3201192e940e88f96aad3b2b6685b046
2023-10-02 19:34:01 +09:00
Chalard Jean
2aa4412503 Address comments on aosp/2765367
Test: comment-only change
Change-Id: I788f6e9f5fdd913d4c5077b6bb82c19664d3cd3f
2023-09-29 15:48:09 +09:00
Jean Chalard
1d600f4300 Merge changes Ifd7abd8a,I39cab8ff,I6b3270d6,Ia28c6abc,If47d7e23 into main
* changes:
  Move the MULTI_SIM_ACTION receiver inline
  Inline registerForCarrierChanges
  Make mThread a local
  Introduce a flag for using the carrier service changed callbacks.
  Have DevSdkIgnoreRunner support @Parameterized parameters
2023-09-29 06:46:08 +00:00
Xiao Ma
f45ec2858a Merge "Exclude testGetNeighborsQuery from NetworkStackCoverageTests." into main 2023-09-29 05:42:16 +00:00
Xiao Ma
998f6b0eda Exclude testGetNeighborsQuery from NetworkStackCoverageTests.
sepolicy gates RTM_GETNEIGH{TBL} with a new permission nlmsg_getneigh
and block access from untrusted_apps, but NetworkStackCoverageTests
uses the same UID with NetworkStack module, so it still has the
permission to send RTM_GETNEIGH(context: u:r:network_stack:s0<00>),
which causes the test always fails. Add the same assumeFalse check
for tests with network_stack context.

Bug: 283346574
Test: atest NetworkStackCoverageTests
Change-Id: Iaf652841bb9868783c924aa22fdf0c4f07e1e391
2023-09-29 12:26:49 +09:00
Maciej Żenczykowski
d58042e0d4 Merge "reverse BpfMap & BpfMapRO inheritence to make sense" into main 2023-09-29 03:24:37 +00:00
Maciej Żenczykowski
7e2f53e762 reverse BpfMap & BpfMapRO inheritence to make sense
Bug: 235590615
Bug: 235907076
Bug: 286003437
Test: TreeHugger, m droid gpuservice_unittest libtimeinstate_test bpf_benchmark bpf_module_test libbpf_load_test && mma
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I020a898fe8b257040a100f146654d4a04b19f843
2023-09-29 00:44:33 +00:00
Chalard Jean
a10ae005df Have DevSdkIgnoreRunner support @Parameterized parameters
Test: aosp/2405723 uses this, TH is happy with existing tests
Change-Id: If47d7e239d8483716fb78a97bbc2da4e24731209
2023-09-28 21:37:31 +09:00