Commit Graph

245 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
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
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
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
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
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