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
BluetoothAdapter.getDefaultAdapter is deprecated and should be replaced
with BluetoothManager.
The AttributionSource is not necessarily set properly with
BluetoothAdapter.getDefaultAdapter, and may depend on which package is
returned first by PackageManager.getPackagesForUid. This has been
causing some flaky failures in presubmit.
Fixes: 332225348
Test: atest
Change-Id: I2f066f1a90a3c6fed7885f4bbee870abf96f664d
Removing "mWifiTetherRequested" because it might cause Wi-Fi tethering
to not have an upstream if P2P is turned on. The issue could be
recovered when the upstream's capabilities or link properties change,
tethering calls "chooseUpstreamType" to select an upstream. If none of
the above situations happen, Wi-Fi tethering won't have an upstream.
1. When Wifi P2P is enabled and tethering enters TetherModeAliveState.
2. Turning on wifi tethering, TetherModeAliveState would first receive
EVENT_IFACE_SERVING_STATE_INACTIVE when wifi tethering's IpServer
is created and enters IpServer's InitialState. Then it will call
updateUpstreamWanted and change mUpstreamWanted from false to true
before wifi tethering's IpServer actually enters TetheredState.
3. When TetherModeAliveState receives EVENT_IFACE_SERVING_STATE_ACTIVE,
which is triggered by wifi tethering's IpServer entering
TetheredState, it won't call chooseUpstreamType() because
mUpstreamWanted is already true.
case EVENT_IFACE_SERVING_STATE_ACTIVE: {
IpServer who = (IpServer) message.obj;
if (VDBG) Log.d(TAG, "Tether Mode requested by " + who);
handleInterfaceServingStateActive(message.arg1, who);
who.sendMessage(IpServer.CMD_TETHER_CONNECTION_CHANGED,
mCurrentUpstreamIfaceSet);
// If there has been a change and an upstream is now
// desired, kick off the selection process.
final boolean previousUpstreamWanted = updateUpstreamWanted();
if (!previousUpstreamWanted && mUpstreamWanted) {
chooseUpstreamType(true);
}
mWifiTetherRequested is only used to check upstreamWanted() and only be
used in TetherModeAliveState so that it is
safe to remove mWifiTetherRequested and always use mForwardedDownstreams
to check whether upstream is needed for TetherModeAliveState because all
the Tethered IpServer is added to mForwardedDownstreams when it enter
Tethered State and be removed from mForwardedDownstreams when it exit
Tethered State.
This change also move the upstreamWanted() function inside TetherMainSM
to prevent it from being used incorrectly outside of TetherMainSM.
Bug: 329552689
Test: atest TetheringTests
Change-Id: I6842170f455b280dd79aae039a1117d5e6d677f3
Pass buffer size to netlinkSocketForProto to allow callers to specify
buffer size. The buffer size is not set if 0 is passed in.
Following callers of netlinkSocketForProto passes SOCKET_RECV_BUFFERSIZE
to keep same behavior as before:
* OffloadHardwareInterface.createConntrackSocket()
* NetlinkUtils.sendOneShotKernelMessage()
* IpSecXfrmController.Dependencies.newNetlinkSocket()
* InetDiagMessage.getConnectionOwnerUid()
Following callers pass 0 to not update the buffer size:
* TunInterfaceController - it uses the socket only for writing
* NetlinkUtils.createNetLinkInetDiagSocket() same behavior as before
Added a SOCKET_DUMP_RECV_BUFFERSIZE of 128k to be used by socket
requesting dump information from kernel:
* NetlinkUtils.getAndProcessNetlinkDumpMessages() - sends dump request
and expecting multiple reply messages.
Bug: 320420453
Test: atest NetworkStaticLibTests
atest FrameworksNetTests
Change-Id: I3dcb76963cf2646eb311602b50ab4e44b8ad3e8f
The logic is currently disabled by default, adding a flag so
that we can compare result with A/B rollout. Tethering only read
this flag once when it is created.
Bug: 319212113
Test: atest TetheringTests
Change-Id: I656b0389e56d29dd691738ee3abfa6418746846f
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
This change includes:
1. Refactor the logic in Tethering#dump into utils class.
2. Move the utils class to a common place which could be referenced
from other sub-modules.
3. Add @MonitorThreadLeak annotation to enforce
there is no thread leak problem.
Test: atest FrameworksNetTests NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.networkstack.tethering.TetheringTest#testDumpTetheringLog
Test: adb shell dumpsys tethering (with hardcoded exception)
Fix: 312669345
Change-Id: Ia6fdfeeec2110afa0ec9e056e9db3843748845c3
* changes:
Revert "Refactor RouterAdvertisementDaemon with FdEventsReader"
Revert "Refactor RouterAdvertisementDaemon to build new RA in HandlerThread"
Yuyang Huangauthored and Gerrit Code Reviewcommited 2023-12-20 08:14:12 +00:00
This reverts commit bdcd7db9d8.
Reason for revert: Design changes, don't use extra Handler in RouterAdvertisementDaemon.
Change-Id: I4888f8f22aea2cadbb6064e63f872c605025930f
This reverts commit 23a2158c38.
Reason for revert: Design changes, don't use extra Handler in RouterAdvertisementDaemon.
Change-Id: Iba829ec028e887b6625f4f972e936ca5757a7614
KH Shiauthored and Gerrit Code Reviewcommited 2023-12-20 06:25:54 +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
This fix the code review comment from aosp/2319853 that getXXX functions
should be renamed to makeXXX because it's actually creating the object.
Test: TH
Change-Id: Ife8e1cc3a90b835764a2dd9731388b05d8a5c964
Markauthored and Mark Chiencommited 2023-12-04 09:02:55 +00:00
Currently, PrivateAddressCoordinator always selects the /24 prefix
from the 192.168.x.x/16 range first. If the upstream is also a /24
prefix in the 192.168.x.x/16 range, there's a 1/256 chance of a
conflict (192.168.0.x/24 ~ 192.168.255.x/24). Since 192.168.x.x/16
is a popular range for home and small business networks, we should
randomize the starting prefix range to reduce the chance of a
conflict. The /8, /12, and /16 range selection rates are 0.39%,
5.86%, and 93.7%, respectively (see the inline comments for how
the rates are calculated).
The chance of selecting a /24 prefix is:
- 10.0.0.0/8: 1/(256*256) * 93.7% = 0.001429%
- 172.16.0.0/12: 1/(16*256) * 5.86% = 0.00143%
- 192.168.0.0/16: 1/256 * 0.39% = 0.001523%
Note: This change is currently turned off by the
tether_force_random_prefix_base_selection flag. We'll run experiments
to make sure tethering stays reliable with this change enabled.
Bug: 312647670
Test: atest TetheringTests
Change-Id: Iea03fdcf0fccad95410e79ae87fcb046d75da457
The code currently calls RandomInt twice to generate an address.
For example, if you want to generate the address 192.168.A.B,
RandomInt will be called twice to generate the values for A and B.
To save resources, we can avoid calling RandomInt twice by reusing
the same random value with different masks for A and B.
Before:
- RandomInt() & 0xff00 -> A
- RandomInt() & 0x00ff -> B
After:
- RandomInt() & 0xffff -> A.B
Bug: 312647670
Test: atest TetheringTests
Change-Id: Iee49af3d82781309f78fe66ab07937b8137fa259
Markauthored and Mark Chiencommited 2023-11-24 03:10:11 +00:00
HandlerThread was introduced in aosp/2493357. This patch moves the
code originally located in buildNewRa() into the HandlerThread.
Bug: 246928127
Test: atest TetheringPrivilegedTests TetheringIntegrationTests \
TetheringTests
Change-Id: I5f6df0a3a79d7f4a865cfec7f88bc28816b1db95
This patch changes the implementation of UnicastResponder in the
RouterAdvertisementDaemon with FdEventsReader. The change includes
replacing Thread with HandlerThread, create socket in non-blocking
mode (required by FdEventsReader) and use FdEventsReader to listen
to the solicited RS packets. Two commands (CMD_START & CMD_STOP)
were added to control the lifecycle of the FdEventsReader.
Bug: 246928127
Test: atest TetheringPrivilegedTests TetheringIntegrationTests \
TetheringTests
Test: Enable WiFi hotspot and connected with another Pixel client:
1. Tcpdump on the Pixel client, checking the RA packets
2. Verify IPv6 addresses were configured
3. ping6 2001:4860:4860::64
Change-Id: I6e89903df90864e3bb34d498e353d6f87193e9d6
Instead of passing state machine to UpstreamNetworkMonitor, wrapped it
by an interface would have two benefits:
1. Easier for testing.
2. Isolate state machine operation in callback.
Test: atest TetheringTests
Change-Id: I2a97fd5cbc8c49df8c3c98428c6570916ab31ea5
TetherUpstream6Key#src64 should be stored in network order. Use
a big-endian ByteBuffer to retrieve a value stored in network order
is actually converts it into native order, which is little-endian in
Android.
In this CL, we changed it to use byte[] instead of long to store the
top 64-bits of the source prefix.
Test: atest TetheringTests
manual test with IPv6-only tethering upstream, check BPF stats.
Bug: 312072637
Change-Id: I79f9282d5eda28328aa6a764ea92b086d6285133
FileDescriptor#getInt$() is a hidden API with the unsupportedApiUsage
annotation on R. Accessing it will cause a NewApi linter check error.
It should be removed from OffloadHalHidlImpl as it is only used for
log messages.
Bug: b/205762647
Test: m
Change-Id: Ie41d12988aee65a066dfb1529e828f4523cc0907
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
Avoid passing primitive data types into Objects.hash() which will
convert them to their corresponding object wrapper types
automatically.
Test: atest TetheringTests
Bug: 261923493
Change-Id: I2efe7f3e50923ad2e33cfd58ae7e1e1cf7fd34bd
This can be used from S. There is no point in having a
release name in the name of this class.
Test: builds
Change-Id: I301bf032f856dd4c30554e06013f31ee57208c4e
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