Commit Graph

11856 Commits

Author SHA1 Message Date
Maciej Żenczykowski
4a3d91fdcb bpf offload - make sure bpf code can access packet headers am: 8e69ec111f am: 3129be7a3b am: 4cfddb344c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1622559

Change-Id: I29df9c0df46fd67203e50d30c3ae70eaa43cfeab
2021-04-07 02:46:50 +00:00
Maciej Żenczykowski
4cfddb344c bpf offload - make sure bpf code can access packet headers am: 8e69ec111f am: 3129be7a3b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1622559

Change-Id: I1e269e775a06d62ab1e106ed8c39d98d01c74e39
2021-04-07 02:00:06 +00:00
Maciej Żenczykowski
3129be7a3b bpf offload - make sure bpf code can access packet headers am: 8e69ec111f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1622559

Change-Id: I303cd63ee424c8c4ef1c744e1893c06a5d53f50a
2021-04-07 01:19:05 +00:00
Chiachang Wang
f3066426bf Merge "Add framework-connectivity-test-defaults to hostside test" into sc-dev 2021-04-07 00:30:57 +00:00
Maciej Żenczykowski
8e69ec111f bpf offload - make sure bpf code can access packet headers
If a tc ebpf program writes into a packet using direct packet access
then the packet will automatically be uncloned and pulled by
additional prologue inserted by the kernel itself.  See
tc_cls_act_prologue() & bpf_unclone_prologue() in kernel sources
(this is how the clat ebpf program works, which does DPA writes).

However in the forwarding programs we only *read* from the packets
using direct packet access, but never write.  All writes happen via
kernel bpf helpers (this is mostly an implementation detail: since
we need to use helpers for checksum updates, I decided to also use
checksums for the writes themselves).  As such the insert 'automatic
unclone/pull' logic doesn't trigger.

It is thus possible (it depends on the skb layout delivered by the
nic driver) for 0 bytes of the packet to be accessible for read
using direct packet access.  We thus need to explicitly try to pull
in the header of the packet so that we can inspect it.

In most cases (on most drivers for most packet types) this will
end up being a no-op (because the headers will already be in
the linear portion of the skb).  But on some drivers for some
packet types it ends up mattering.

Test: TreeHugger, makes icmpv6 tether forwarding work on bramble
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4b07e57728ce544ffb908527ea11ecc315e5acec
2021-04-06 21:50:17 +00:00
Chiachang Wang
c1032ecc0e Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0 am: a8cf72829c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I2624451fe07c857cc9cdb303450cd5079d0008fe
2021-04-06 13:41:34 +00:00
Chiachang Wang
8cbbafef5e Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0 am: e08cfe35ca
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I3b80a8a8a68f6a1ef2cab32d59cf4aae71cca645
2021-04-06 13:02:08 +00:00
Chiachang Wang
e08cfe35ca Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: Ie18feeed7a5fab34e9696f057633cd40f67ce0ba
2021-04-06 12:35:58 +00:00
Chiachang Wang
a8cf72829c Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I00a93b5bf8c44ab5b05f27dc7312f2d996e1b501
2021-04-06 12:35:39 +00:00
Chiachang Wang
d212efd8b0 Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I4ced8a0913bd170e8b6e008480c3dd2cf60c6246
2021-04-06 11:44:11 +00:00
Chiachang Wang
7d0e27bd7c Merge "Update tests for onNetworkCreated and onNetworkDestroyed" 2021-04-06 11:04:30 +00:00
Chiachang Wang
b82f3a9f57 Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4 am: c1c5f7f974 am: 9565064aad
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: Ic7ca40e3c70bf38d749cd7e91bb23847b4735bce
2021-04-06 10:04:22 +00:00
Maciej Żenczykowski
5922723dd4 Merge "implement insertOrReplace()" am: 47851fc01b am: 40899ff9e8 am: ebddc8809f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662788

Change-Id: If74751e28741a56a8eae85880392f2790f13516e
2021-04-06 10:04:12 +00:00
Chiachang Wang
b3269df005 Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4 am: c1c5f7f974 am: 0f60bf6013
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: If7ac04aa2a7014d7154879f539b37bb12a3788ae
2021-04-06 10:04:05 +00:00
Maciej Żenczykowski
b492cee0a7 Merge "implement insertOrReplace()" am: 47851fc01b am: 40899ff9e8 am: cb2064eeff
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662788

