Commit Graph

232 Commits

Author SHA1 Message Date
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
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
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
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
Motomu Utsumi
2359e7b554 Remove defaultEnabled arg from isNetworkStackFeatureEnabled
Test: NetworkStaticLibsTests
Bug: 279108992
Change-Id: Id5409158fd720efc92e1b39678e636a8a7d5a0a5
2023-09-27 17:39:31 +09:00
Motomu Utsumi
ed4e7ec954 Update the logic of isFeatureEnabled and isFeatureNotChickenedOut
If the flag value is unset or 0, isFeatureEnabled return false and
isFeatureNotChickenedOut return true.
If the flag value is -1 (force disable), both return false.
If the flag value is other values, both query the package version and
return `flagValue <= packageVersion`

Now the only difference is a default behavior when the flag is not set
or 0.
So isFeatureEnabled and isFeatureNotChickenedOut can use the same flag.

This CL also fixes the issue in rollback.
Before this CL, isFeatureNotChickenedOut did not check the module
version and could have a issue if there is a rollback.

Test: NetworkStaticLibsTests
Bug: 279108992
Change-Id: I12d6ebadff3aee7b7c614aca4eb0a34ef0db9857
2023-09-27 17:30:01 +09:00
Motomu Utsumi
195a30f02e Remove lint-baseline in staticlibs
Bug: 300384860
Test: TH
Change-Id: Ic26efebc24b3f7030b6ff66579fc0f5e5d019d5f
2023-09-27 17:24:30 +09:00
Motomu Utsumi
daae5ca53d Merge "Rename to isNetworkStackFeatureEnabled" into main 2023-09-08 09:27:13 +00:00
Motomu Utsumi
958ee15299 Merge "Remove unnecessary arguments from isTetheringFeatureEnabled" into main 2023-09-08 09:24:57 +00:00
Xiao Ma
e129bc5958 Merge "Add IA Address option struct." into main 2023-09-07 08:43:12 +00:00
Xiao Ma
af996bec47 Merge "Remove the VisibleForTesting annotation on IaPrefixOption constructor." into main 2023-09-07 08:18:23 +00:00
Motomu Utsumi
e323c1db81 Rename to isNetworkStackFeatureEnabled
DeviceConfigUtils had isFeatureEnabled for NetworkStack and Tethering
which were confusing since the difference was only the arguments.
This CL renames isFeatureEnabled for NetworkStack module to
isNetworkStackFeatureEnabled to avoid confusion.

This CL also removes unnecessary arguments.

Bug: 279108992
Test: m
Change-Id: I523b98bd3754c209c64ce7d1513b5afcb36599b9
2023-09-05 17:50:24 +09:00
Motomu Utsumi
6a22207190 Remove unnecessary arguments from isTetheringFeatureEnabled
Test: m
Bug: 279108992
Change-Id: Iadc1b4665c364bf754ed32e7bb53b78e555ed457
2023-09-05 17:50:15 +09:00
Xiao Ma
9209b00164 Add isNetworkStackFeatureNotChickenedOut API for NetworkStack module.
Bug: 279108992
Test: atest NetworkStaticLibsTests
Change-Id: If42eb401b812017bd4d724b4323a8d51f7430606
2023-08-28 17:52:04 +09:00
Yuyang Huang
62a016e514 Merge "Move ArpPacket.java to frameworks/libs/net" into main 2023-08-24 07:12:27 +00:00
Yuyang Huang
6acc55e129 Move ArpPacket.java to frameworks/libs/net
Bug: 281639507
Test: TH
Change-Id: Ic0d273695d3f0f85a0ec56337a9d12d77b60ea3b
2023-08-24 12:48:02 +09:00
Maciej Żenczykowski
82ae7ff289 Merge "BpfMap.java - remove getNextRawKey()" into main 2023-08-21 17:15:32 +00:00
Maciej Żenczykowski
4ed5e9e497 Merge "BpfMap.java - remove getRawValue()" into main 2023-08-21 17:15:14 +00:00
Motomu Utsumi
656c77f4f0 Merge "Rename to isTetheringFeatureEnabled" into main 2023-08-21 03:17:38 +00:00
Chiachang Wang
bdbcc0cc30 Merge "Address review comments in aosp/2677976" into main 2023-08-21 02:34:01 +00:00
Maciej Żenczykowski
b6a23b1504 BpfMap.java - remove getRawValue()
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6903a29773ee4782c0f2ae64561e1c0fdcba618f
2023-08-20 14:05:43 +00:00
Maciej Żenczykowski
2c87b82603 BpfMap.java - remove getNextRawKey()
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ida62d346c1d6df800b5d45b67de60e945ac2b4c8
2023-08-20 13:01:13 +00:00
chiachangwang
3b64739d81 Address review comments in aosp/2677976
This commit address the follow-up review comments
in aosp/2677976.

