Commit graph

90,888 commits

Message SHA1
Merge "Fix broken documentation in Connectivity" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2023-10-13 19:30:52 +00:00
0eab476f7a
Fix broken documentation in Connectivity
EthernetManager is @SystemApi, so cannot be referenced from public
API.

Bug: 303184203
Test: m docs
Change-Id: Ib5cc07c89b4ecfdeae704da131ebb307816e35fa

Anton Hansson   commited 2023-10-13 15:25:26 +00:00
5ac6c0b05b
Merge "Add additional overriding methods to signature files" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-10-13 15:05:40 +00:00
d2d3b5dd88
Merge changes I3b6ee1db,I70e13303,I6fb7dfe4 into main
* changes:
  Simplify addRoutesToLocalNetwork calls
  Add LocalNetworkConfig
  Tell netd about local networks

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-13 09:57:18 +00:00
a6190bd658
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

Chalard Jean   commited 2023-10-13 16:19:25 +09:00
cf70df3e9b
Add LocalNetworkConfig
This doesn't do anything at this patchset, but the whole
pipe from the agent to ConnectivityService is built.

LocalNetworkInfo will be the name of the public information
sent in callbacks to clients.

Test: CSLocalAgentTests
Change-Id: I70e133031ef3b0aaf6c3e59ccc2ad895c66d339c

Chalard Jean   commited 2023-10-13 14:40:45 +09:00
fa21cafc1c
Tell netd about local networks
This patch does the following :
• When a network is local but the system doesn't support it,
  throw in registerNetworkAgent.
• When a network is local, tell netd about it.
• Add tests for the above, as well as a test for callbacks
  being sent correctly when the caps are set and not when
  they aren't and that the new keep connected flag is
  respected.

Telling netd about the network being local has it add two
routes that do not exist if the network is not local :
• One at PRIORITY_LOCAL_NETWORK matching unmarked sockets
  and looking up the table for the interface.
20000: from all fwmark 0x0/0x10000 lookup xxxx
• One at PRIORITY_EXPLICIT_NETWORK matching explicitly on
  network 99, so that dnsmasq traffic and any OEM traffic
  marked for network 99 flowing there.
16000: from all fwmark 0x10063/0x1ffff iif lo lookup xxxx
IMPLICIT_NETWORK and EXPLICIT_NETWORK rules are installed
by connectivity service as a matter of course whether the
network is local or not.

See commit If8729fc6f3716a580c936584b851bc38000b5de5 for
implementation details of this mechanic.

There is no need to implement anything in particular for the
new connected reason, as the current implementation will
already keep it connected. A new test makes sure of that.

Test: FrameworksNetTests
      CtsNetTestCases
      FrameworksNetIntegrationTests
      NetworkStackTests
      NetworkStaticLibTests
      TetheringTests
      MtsTetheringTestLatestSdk
      TetheringIntegrationTests
Change-Id: I6fb7dfe4c232eea8cac9ac268897ddb36bb794d1

Chalard Jean   commited 2023-10-13 14:40:38 +09:00
774dc3cd51
Merge changes I22d67a7e,Ida4a4bc7,Ie8522862,Id55d8d6c into main
* changes:
  Ensure nri is satisfied before returning.
  Add testLockdownVpn that mocks platform VPN.
  Make variables in testLegacyLockdownVpn() final.
  Update testLegacyLockdownVpn to mock VPN.

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-10-13 05:00:29 +00:00
ccfc52145b
Add additional overriding methods to signature files
This change adds overriding methods that are essential to compile the
stubs generated from the signature files.

More information and the background for this change is available at
go/add-overriding-one-pager.

Test: m checkapi
Bug: 299366704
Change-Id: Idba307148fd9afa87bfb7e0c89e00d9bd97ec204

Paul Duffin   commited 2023-10-12 19:21:07 +01:00
b3c3f2e9d0
Merge "Include both eth%d and usb%d ethernet interfaces on U+" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2023-10-12 17:28:34 +00:00
9b2a0d1962
Include both eth%d and usb%d ethernet interfaces on U+
Ethernet interface naming is not consistent on Linux. While some USB
ethernet dongles show up as eth0, others might show up as usb0.