Change-Id: Ibf8a5bd40f05a7fbc4e949e5f9da86032934b4c0
2021-04-06 10:03:25 +00:00
Chiachang Wang
0f60bf6013 Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4 am: c1c5f7f974
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: I7ddbfa9eaf0bb6b2e0375f48a17e0d96e49b6c7a
2021-04-06 09:38:26 +00:00
Chiachang Wang
9565064aad Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4 am: c1c5f7f974
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: I5e7ec1bec1e578b45cf3940b748fa585f6dda246
2021-04-06 09:37:37 +00:00
Chiachang Wang
c1c5f7f974 Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: Ib93d650bc77e2b5daa75ce8f79bbd392e1f5c46c
2021-04-06 09:17:42 +00:00
Maciej Żenczykowski
cb2064eeff Merge "implement insertOrReplace()" am: 47851fc01b am: 40899ff9e8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662788

Change-Id: Ia4fe20d67bacf5e3e0fa424aeacf1d113db02fdc
2021-04-06 09:17:40 +00:00
Maciej Żenczykowski
ebddc8809f Merge "implement insertOrReplace()" am: 47851fc01b am: 40899ff9e8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662788

Change-Id: I5c9f760c6281d0154377a2edeaaac375bfc3020a
2021-04-06 09:17:33 +00:00
Chiachang Wang
674a907cc4 Merge "Ensure SSID is not exposed to apps without correct permission" 2021-04-06 08:58:50 +00:00
Maciej Żenczykowski
40899ff9e8 Merge "implement insertOrReplace()" am: 47851fc01b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662788

Change-Id: I06081f8ad3e27875ec6a0f13cb21f6b1ab006159
2021-04-06 08:55:52 +00:00
Maciej Żenczykowski
47851fc01b Merge "implement insertOrReplace()" 2021-04-06 08:17:42 +00:00
Frank Li
dc505306ef [automerger skipped] Merge "Add session ID to VpnTransportInfo" am: 320cd17220 am: 45d9b25a36 am: 7f1a6eb12f -s ours
am skip reason: skip tag Change-Id I883035262465238c35c5a931d89707f3e84feef8 with SHA-1 ac6614fa05 is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652217

Change-Id: Ib629376732241e31f78123fe3a44732c9ab8e9ad
2021-04-06 07:57:52 +00:00
Frank Li
dc783a72bc [automerger skipped] Merge "Add session ID to VpnTransportInfo" am: 320cd17220 am: 45d9b25a36 am: 1502d841cf -s ours
am skip reason: skip tag Change-Id I883035262465238c35c5a931d89707f3e84feef8 with SHA-1 ac6614fa05 is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652217

Change-Id: I09ba1711b80b239780092f3dee13e182c8275ed0
2021-04-06 07:54:12 +00:00
Frank Li
7f1a6eb12f Merge "Add session ID to VpnTransportInfo" am: 320cd17220 am: 45d9b25a36
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652217

Change-Id: I42628292a9d30ac39e29278214b9a179f28e277c
2021-04-06 07:35:07 +00:00
Frank Li
1502d841cf Merge "Add session ID to VpnTransportInfo" am: 320cd17220 am: 45d9b25a36
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652217

Change-Id: I0011ffa4d24d9680e79241a120ea7c4904d88d67
2021-04-06 07:29:23 +00:00
Frank Li
45d9b25a36 Merge "Add session ID to VpnTransportInfo" am: 320cd17220
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652217

Change-Id: I2bcafaaeb3f9dd2030745f1f7fa52f10f60733dd
2021-04-06 07:01:13 +00:00
Frank Li
320cd17220 Merge "Add session ID to VpnTransportInfo" 2021-04-06 06:50:48 +00:00
Lorenzo Colitti
ccf6ed900a Fix DadProxyTest when forwarding is on. am: b6bffbca95 am: 3f29d3ef39 am: f6adb01d24
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1664401

Change-Id: I8e4df65ae7343445ea56c6e9a01b1573380988a3
2021-04-06 06:09:58 +00:00
Lorenzo Colitti
498626e6c5 Fix a race condition in upstream selection. am: 491999292b am: bf8a7b622d am: 505a805d70
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662400

