Commit Graph

1258 Commits

Author SHA1 Message Date
Mike Yu
d97fdbb3bc Merge changes from topic "dns_svcb" into main
* changes:
  Add tests for DnsSvcbRecord and DnsSvcbPacket
  Add DnsSvcbPacket
  Add DnsSvcbRecord
2023-11-09 05:24:17 +00:00
Maciej Żenczykowski
0ad252e03c BpfMap.h - simplify error returns
Returning the number of the file descriptor isn't actually useful since
it doesn't really tell you anything once the program has terminated.
(most logs we look at are long after the fact)

However, it does involve a fair bit of string processing to generate
the errors.  This is particularly an issue for things we constantly
call and sometimes expect to fail.  For example it is normal for
getNextKey() to fail with ENOENT at the end of iteration...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib94037440b5fcaa34cc8aa01b165431efabeb377
2023-11-08 18:36:42 -08:00
Mike Yu
f5032571a8 Add tests for DnsSvcbRecord and DnsSvcbPacket
This change adds the test coverage for DnsSvcbRecord
and DnsSvcbPacket.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: I0b6328337fd61c5ac2e5f6b3737238f7d678245a
2023-11-09 02:14:29 +00:00
Mike Yu
8404b3c93e Add DnsSvcbPacket
DnsSvcbPacket will be used to parse DNS packet of type SVCB.

Bug: 240259333
Test: will add some tests in a follow-up change
Change-Id: Icb13d50f2d95a898b3b7ea373db876f41690723a
2023-11-09 02:14:29 +00:00
Mike Yu
9b96c83238 Add DnsSvcbRecord
This change is an initial implementation of DNS SVCB Record. It
can parse an SVCB Record in wire format.

The RDATA field of a SVCB Record is formatted as follows:
- SvcPriority: 2-byte field
- TargetName: a domain name that follows RFC1035 section 5.1
- SvcParams (optional): a list of SvcParam

This initial implementation focuses on the SvcParams related to DDR,
including alpn, port, ipv4hint, ipv6hint, and dohpath. For the other
SvcParams, such as mandatory and ech, this change doesn't check
whether their value is valid.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Test: No test for DnsSvcbRecord for now. will add some tests in a
      follow-up change
Change-Id: Icfe9b623eda8390c40b106123a718cdd2af3af99
2023-11-09 02:14:29 +00:00
Chalard Jean
22350c93b4 Add LocalNetworkInfo and send callbacks when it changes
Test: CSLocalAgentTest
Change-Id: I8caca97b891081f9212a01d428a34ed1a08d5126
2023-11-07 17:29:38 +09:00
Junyu Lai
092839a6b5 Merge changes from topic "apipluscts" into main
* changes:
  [BR03.3] Add feature version constant for accessing bpf in Connectivity
  [BR03.1] Expose isUidNetworkingBlocked
2023-11-06 09:09:03 +00:00
Junyu Lai
ec5500de79 [BR03.3] Add feature version constant for accessing bpf in Connectivity
This is needed by the callers to determine if the Tethering
module is new enough to support the API that get whether
the network is blocked for the given uid and conditions.

Test: adb shell cmd network_stack is-uid-networking-blocked <uid> <metered>
Bug: 297836825
Change-Id: Ie79eacb1e63ff60291ad4f0ef6e8bba5ab0bdb07
2023-11-06 14:51:01 +08:00
Chiachang Wang
95cf7f9550 Merge "Rename method connectSocketToNetlink to connectToKernel" into main 2023-11-06 05:25:46 +00:00
Chiachang Wang
fe84f59ff0 Rename method connectSocketToNetlink to connectToKernel
Address leftover comments in aosp/2354202.

Bug: 265877161
Test: atest FrameworksNetTests NetworkStackTests
Change-Id: I77f36b890265e9af6f5ab866d5e0071363bb3d0f
2023-11-06 03:18:18 +00:00
Maciej Żenczykowski
20a870f945 Merge "Update fmtlib to 10.1.1" into main 2023-11-05 05:21:40 +00:00
Henri Chataing
6cc0283095 Update fmtlib to 10.1.1
Test: m
Change-Id: I15107355d2c26f69be5bb336e978eac55f65c437
2023-11-03 23:26:47 +00:00
Motomu Utsumi
d232211291 Merge "Handle v4-mapped v6 address in Struct parsing" into main 2023-10-31 12:02:47 +00:00
Motomu Utsumi
cb62c1b120 Merge "Add util method to generate IPv4-mapped IPv6 address from IPv4 address" into main 2023-10-31 12:02:08 +00:00
Yuyang Huang
f3bef6846a Merge "Increase HandlerUtilsTest timeout to 500ms" into main 2023-10-31 08:39:35 +00:00
Motomu Utsumi
e3e34bdf3a Handle v4-mapped v6 address in Struct parsing
testV4MappedV6Address fails without change in Struct.java

Bug: 295800201
Test: atest ConnectivityCoverageTests
Change-Id: I4a40bc47b051860c6420f211491e2ecd34c1d732
2023-10-31 17:01:48 +09:00
Motomu Utsumi
52366e0fb1 Add util method to generate IPv4-mapped IPv6 address from IPv4 address
Bug: 295800201
Test: NetworkStaticLibTests
Change-Id: Ia10e7dd14edfabe0edf5c9e12ceae54a1ff88d13
2023-10-31 17:01:43 +09:00
Jean Chalard
9fea45db05 Merge "Cleanup modifyRoutes" into main 2023-10-27 13:11:29 +00:00
Chalard Jean
ac5e4cf025 Cleanup modifyRoutes
This is no longer used out of this file, and should not be.

Test: Build
Change-Id: I531191b4afbda39a5fbaf1f483d13068f86d17f1
Merged-In: Ief0a79883bcc2c5493807c548cb71ef655abed23
2023-10-27 06:53:36 +00:00
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