This is a no-op refactoring which inline the functionalities
to IpServer, enabling subsequent changes to move
networkAddInterface part to ConnectivityService when the
tethering is enabled.
Test: atest TetheringTests:android.net.ip.IpServerTest
atest NetdStaticLibTests:com.android.net.module.util.NetdUtilsTest
Bug: 349487600
Change-Id: I6d0e5d349691df7a15bee852d5fd1dd19f5da6f6
This is a no-op, preparatory refactoring to isolate route
modification functionality, enabling subsequent changes to move
routing control to ConnectivityService.
Test: atest TetheringTests:android.net.ip.IpServerTest
atest NetdStaticLibTests:com.android.net.module.util.NetdUtilsTest
Bug: 349487600
Change-Id: I55af07968567b173dd9f97795600390439f1b927
IpServer#enable is called with both a non-null TetheringRequest and the
requestedState, but the requestedState is derived from the
TetheringRequest's connectivity scope. Remove this requestedState arg
and simply have IpServer read the connectivity scope itself.
Bug: 216524590
Test: covered by existing tests
Change-Id: I73227f5053da3a2ab35563268fc416b6dd9b1801
Quang Anh Luongcommited 2025-01-30 14:30:51 +09:00
Currently the enableIpServing->tetherInternal call stack may have a
tethering request alongside a redundant tethering type and requested
state. The redundant arguments were necessary since there may be cases
where the active request is null (e.g. back-to-back start/stop, which
removes the active request before the link layer event enables ip
serving).
This change gets rid of the redundant arguments and makes the call stack
take a non-null TetheringRequest. In case the active request is not
found, we will create a placeholder request with just the type and
connectivity scope (i.e. requested state). This should be equivalent to
the old code of sending a null request (since none of the other fields
in TetheringRequest are used), making this a no-op change.
Bug: 216524590
Test: covered by existing tests
Change-Id: I5ac83c74f5bc4aec2fe85daa9477740749d95c63
Quang Anh Luongcommited 2025-01-30 14:30:49 +09:00
This reverts commit 685b8aa508.
Reason for revert: May break Bluetooth pre-T IPv4 prefix conflict handling if TetheringRequest is not specified. Instead we should add this to AOSP/3389321 when we can guarantee IpServer always has a tethering request here.
Bug: 384812983
Test: presubmit
Change-Id: I9c65e87804855fd293fa75c921de3d256caad1b3
Follow-up from aosp/3383831, some arguments are still missing,
adding them and update tests accordingly.
Test: atest NetdStaticLibTests
Bug: 349487600
Change-Id: I495291f1e57c3a32c015fc7dfa3c2e6e86663da8
This is a no-op refactoring which:
1. Updates netd utility methods to handle custom netIds.
2. Rename internal methods to reflect the functionality.
3. Import constants from TetheringManager to improve
readability.
This refactoring is a prerequisite for future changes that will
utilize a new netId for routing instead of LOCAL_NETWORK_ID.
Test: atest NetdStaticLibTests TetheringTests CtsTetheringTest
Test: adb shell ip ru && adb shell ip ro show table local_network
Bug: 349487600
Change-Id: I1f3a68d24852b6bd85ce7be2ec58746e49b67636
IpServer currently starts/stops tethering by specifying the tethering
type, but this will be a problem when we start to allow multiple
requests per type. To fix this, specify the TetheringRequest instead.
Note this CL has no functional changes.
Bug: 216524590
Test: atest TetheringTest TetheringManagerTest
Change-Id: I6bd9ceebcaa637a540435d5e91a35382f167a809
Quang Anh Luongcommited 2024-11-19 19:32:22 +09:00
Include SoftApConfiguration in TetheringEventCallback via
TetheringInterface, to allow apps to know which interfaces are created
with their SoftApConfigurations.
API-Coverage-Bug: 371133403
Bug: 216524590
Test: atest TetheringTest CtsTetheringTest
Change-Id: I1b4868ba8327bee3b03c0f21e5b4f0845f2f24a8
Quang Anh Luongcommited 2024-11-18 13:37:39 +09:00
This CL splits requestDownstreamAddress into two methods: requestStickyDownstreamAddress and requestDownstreamAddress.
- The requestStickyDownstreamAddress is equivalent to the former requestDownstreamAddress when useLastAddress=true.
- The new requestDownstreamAddress method allows allocating an address without providing the interface type and scope, which is Thread NAT64's use case.
Bug: 369282577
Change-Id: Ib839d121c7b46c492f2c4c1c61b52b5d017fa055
API
This CL refactors IpServer to allocate IPv4 address via RoutingCoordinatorManager
instead of directly talking to PrivateAddressCoordinator class.
Bug: 350699020
Change-Id: I5c68620626a3668c079234da232f0ef2beb46628
* changes:
Remove unused method TetheringConfiguration#isRandomPrefixBaseEnabled()
PrivateAddressCoordinator: introduce Dependencies class
PrivateAddressCoordinator: move the special handling of WiFi P2P dedicated IP to IpServer
Treehugger Robotauthored and Gerrit Code Reviewcommited 2024-10-08 17:07:29 +00:00
dedicated IP to IpServer
The source of
TetheringConfiguration#shouldEnableWifiP2pDedicatedIp is in the
Tethering's resources. As refactoring the code, we noticed that it will
be simpler to handle this at IpServer (constructed using
TetheringConfiguration) instead of at PrivateAddressCoordinator
(will require reflection to read the Tethering's resources).
Bug: 369282577
Change-Id: I7b766ef6a769043c2a4ca11741db5c16c5c57071
Technically, UnavailableState should not handle any messages at all (and
shouldn't exist). As the IpServer has already been removed from
mTetherStates. However, sendInterfaceState() cleans up IPv6 tethering
which eventually triggers a CMD_IPV6_TETHER_UPDATE. Instead of
preventing the CMD_IPV6_TETHER_UPDATE, ignore it for now and remove this
state entirely once we have rolled out SyncStateMachine.
Bug: 368713124
Test: TH
Change-Id: I32ae9583aa01411fa1fc299a0fc91138557b7ae2
The break is missing when processing CMD_SERVICE_FAILED_TO_START
in BaseServingState.
Test: atest TetheringTests
Change-Id: I1699da251f90ec447466266b704df24d081c40b3
On Android R, IpServer uses netd to set up tethering while on S+ it uses
RoutingCoordinator.
This CL lets Tethering own a RoutingCoordinatorService when the SDK
version <= R so IpServer can always use RoutingCoordinator instead of
netd.
Bug: 350699020
Test: CI
Change-Id: I0ed33fb050260c26be87079bed0e189716cd8782
- This CL puts RoutingCoordinator into staticlibs to make it usable by
both Tethering and ConnectivityService on R.
- This CL also changes the return type of
ConnectivityInternalApi#getRoutingCoordinatorManager() to IBinder so
it has fewer dependencies.
Bug: 350699020
Test: CI
Change-Id: Iba096e940795cd33e61c5141721394ad39e5ce6d
Replace TetheringRequestParcel with TetheringRequest in the service
code. This makes future changes easier since TetheringRequest is a
proper class and not an AIDL object.
Bug: 216524590
Test: atest TetheringTest TetheringManagerTest
Change-Id: I0cdee597d393e53feb9fe9aff4d6c67330c88599
Quang Anh Luongcommited 2024-06-26 16:25:13 +09:00
* changes:
Clean up BpfCoordinatorTest after refactors
Move upstream interface BPF support check to BpfCoordinator
Refactor BPF map update logic of upstream interface change
Centralize IP neighbor monitoring in BpfCoordinator
Get rid of BpfCoordinator#mPollingStarted
KH Shiauthored and Gerrit Code Reviewcommited 2024-06-22 12:34:34 +00:00
Removed upstream interface BPF support check from IpServer and moved
it to BpfCoordinator. The support check can be performed directly in
BpfCoordinator using the interface name.
Test: atest TetheringTests
Bug: 294025403
Change-Id: Ia51bc3ab18dd21afdca9db9199fa060aab68f768
This CL centralizes IP neighbor monitoring in the BpfCoordinator,
eliminating the need for redundant monitors in each IpServer.
Test: atest TetheringTests
Bug: 294025403
Change-Id: Ie6fbc3eeaa0ed4a34a6680714f44678e2d5b633a
Refactor IpServer/BpfCoordinator to remove mPollingStarted, and just
maintain the invariant that "data usage polling and conntrack
monitoring are running iff at least one IpServer is serving".
Test: atest TetheringTests
Bug: 294025403
Change-Id: I55064ee78e1cda12ad76b7c31496d760dcffdd76
Check out #isLoggable from frameworks/base/core/java/android/util/Log.java to
learn how to enable the log.
Bug: 329552689
Change-Id: I86ce0dae947cf56da069dfe3145ef074de11217e
Test: TH
This reverts commit cf11be9eb2.
Reason for revert: avoid some IpServer(s) running the new sync state machine while others use the async state machine.
Bug: 319212113
Change-Id: Ib086a7ccd102f38e579c79f94aceae9971f1853a
Mark Chienauthored and Markcommited 2024-01-22 11:34:14 +00:00
The logic is currently disabled by default, adding a flag so
that we can compare result with A/B rollout.
Test: atest TetheringTests
Change-Id: If640b9a172b97aa67c49b2976cdef118218f1e0f
ArraySet is designed to be more memory afficient than HashSet. It is
suitable to store small numbers of items.
Test: atest TetheringPrivilegedTests TetheringIntegrationTests \
TetheringTests
Bug: 261923493
Change-Id: I2bd2eded801cc05ce53ef9f9486b13faf1772d22
This reverts commit 55ccfe19e2.
Reason for revert: this must be introducing some sort of race
it appears to cause
atest EthernetTetheringTest 'NetdBinderTest#TetherForwardAddRemove'
to no longer reliably pass.
Change-Id: I5281ab3f42c5ce268d97a12db24a6768db3f4354
Maciej Żenczykowskiauthored and Gerrit Code Reviewcommited 2023-10-28 02:10:52 +00:00
BPF needs upstream prefixes information to filter spoofing IPv6 source
addresses carried in downstream traffic.
We retrieve prefixes from upstream interface's LinkProperties and pass
it to the BpfCoordinator. Forwarding rules will also be updated when
upstream interface's IPv6 link addresses change.
Test: atest TetheringTests
Bug: 261923493
Change-Id: If8cfc3b191e520ca838654d1b5211ab9e9ec021d
As state transitions always occur after a message has been processed,
calling transitionTo only under processMessage makes the flow easier
to understand and less error-prone.
The risk of this change is very minimal since it is only about
handling the error, but tethering will stop regardless.
Test: atest TetheringTests
Change-Id: I56c6cf6cc989464ee84a8333ac131afc808a3d95
Currently, Ipv6UpstreamRule is added follows the adding of
Ipv6DownstreamRule when it is the first rule from a downstream
interface to the upstream interface.
This CL changed it to:
1. Upstream interface change updates both IPv6 upstream and downstream
forwarding rules.
2. Neighbor events updates only IPv6 downstream forwarding rules.
Data limit setting on the upstream interface is now depend on the
upstream rules instead of the downstream rules. This CL also updates
corresponding test cases in IpServerTest and BpfCoordinatorTest.
Test: atest TetheringTests
Bug: 261923493
Change-Id: I5b4df64a3d276afb7a24bbef3a0432f53377e8b2
In current code, IpServer will ensure bpf offload is supported before
calling BpfCoordinator's APIs. But those APIs already have the same
checks inside the function. This CL removed duplicated checks in
IpServer.
After this change, the BPF offload support status is only determined
inside BpfCoordinator and it won't change during the life cycle of
Tethering. Tethering initializes mBpfCoordinator just once in the
constructor. After that point, the value of isUsingBpf can never
change, because mIsBpfEnabled is final and
mBpfCoordinatorShim.isInitialized() is either always true (api30) or
can either never change (api31).
Also fixed a bug in IpServerTest upon this change.
Test: atest TetheringTests
Bug: 261923493
Change-Id: I50f231a83bf678b90eae4fd9bfa6035e86978bb3
The original code requires updating mLastIPv6LinkProperties before
calling updateIpv6ForwardingRules because mLastIPv6LinkProperties will
be used inside an internal function later. Remove this unnecessary
dependency by passing the interface name into the function.
Bug: 294025403
Test: atest TetheringTests
Change-Id: I5699fba3d7caf3314d102b643b02da2b2797dd66
Replaced startUpstreamIpv6Forwarding and stopUpstreamIpv6Forwarding
with add/remove Ipv6UpstreamRule. This is a preparation for following
CLs which will pass the upstream's prefixes to the bpf map. We might
have more than one upstream rules.
Also renamed Ipv6ForwardingRule to Ipv6DownstreamRule since we have
defined the Ipv6UpstreamRule.
No logic changes are being made in this CL.
Test: atest TetheringTests
Bug: 261923493
Change-Id: I022f97c2daf468bbd4a4279a069ccf498013e7e7