Change-Id: I0ac607254e18f3c49c85e5add73eb2122be2dbc0
2021-04-06 06:09:57 +00:00
Lorenzo Colitti
4dce5c51e2 Add unit tests for race conditions in upstream selection. am: 6748e62ef2 am: afb685e650 am: 4321aa067b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662399

Change-Id: Ie7fb4e07a2c571218871a6560f77bbc985280c1e
2021-04-06 06:09:56 +00:00
Lorenzo Colitti
eb2a150485 Fix DadProxyTest when forwarding is on. am: b6bffbca95 am: 3f29d3ef39 am: 658bdb7e1e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1664401

Change-Id: Ia5a9d8ea7ecf3a7615dbf725fbfaa3eb2a766015
2021-04-06 05:29:43 +00:00
Lorenzo Colitti
365b803fac Fix a race condition in upstream selection. am: 491999292b am: bf8a7b622d am: 6033471338
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662400

Change-Id: Ic99e65a5e24cc497fb00a8f0969e97aaf120ac8d
2021-04-06 05:29:42 +00:00
Lorenzo Colitti
035bde8ae5 Add unit tests for race conditions in upstream selection. am: 6748e62ef2 am: afb685e650 am: 48cd598f81
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662399

Change-Id: Id16999b1c4659b7c44b24a2deef8fdeb37803d42
2021-04-06 05:29:41 +00:00
Lorenzo Colitti
f6adb01d24 Fix DadProxyTest when forwarding is on. am: b6bffbca95 am: 3f29d3ef39
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1664401

Change-Id: I3904270affd954bf265ac3df31041d794a559cc0
2021-04-06 04:42:41 +00:00
Lorenzo Colitti
505a805d70 Fix a race condition in upstream selection. am: 491999292b am: bf8a7b622d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662400

Change-Id: I62d575655a0f4880f0f2c2a793bf9eb1ca9295dc
2021-04-06 04:42:40 +00:00
Lorenzo Colitti
4321aa067b Add unit tests for race conditions in upstream selection. am: 6748e62ef2 am: afb685e650
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662399

Change-Id: Ic1cf40e3eaca0e60043a86982c72ac420727d63f
2021-04-06 04:42:38 +00:00
Lorenzo Colitti
658bdb7e1e Fix DadProxyTest when forwarding is on. am: b6bffbca95 am: 3f29d3ef39
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1664401

Change-Id: I5715c990a0de3b3de1a09e44a25bf96d7027feb5
2021-04-06 04:42:31 +00:00
Lorenzo Colitti
6033471338 Fix a race condition in upstream selection. am: 491999292b am: bf8a7b622d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662400

Change-Id: Ie771aba579b10a742b14d598dfcc50eee6baf4df
2021-04-06 04:42:30 +00:00
Lorenzo Colitti
48cd598f81 Add unit tests for race conditions in upstream selection. am: 6748e62ef2 am: afb685e650
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662399

Change-Id: I08b9b57734374ab12634ea8ba20c718c6e7c3280
2021-04-06 04:42:29 +00:00
Maciej Żenczykowski
a36ea6fb19 implement insertOrReplace()
Test: atest com.android.networkstack.tethering.BpfMapTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4a40898f03293d6d79b57c35f743271c669a8ea7
2021-04-06 04:38:46 +00:00
Lorenzo Colitti
3f29d3ef39 Fix DadProxyTest when forwarding is on. am: b6bffbca95
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1664401

Change-Id: I08b7f80b872a0cac5c1e0b930f4aca47c186b598
2021-04-06 03:59:23 +00:00
Lorenzo Colitti
bf8a7b622d Fix a race condition in upstream selection. am: 491999292b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662400

Change-Id: I6e1e1834489b80eb332176a69f4f6740e9575bdd
2021-04-06 03:59:22 +00:00
Lorenzo Colitti
afb685e650 Add unit tests for race conditions in upstream selection. am: 6748e62ef2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662399

Change-Id: Id2dcfdc1ec744e67f9f7877ea264bffdf1354b62
2021-04-06 03:59:19 +00:00
Lorenzo Colitti
b6bffbca95 Fix DadProxyTest when forwarding is on.
When forwarding is on, DadProxyTest fails because forwarding
disables optimistic addresses. This results in the DAD proxy
getting EADDRNOTAVAIL.