Fix: 296150560
Test: atest FrameworksNetTests NetworkStaticLibTests
Change-Id: I0ff4cef8585e2ae496447c4d37e072c1de281775
2023-08-18 08:13:27 +00:00
Motomu Utsumi
c046ac418e Rename to isTetheringFeatureEnabled
DeviceConfigUtils has isFeatureEnabled for NetworkStack and Tethering
which were confusing since the difference was only the arguments.
This CL renames isFeatureEnabled for Tethering module to
isTetheringFeatureEnabled to avoid confusion.

Bug: 279108992
Test: m
Change-Id: I16e8e4f6c0080d73533ce8bd36adfa7038347500
2023-08-17 19:00:22 +09:00
Motomu Utsumi
aad6281844 Rename to isTetheringFeatureNotChickenedOut
Expected use case of isTetheringFeatureForceDisabled was
`enabled = !isTetheringFeatureForceDisabled`, which is error prune.
So this CL renames to isTetheringFeatureNotChickenedOut and updates to
return true if the feature is not disabled.
If the feature is enabled by default and disabled by flag push (kill
switch), isTetheringFeatureNotChickenedOut should be used.

Bug: 279108992
Test: m
Change-Id: I5f85c24032bae298831bbf042874a63ea2c9b75f
2023-08-17 02:18:22 +00:00
Xiao Ma
a3f942de44 Add IA Address option struct.
Bug: 293393743
Test: m
Change-Id: Id4ab164579a95b87fa8a8d1d00447c6a3bd394d5
2023-08-12 16:38:06 +09:00
Xiao Ma
79f5dc6b4d Remove the VisibleForTesting annotation on IaPrefixOption constructor.
Fix AndroidLint warning in aosp/2691418.

Bug: 260934173
Test: TH
Change-Id: Idfaff1342931d6c3ebfd3aa2fea02ab3ed5bb6f1
2023-08-11 15:53:49 +09:00
Yuyang Huang
783d4fb4f6 Add helpers method to SharedLog
Bug: 294326360
Test: atest FrameworksNetTests
Change-Id: Ib8ba3e9a556a70de28813465396c6609b7c22333
2023-08-06 17:34:58 +09:00
Chiachang Wang
cc5c2a648a Merge "Add isFeatureSupported and isTetheringFeatureForceDisabled methods" into main 2023-08-03 06:58:28 +00:00
Chiachang Wang
f870ae3120 Merge "Add resolvePkgPrefix() method" into main 2023-08-03 06:58:20 +00:00
chiachangwang
1637730010 Add isFeatureSupported and isTetheringFeatureForceDisabled methods
Add isFeatureSupported helper method to check whether
a specific feature is supported. This is useful when a specific
module version is required on a cross module feature, e.g.
a connectivity feauture requires to work with a older
networkstack module.

This commit also adds isTetheringFeatureForceDisabled() method
as a method that refers to DeviceConfig which can be controlled
to explicitly disabled.

Bug: 291870956
Test: atest FrameworksNetTests NetworkStaticLibTests
Change-Id: I511d00663e2378c36b4ca017db4b88d88f650852
2023-08-02 13:12:14 +00:00
Remi NGUYEN VAN
fa33ba6f3d Merge "Add DomainsUtils class to encode/decode domain names." into main 2023-08-02 00:58:40 +00:00
chiachangwang
9835a4eae0 Add resolvePkgPrefix() method
This is a no-op refactor change to create resolvePkgPrefix()
helper method to prevent code duplication for the follow up
commit.

Bug: 291870956
Test: atest NetworkStaticLibTests
Change-Id: I8deea97acdb793dfa076ce55f7f2c3eb0b224461
2023-07-31 14:01:24 +00:00
Xiao Ma
80dbd06f64 Add Ipv6PktInfo (in6_pktinfo) struct.
in6_pktinfo structure specifies the source IPv6 address and interface
for an outgoing packet(used with UDP or RAW socket), we can specify the
IPV6_PKTINFO ancillary data on sendmsg() with this structure to set the
source address (e.g. a global IPv6 address).

Bug: 293393743
Test: TH
Change-Id: I2bd8ea6fcdb7398db9b3a54243c81ca27e832e45
2023-07-27 15:17:24 +09:00
fqjc86
48693a994a Add DomainsUtils class to encode/decode domain names.
Both encode and deocde methods support message compression which is
described in RFC1035 section 4.1.4. We can leverage both methods in
a follow-up CL to parse DHCPv4 option 119 and DNSSL RA option.

This cl also adds maxLabelCount argument for DnsRecordParser#parseName
to prevent the potential recursion from overflowing the stack.