This CL changes config_ethernet_iface_regex to "*" which stands for "use
Android version specific default". The default will include both usb\d+
and eth%d named interfaces on Android U+. Android T will continue to
only include eth%d interfaces (note that the "+" is a new addition which
is highly unlikely to have any actual effect, but is more technically
correct).

Bug: 304335605
Test: TH
Change-Id: I823be8ee390cb2b6dd41b537c72ed76f5aa9e0ea

Patrick Rohr   commited 2023-10-12 10:26:47 -07:00
11eac8e12b
Merge changes Ic490fee6,If78047c3 into main
* changes:
  Add hidden constants for communicating about local network agents
  Use isAtLeast* from deps

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-12 11:01:36 +00:00
10353d5351
Ensure nri is satisfied before returning.
When a network preference is set, the highest priority nri will
be a managed default request that disallows default networking.
In the case where there is no satisfying network,
mNoServiceNetwork is used as the satisfier instead of null.
(see computeNetworkReassignment)

mNoServiceNetwork should not be returned in any public API.
Check for the nri being satisfied before returning the satisfier
to ensure mNoServiceNetwork is not returned.

Fixes: 301222648
Test: atest FrameworksNetTests
Change-Id: I22d67a7e8d0274d8ad4f6123fbedf6d37eed18e7

Hansen Kurli   commited 2023-10-12 18:48:57 +08:00
ed972a6fd2
Add testLockdownVpn that mocks platform VPN.
Add a test for lockdown vpn that uses TYPE_IKEV2_IPSEC_PSK and
mocks platform VPN by override in startLegacyVpnPrivileged().
In the context of ConnectivityService, setVpnDefaultForUids()
is the main interaction.

Refactor testLegacyLockdownVpn to take a VpnProfile and assert
behaviors with and without setVpnDefaultForUids().
This includes:
    1. Updating callback asserts and assertActiveNetworkInfo to
       reflect setVpnDefaultForUids().
    2. Adding TODOs where mCm.getActiveNetworkInfo() returns
       unexpected values.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ida4a4bc745af5ba2fc251795b2ffca56ead79b7f

Hansen Kurli   commited 2023-10-12 18:48:24 +08:00
48c14686a3
Merge "Update mActiveIdleTimers to use netId as a key" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2023-10-12 09:10:22 +00:00
9b6420bc13
Merge "Stop the created handler threads on the tests" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-10-12 07:13:30 +00:00
0b5d785096
Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0

Chalard Jean   commited 2023-10-12 13:30:49 +09:00
d6f4efb1a8
Use isAtLeast* from deps
CSTest and CSAgentWrapper need to agree on what the current
version is

Test: CSTest*
Change-Id: If78047c36ce213a531207d25b410e870691fbb98

Chalard Jean   commited 2023-10-12 13:30:49 +09:00
5efbcf7bab
Stop the created handler threads on the tests
The created handler thread will stay there for a while until
all the tests are finished. This is considered as a leakage
which will take the resource from the devices. In low end
devices, this may possibly impact the performance. The created
threads should be closed explicitly.

Test: atest ConnectivityCoverageTests ConntrackSocketTest
Change-Id: Ic1beb2a210e7c8c80c66fc9e0727c47599150672

Paul Hu   commited 2023-10-12 10:25:03 +08:00
ebbbf8f470
Merge changes Ibb8d33b7,Ie168fe1f,I9f699b63 into main
* changes:
  Prepare exposing Network{Request,Caps}.forbiddenCapabilities
  Add a keep connected for test reason
  Improvements to CSTest : legacy type, wait for LOST, permissions

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-12 02:14:52 +00:00
02193c0cce
Merge "Prepare for keeping concrete overrides of abstract methods" into main
Jihoon Kang   authored and   Gerrit Code Review   commited 2023-10-11 21:02:18 +00:00
415773ed06
Merge changes Ib24809ec,Id9d26435 into main
* changes:
  Remove the fail case on IPv6 in testLockdownVpn
  Remove LockdownVpnTracker from testLegacyLockdownVpn

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-10-11 12:03:37 +00:00
270813c4c5
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