Forwarding is on quite often on real hardware because many
solutions for wifi calling use forwarding.

Fix the test to retry after two seconds if the packet is not
forwarded on the first attempt.

It would also be possible to make this work more reliably in the
test by simply disabling DAD or disabling forwarding. However,
because DAD does happen in real usage (downstream interfaces
always disable DAD, but upstream interfaces don't), that seems
risky. For example, if the test disabled DAD, it would not catch
bugs where the DAD proxy crashed or stopped forwarding if it got
EADDRNOTAVAIL.

Test: atest TetheringPrivilegedTests on coral, which has forwarding on
Change-Id: I58280ef7c0e40371cd770ead4c8baa7190c288fd
2021-04-05 23:42:29 +09:00
Lorenzo Colitti
491999292b Fix a race condition in upstream selection.
Current upstream selection code suffers from a race where if the
CONNECTIVITY_ACTION broadcast for a given network switch is
received and processed before the NetworkCallbacks for that
network switch, upstream selection just re-selects the same
upstream it had before. The incorrect upstream persists until
another CONNECTIVITY_ACTION is received.

Fix this by defining a new EVENT_DEFAULT_SWITCHED message code
communicated from UpstreamNetworkMonitor to Tethering, and send
that whenever the default network switches.

The message is sent in onLinkPropertiesChanged, because the
tethering code stores all information about networks in an
UpstreamNetworkState structure that contains Network,
LinkProperties and NetworkCapabilities. When a network switch
occurs, onLinkPropertiesChanged always follows onAvailable and
onCapabilitiesChanged, and thus marks the first point in time
when all the information is available.

This CL tries not to change existing codepaths too much, but
it does move the update of mDefaultInternetNetwork from
onCapabilitiesChanged to onLinkPropertiesChanged. This should
not be a problem because the only thing that reads
mDefaultInternetNetwork is getCurrentPreferredUpstream, which,
in the case of a default network switch, will be run by the
onLinkPropertiesChanged which will immediately follow.

Bug: 173068192
Test: changes to existing unit tests show bug is fixed
Change-Id: Ic9196bc92892811b25bda463ffd839ee5c19d294
2021-04-05 22:52:13 +09:00
Lorenzo Colitti
6748e62ef2 Add unit tests for race conditions in upstream selection.
In the current tethering code, upstream selection is only
triggered by CONNECTIVITY_ACTION. But in automatic mode, the
upstream network is selected by listening to a NetworkCallback
that tracks the default network.

This causes a race where if the CONNECTIVITY_ACTION for a network
switch is received and processed before the callbacks for that
network switch, upstream selection just re-selects the upstream
currently in use.

Make it possible to test this by giving TestConnectivityManager
the ability to choose the ordering between NetworkCallbacks and
CONNECTIVITY_ACTION, and to run an arbitrary Runnable between
calling one and calling the other. TetheringTest passes a
Runnable that calls mLooper.dispatchAll(), which ensures that
the tethering code fully processes the first set of information
it receives (either the broadcast (or the callbacks) before
receiving any more information.

Add test coverage to testAutomaticUpstreamSelection that
exercises various orderings, and make the test pass by expecting
the buggy behaviour of the current code.

An upcoming CL will fix the bug and update the tests.

Bug: 173068192
Test: test-only change
Change-Id: I7805444dcf59f6d5f8517fbcf2f2b1641783d50b
2021-04-05 14:51:53 +09:00
Lorenzo Colitti
57850ea847 Dump the input destination MAC address for IPv4 flows. am: e9bc8c9db7 am: a16ca88456 am: 6ca408f317
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662403

Change-Id: I389a4b23b8496cbaee0b815de1c53de532c657f7
2021-04-02 10:51:07 +00:00
Lorenzo Colitti
a8402cec06 Dump the input destination MAC address for IPv4 flows. am: e9bc8c9db7 am: a16ca88456 am: cf257bb217
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1662403

Change-Id: I6c92f144be4979bdfa6c98462f56c86ef006eedc
2021-04-02 10:50:22 +00:00