Bug: 189865016
Test: atest NetworkStaticLibTests
Change-Id: I90101ecda64bfecb0233e80ea93c91c204fbf176
2023-07-25 18:29:23 +05:30
Xiao Ma
72b0cd986a Add RouteInformation option Struct.
This structure is useful when building an RA with RIO for integration
tests and verify the device's provisioning behavior, for example, check
if devices in ULA networks can recover its IPv6 connectivity from
receiving a normal RA after losing IPv6 default route (e.g. received RA
with zero router lifetime).

Bug: 183601771
Test: m
Change-Id: I13b85000ea1633f56edc74e3d62b7a38b9a851bf
2023-07-24 12:51:01 +09:00
Maciej Żenczykowski
28a8600dc0 Merge "Move ticksToMilliSeconds to NetlinkUtils." into main 2023-07-20 12:02:48 +00:00
Xiao Ma
a56b949726 Move ticksToMilliSeconds to NetlinkUtils.
ticksToMilliSeconds is used to convert the clock ticks to milliseconds,
move it to a common utils class, we can call this method to convert the
rta_cacheinfo.rta_expires in user space as well to get when the default
route will expire.

Bug: 183601771
Test: atest NetworkStaticLibTests
Change-Id: Iabd510fe290f835a8fe690d91921d5b706a23b56
2023-07-20 16:54:46 +09:00
fqjc86
cece401526 Add DomainsUtils class to encode/decode domain names.
Both encode and deocde methods support message compression which is
described in RFC1035 section 4.1.4. We can leverage both methods in
a follow-up CL to parse DHCPv4 option 119 and DNSSL RA option.

This cl also adds maxLabelCount argument for DnsRecordParser#parseName
to prevent the potential recursion from overflowing the stack.

Bug: 189865016
Test: atest NetworkStaticLibTests
Change-Id: I624649c224f141848a475ac85c56012d138c5224
2023-07-11 18:04:18 +09:00
Motomu Utsumi
2ba922ad85 Use default package version in isFeatureEnabled if package is not found
Bug: 287359634
Bug: 289173013
Test: atest HostsideVpnTests
Change-Id: I379cde0391f96a8ac5dcdb2ff7723ea950684e36
2023-07-07 15:57:58 +09:00
Xiao Ma
723515738d Add a method helper to create RTM_DELADDR message in user space.
Bug: 260934173
Bug: 263222068
Test: atest NetworkStaticLibTests
Change-Id: Ibddaed91b12d3f27778d0bd2171bc5be38ff8bda
2023-06-30 23:52:23 +09:00
Xiao Ma
3a4ad37d61 Remove StructIfaddrMsg ctor VisibleForTesting annotation.
This allows other class to refer StructIfaddrMsg constructor as well,
otherwise, the default visibility is private.

Bug: 263222068
Test: atest NetworkStaticLibTests
Change-Id: If571b014ade51e3387748a4df0abcb49b59cb462
2023-06-30 23:48:27 +09:00
Xiao Ma
34ab408ade Parse rta_cacheinfo structure in RtNetlinkRouteMessage.
Bug: 183601771
Test: atest NetworkStaticLibTests
Change-Id: I9ea55ad297f5183853eeaa2e53f2406d79a90a20
2023-06-22 10:37:39 +09:00
Xiao Ma
4cb10fdc28 Add netlink rta_cacheinfo structure.
Bug: 183601771
Test: m
Change-Id: Iaa65425fa875a9dde4d4b7c1b110d9a2a406f444
2023-06-22 10:37:27 +09:00
Xiao Ma
789baf20d3 Make IaPrefixOption constructor public.
Then we can create an IaPrefixOption instance via constructor in the
NetworkStackIntegration test.

Bug: 260934173
Test: atest NetworkStackIntegrationTests
Change-Id: I05be1dde6ba5bda125631674c5c0f8634eb18924
2023-06-09 11:38:11 +09:00
Xiao Ma
a6fba08f82 Add a helper function to send RTM_NEWADDR netlink message to kernel.
Bug: 260934173
Test: TH
Change-Id: I6e9100e6f04a85550790c90fb0fde8d839e74578
2023-06-01 11:02:05 +09:00
Motomu Utsumi
a0a78d3ca5 Merge "Add logs for target uids and duration to destroyLiveTcpSockets" 2023-05-23 02:19:24 +00:00
Motomu Utsumi
78cc19e25a Add logs for target uids and duration to destroyLiveTcpSockets
destroyLiveTcpSockets APIs are replacement of socketDestroy in
NetdNativeService which has logging for target uids and duration.
Logging them would be useful in debug.
So adding equivalent logging to destroyLiveTcpSockets APIs.

Test: atest com.android.cts.net.HostsideVpnTests#testSocketClosed
Test: atest ConnectivityManagerTest#testFirewallCloseSocketDenylistChainDeny
Bug: 270298713
Change-Id: I347d010541656c92a64029b1474fae601d6e5659
2023-05-23 02:19:11 +00:00