Chalard Jean   commited 2023-10-11 17:02:52 +09:00
cf7dbcae41
Add a keep connected for test reason
This has been sorely needed for a while. Instead of filing requests
for each of your networks in a CSTest, which is fiddly at best and
sometimes almost impossible (because you can't single out the network),
you can now add this flag and be done with it.

Test: CSKeepConnectedTest
Change-Id: Ie168fe1f3a17de035fdf05e3d6580d3262a3448e

Chalard Jean   commited 2023-10-11 17:02:52 +09:00
c517fb1247
Improvements to CSTest : legacy type, wait for LOST, permissions
• Make sure all Agents have a legacy type. This is necessary to
  avoid crashes in LegacyNetworkTracker
• Wait for LOST when disconnecting a network
• Make sure the test package sees its own permissions (importantly
  it can't see background networks otherwise, because it lacks
  CHANGE_NETWORKING_STATE)

Test: in the followup
Change-Id: I9f699b6372a8fe0d5bcd5310d8f35f72e48a6c61

Chalard Jean   commited 2023-10-11 17:02:51 +09:00
026ca940d9
build netbpfload into the tethering apex
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id68aece26115808c2b1b795b9395208f5066f87c

Maciej Żenczykowski   commited 2023-10-10 16:51:01 -07:00
a2a3d754a6
Merge changes from topic "netbpfload" into main
* changes:
  netbpfload: remove netbpfload.rc
  netbpfload: remove support for limiting selinux contexts
  netbpfload: do not create /sys/fs/bpf/loader subdir
  type safety for 'bool downstream'
  type safety for 'bool updatetime'

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-10-10 17:23:50 +00:00
9c01dd494d
Prepare for keeping concrete overrides of abstract methods
Currently, metalava will discard concrete overrides of abstract methods
from the API signature files which causes problems when attempting to
generate stubs from those files and also discards information that may
be important in API reviews. This change is the first step in the
process of changing that behavior.

This change hard codes the current behavior for discarding the concrete
overrides (`add-additional-overrides=no`) into those signature files
that will (or are likely) to be affected by the change in behavior.
That allows the default behavior to be changed for all the other files
without affecting these.

Follow up changes will remove the hard coding from the signature files
and will update the contents which will include the concrete overrides
of the abstract methods.

More information and the background for this change is available at
go/add-overriding-one-pager.

Test: m checkapi
Bug: 299366704
Change-Id: I52c5bbe2e3bbd36019fe44fcb0b2d19876a5a869

Paul Duffin   commited 2023-10-10 17:11:25 +01:00
7bd2d108ea
Reword a comment for accuracy
Test: none needed
Change-Id: I7e409827adc86fc13975f394100889a6bf0f1e50

Chalard Jean   commited 2023-10-10 20:12:40 +09:00
f70919fbec
netbpfload: remove netbpfload.rc
I think it's better to just put this in bpfloader.rc,
where we can guarantee the correct ordering.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie2c5ab1cb1de015397ac54867ae6bb0c4321d207

Maciej Żenczykowski   commited 2023-10-10 03:46:06 -07:00
1d2c93d568
netbpfload: remove support for limiting selinux contexts
No need for this, as we simply only support those selinux
contexts (and directories) which are available to networking.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I35b134c57411f82514b9f7148411f83d3aee1927

Maciej Żenczykowski   commited 2023-10-10 03:46:06 -07:00
af07d6db1f
netbpfload: do not create /sys/fs/bpf/loader subdir
(it's already created by the platform bpfloader)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie22f585cab17fd2bded3d97a9cfe1019b792b69d

Maciej Żenczykowski   commited 2023-10-10 03:37:14 -07:00
857399114e
type safety for 'bool downstream'
funky naming 'stream.down', because downstream.downstream is just too long...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id234654fa8960e7430fc33119f36fd94b858d242

Maciej Żenczykowski   commited 2023-10-10 03:37:14 -07:00
e1a615ad83
type safety for 'bool updatetime'
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I99d51524ba913c46bad64b89778c01164639c85e

Maciej Żenczykowski   commited 2023-10-10 03:37:14 -07:00
8a6c6d50c0
Allow for mocking an SDK in the tests
Test: in followup patches
Change-Id: I540ce2a455c92be52eb94fbd4b54a2081d04d25e

Chalard Jean   commited 2023-10-10 14:57:22 +09:00
eb66389d6a
Merge "Use libbase properties for a slight simplification." into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-10-10 05:56:01 +00:00
af11354ba5
Merge "Expose the netd mock in CSTest to allow verifying calls on it" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-10 04:17:29 +00:00
4dec273ab4
Merge "Add missing copyright notices to tests" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-10 04:16:52 +00:00
e339c6b780
Merge changes I163e21fd,I1b0943d3,I3af8e7f1 into main
* changes:
  netbpfload: remove support for limiting program types
  netbpfload: remove non-network program types
  netbpfload: add Android.bp file

Treehugger Robot   authored and   Gerrit Code Review   commited 2023-10-10 03:52:05 +00:00
962ac591bc
Merge "Move the delegated prefix validity check to IaPrefixOption class." into main
Xiao Ma   authored and   Gerrit Code Review   commited 2023-10-10 03:27:35 +00:00
a1eb2e453f
Use libbase properties for a slight simplification.
Test: treehugger
Change-Id: If699230d0bf71ce521d7175da707e42b78ae4886

Elliott Hughes   authored and   Maciej Żenczykowski   commited 2023-10-09 23:57:48 +00:00
497e3e05a5
Merge "Clean up obsolete aliases for Truth." into main
Krzysztof Kosiński   authored and   Gerrit Code Review   commited 2023-10-09 23:08:57 +00:00
22d08770af
Merge changes Ib48cc2b8,I3f0a12f1 into main
* changes:
  type safety for is_ethernet
  type safety for 'bool egress'

Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-10-09 17:23:32 +00:00
2c2c707d6c
Merge changes If33414ec,I8f211e47,If05c0c53 into main
* changes:
  netd.c: factor out get_app_permissions()
  bpf_progs: use macros for kernel version
  type safety for kernel version

Treehugger Robot   authored and   Gerrit Code Review   commited 2023-10-09 14:39:54 +00:00
ae0971b4ae
netbpfload: remove support for limiting program types
No need for this, as we simply only support network
program types in the first place.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I163e21fd4d4089882cf37fc68bc4299003b514d7

Maciej Żenczykowski   commited 2023-10-09 00:32:36 -07:00
fcea70f840
netbpfload: remove non-network program types
We are unlikely to ever be willing to load these
program types from mainline, as it is simply too dangerous.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1b0943d39b8131699f4606e8d165f3c944d453ed

Maciej Żenczykowski   commited 2023-10-09 00:32:31 -07:00
02519f86ad
netbpfload: add Android.bp file
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3af8e7f14de8dd5dd65c40705195332bef114b88

Maciej Żenczykowski   commited 2023-10-09 00:32:26 -07:00
40dfe53313
type safety for is_ethernet
(reversing logic, as 'rawip.rawip' is much shorter then 'ethernet.ethernet')

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib48cc2b889e8b587e14edbe89606f887a884af87

Maciej Żenczykowski   commited 2023-10-08 20:16:59 -07:00
8d3bde7949
type safety for 'bool egress'
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3f0a12f139478bc94d351d58a08d4a9bd19fa320

Maciej Żenczykowski   commited 2023-10-08 20:16:59 -07:00
a8852b2488
Merge "[mdns] exclude mDNS advertiser code from standalone build test" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2023-10-08 12:21:24 +00:00
4a8977c452