Commit Graph

8175 Commits

Author SHA1 Message Date
Lorenzo Colitti
4431655a4d Merge "offload - finish ipv4 tethering" 2021-02-09 11:08:06 +00:00
Lorenzo Colitti
72ec3ba88a Improve BPF tethering counters.
Test: m
Change-Id: I53961e1e16bf90d76f16b9416c55b65e8374373d
2021-02-09 03:36:40 +00:00
Maciej Żenczykowski
d46b3d8ef8 Merge changes I3fcd7eb8,I4bf2c762
* changes:
  Add error counters for various failures.
  Add a bpf_tethering_headers lib used by the programs and JNI.
2021-02-09 02:57:24 +00:00
Lorenzo Colitti
b81584dbe5 Add error counters for various failures.
Currently, debugging the tethering programs is not easy because
in case of any failure they simply return TC_ACT_OK. This CL adds
a number of counters that the program can increment in the case
of interesting events such as malformed packets.

At the moment the counters are stored in a global tethering error
map, which is an ARRAY map of 32-bit counters. This should not
take up much space because there are only a dozen of these.

We might not need all of these counters. In future CLs we can
reduce the number of counters, or perhaps move them to a map of
maps so as to have separate counters on a per-interface basis.

Test: manual
Change-Id: I3fcd7eb8d318700092949ff2f39987bf4ba3656c
2021-02-09 02:56:52 +00:00
Lorenzo Colitti
734b14e07d Add a bpf_tethering_headers lib used by the programs and JNI.
This provides a place to store common definitions that can be
used by both the programs and by JNI code in the tethering
module.

Over time much of the tethering-specific code in bpf_shared.h
could move here.

Test: m
Bug: 177884581
Change-Id: I4bf2c762d61cd5db003d59880e6bf7d107ff1a07
2021-02-09 01:54:52 +00:00
Treehugger Robot
1259762383 Merge "Temporarily disable flaky testRequestBackgroundNetwork CTS test" 2021-02-09 00:13:46 +00:00
Junyu Lai
438f787ca3 Merge changes from topic "vcn07"
* changes:
  Address comments on aosp/1550755
  [VCN07.1] Add test for bypassing VCN for non-internet request
2021-02-08 21:40:09 +00:00
junyulai
349deb8e15 Temporarily disable flaky testRequestBackgroundNetwork CTS test
Test: TH
Bug: 179554972
Change-Id: If82d561231b74e8cd0d220431ac83d08e8f16cdd
2021-02-08 21:48:13 +08:00
junyulai
5ceb5c3c8f Address comments on aosp/1550755
This CL bypass adding NOT_VCN_MANAGED on R device. And add TODOs
for refactoring and adding test coverage.

Test: atest CtsNetTestCasesLatestSdk:NetworkRequestTest on R device
Bug: 175662146

Change-Id: Id09b19c13f9a74e25d45689d2211418172dfaec8
2021-02-08 08:52:28 +00:00
Sudheer Shanka
8247993e00 Update meteredness of cellular networks for tests.
This would allow us to run both metered and unmetered networkpolicy
related tests when the device is on a cellular network.

Bug: 165343126
Test: atest CtsHostsideNetworkTests:HostsideRestrictBackgroundNetworkTests
Test: atest CtsHostsideNetworkTests:HostsideNetworkCallbackTests
Change-Id: Id70856dffc920e74bda28583dba4dd851a832397
Merged-In: Id70856dffc920e74bda28583dba4dd851a832397
2021-02-07 23:29:08 +00:00
Martin Stjernholm
199641d451 Revert "Don't crash Tethering service when WiFi feature is missing"
This reverts commit f6a1052f4e.

Reason for revert: Suspected reason for TetheringTests breakage
Bug: 179467044

Change-Id: I3a5ee621b32145b74a31d6c3e411bd789e395935
2021-02-05 11:47:48 +00:00
junyulai
ea79aa6fd9 [VCN07.1] Add test for bypassing VCN for non-internet request
Test: atest NetworkRequestTest#testBypassingVcnForNonInternetRequest
Bug: 175662146
Change-Id: I245bd69e02866d3608ab1667b665f6e12860037b
2021-02-05 10:09:09 +08:00
Tomasz Wasilczyk
f6a1052f4e Don't crash Tethering service when WiFi feature is missing
Bug: 175430552
Test: disable WiFi feature on device with wlan0

Change-Id: I83012013ff6a276d9a5c70748b726289b007cb0a
2021-02-02 16:11:18 +00:00
Lucas Lin
c0bae3c8c5 Merge "Add NetdStaticLibTestsLib into TetheringCoverageTests" 2021-02-02 03:38:37 +00:00
Junyu Lai
fa8d845a6e Merge "[VCN06.1] Add CTS for request background network" 2021-01-29 11:02:02 +00:00
Junyu Lai
38b5855ff7 [VCN06.1] Add CTS for request background network
Test: android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork
Bug: 175662146

Change-Id: Icd7d2bc18c4b328291e96fc3f18828d0421f5b6e
2021-01-29 14:34:38 +08:00
Maciej Żenczykowski
ec5f67d97e offload - finish ipv4 tethering
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I88f14938c7c4f66190a3afa2acd9104284e27927
2021-01-27 17:54:07 -08:00
lucaslin
5dc7de221a Add NetdStaticLibTestsLib into TetheringCoverageTests
Add NetdStaticLibTestsLib into Tethering MTS , so that the tests
under client-libs can also be run when running tethering MTS.

Bug: 170598012
Test: atest TetheringCoverageTests
Change-Id: Idd47becaa4254ab80b74ad5f3ddcdd4b017a5e69
2021-01-27 17:54:56 +00:00
Treehugger Robot
0f7f9b6e40 Merge "Dump BPF offload rules for upstream IPv4 and IPv6." 2021-01-27 07:23:55 +00:00
Treehugger Robot
33848955b0 Merge "merge Tether{Down,Up}stream6Value -> Tether6Value" 2021-01-27 07:18:35 +00:00
Remi NGUYEN VAN
f0be057728 Merge "Move connectivity-sources to frameworks/base" 2021-01-27 07:15:05 +00:00
Maciej Żenczykowski
7dfbcf58d2 merge Tether{Down,Up}stream6Value -> Tether6Value
Test: atest TetheringTests TetheringCoverageTests
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibdbba9ef6652dd11bb18eba316045dff440fcf9e
2021-01-27 06:41:59 +00:00
Lorenzo Colitti
61976f278f Dump BPF offload rules for upstream IPv4 and IPv6.
Add code to BpfCoordinator to dump upstream IPv4 and IPv6 rules.
For IPv4, currently only the upstream map is printed, because the
downstream map is expected to be symmetrical.

Example output:

=============
    21(21) -> 12(rmnet_data2) 86dd 00:00:00:00:00:00 00:00:00:00:00:00
    [wlan1]: iif(iface) oif(iface) v6addr srcmac dstmac
      12(rmnet_data2) 21(wlan1) /2001:240:2425:b5dc:21a9:995d:bc57:bc37 b2:b5:e0:24:21:c2 ca:06:8d:54:99:ad
    [IPv4]: iif(iface) oif(iface) src nat dst
      21(21) 12(rmnet_data2) 192.168.16.247:41544 -> 100.101.80.108:41544 -> 216.239.36.135:443
      21(21) 12(rmnet_data2) 192.168.16.247:42028 -> 100.101.80.108:42028 -> 8.8.4.4:853
      21(21) 12(rmnet_data2) 192.168.16.247:42032 -> 100.101.80.108:42032 -> 8.8.4.4:853
      21(21) 12(rmnet_data2) 192.168.16.247:42042 -> 100.101.80.108:42042 -> 8.8.4.4:853
      21(21) 12(rmnet_data2) 192.168.16.247:41816 -> 100.101.80.108:41816 -> 8.8.8.8:853
      21(21) 12(rmnet_data2) 192.168.16.247:42040 -> 100.101.80.108:42040 -> 8.8.4.4:853

=============

Also make it possible to do "dumpsys tethering bpf" and get only
the BPF dump.

Test: manual
Change-Id: I2aaa2fdda7d724994090c26feff585f24cd3283b
2021-01-27 14:30:51 +09:00
Lorenzo Colitti
0913a7a415 Merge changes Iaac422d7,Ia7638b31
* changes:
  Remove IpServer.Dependencies#getIfIndex.
  Address comments on aosp/1559686.
2021-01-27 03:04:23 +00:00
Maciej Żenczykowski
cff64c8561 fix comments
Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic217e08484c39077bcc408195daa3311ed93ad28
2021-01-26 16:45:21 -08:00
Lorenzo Colitti
f3b201f819 Remove IpServer.Dependencies#getIfIndex.
This code is unused.

Test: atest TetheringTests
Change-Id: Iaac422d72e8538b67798cb3ae3737deb7b426401
2021-01-27 00:53:59 +09:00
Lorenzo Colitti
51c1a95c82 Address comments on aosp/1559686.
Also remove some unnecessary line wrapping.

Test: atest TetheringTests
Change-Id: Ia7638b3198d7811cdbb34e959c50608cf1a656bf
2021-01-27 00:53:59 +09:00
Lorenzo Colitti
77262cea76 Add an isEmpty convenience method to BpfMap.
Test: new unit test
Change-Id: Ibec09f328e24111aee4760af2f75ea5a80ba84c3
2021-01-27 00:53:56 +09:00
Lorenzo Colitti
7bf39e56e1 Address a TODO in BpfMapTest.
Test: test-only change
Change-Id: I9a47234979cbb161dfcd0c97c54c0476aa753c5e
2021-01-27 00:53:02 +09:00
Lorenzo Colitti
5b1ed508cf Program the upstream IPv6 map in BpfCoordinator.
- Add methods to start and stop IPv6 forwarding upstream
- Populate the upstream IPv6 map when the first rule for any
  upstream/downstream pair is created.
- Clear the upstream IPv6 map when the last rule for any
  upstream/downstream pair is deleted.

Test: Added coverage to IpServerTest and BpfCoordinatorTest
Change-Id: Ib041081e95f5f449489ab63138de034222ffac8f
2021-01-27 00:52:09 +09:00
Lorenzo Colitti
d69a886235 Rename TetherDownstream6Value to Tether6Value.
The two value types are identical so there is no need to have
separate classes for them.

Test: atest TetheringTests
Change-Id: Ia622b082d0a44373d21f51222f5e675e5bde08e0
2021-01-27 00:52:09 +09:00
Lorenzo Colitti
3c35666892 Merge changes from topic "bpf_tether4_rename"
* changes:
  merge Tether{Down,Up}stream4{Key,Value} - part 3 - fixups
  merge Tether{Down,Up}stream4{Key,Value} - part 2 - java
  merge Tether{Down,Up}stream4{Key,Value} - part 1 - C portion
2021-01-26 13:01:22 +00:00
Lorenzo Colitti
a36d65da0a Mark the EntitlementManager PendingIntents as immutable.
These are read-only intents and should not be mutated by any
app receiving them.

Bug: 178324405
Bug: 178249531
Test: atest TetheringTests TetheringCoverageTests GtsTetheringTestCases
Change-Id: I5395e7c19e6453640ad790f2b9a9ba22bbcefa88
2021-01-26 15:14:26 +09:00
Lorenzo Colitti
ae27ecf5ad Fix a WTF in IpServerTest.
Bug: 178324405
Test: atest TetheringTests
Change-Id: I2069ea79f982e6bb197388edd7820a05d1e651f1
2021-01-26 15:14:26 +09:00
Maciej Żenczykowski
911a7267f5 merge Tether{Down,Up}stream4{Key,Value} - part 3 - fixups
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia7840698e80ded33d8e0b59efe1ca7267254b892
2021-01-25 20:32:10 -08:00
Maciej Żenczykowski
32874eb6bc merge Tether{Down,Up}stream4{Key,Value} - part 2 - java
Generated via:
  git grep 'Tether(Down|Up)stream4(Key|Value)' | cut -d: -f1 | sort -u | while read i; do
    sed -r -i 's@TetherUpstream4Value@Tether4Value@g' "$i"
    sed -r -i 's@TetherDownstream4Value@Tether4Value@g' "$i"
    sed -r -i 's@TetherDownstream4Key@Tether4Key@g' "$i"
    sed -r -i 's@TetherUpstream4Key@Tether4Key@g' "$i"
  done

  cd Tethering/src/com/android/networkstack/tethering
  git mv TetherUpstream4Key.java Tether4Key.java
  git mv TetherUpstream4Value.java Tether4Value.java

  git diff TetherDownstream4Key.java Tether4Key.java
  git diff TetherDownstream4Value.java Tether4Value.java
  git rm TetherDownstream4Key.java
  git rm TetherDownstream4Value.java

Fixup resulting 'import' duplication
  mcedit Tethering/apishim/31/com/android/networkstack/tethering/apishim/api31/BpfCoordinatorShimImpl.java
  mcedit Tethering/apishim/30/com/android/networkstack/tethering/apishim/api30/BpfCoordinatorShimImpl.java
  mcedit Tethering/apishim/common/com/android/networkstack/tethering/apishim/common/BpfCoordinatorShim.java
  mcedit Tethering/tests/unit/src/android/net/ip/IpServerTest.java

Test: N/A, requires follow up commit
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1dfc3108ca4bbd0cefc3420bc7e421594b62619c
2021-01-25 20:32:05 -08:00
Maciej Żenczykowski
1feb8b4ac8 merge Tether{Down,Up}stream4{Key,Value} - part 1 - C portion
The keys are identical, and the values nearly so, this will make everyone's life easier.

Test: git grep 'Tether(Down|Up)stream4(Key|Value)' finds nothing
  (note this requires follow up commits)
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbff2c617ac5834ea80f827eaf89ca81e862baec
2021-01-25 20:31:11 -08:00
Lorenzo Colitti
dc4189f0e4 Merge changes I8cd6e49b,Ibb52c7b7
* changes:
  [NFCT.TETHER.10] Add/delete IPv4 offload BPF rules to/from BPF map
  [NFCT.TETHER.9] Build IPv4 offload BPF rules for raw ip
2021-01-26 00:30:15 +00:00
Maciej Żenczykowski
c2b0146045 offload - begin ipv4 tethering implementation
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0ad143be954d55d0ed39853031c7bd364378e1ec
2021-01-25 19:07:40 +00:00
Hungming Chen
dd833dee31 [NFCT.TETHER.10] Add/delete IPv4 offload BPF rules to/from BPF map
Access the IPv4 downstream and upstream BPF map with the built rules.

Test: atest TetheringCoverageTests
Change-Id: I8cd6e49b377c72250988019eea57f93cccd78309
2021-01-25 20:13:47 +08:00
Maciej Żenczykowski
18552e8fb3 offload - ignore ethernet packets not destined for us
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Icabd1db48a1189425a941384d534c0f18bf20827
2021-01-24 19:59:21 -08:00
Maciej Żenczykowski
bf8ec1a21d rename do_forward to do_forward6
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I649dc490b1883a1e97f748370a77c956f1315e2e
2021-01-24 19:59:16 -08:00
Remi NGUYEN VAN
36840ee2d3 Move connectivity-sources to frameworks/base
All sources for the connectivity module are being moved to
frameworks/base/packages/Connectivity, so that they can all be moved to
packages/modules/Connectivity in one move keeping history.

INetworkAgent and INetworkAgentRegistry were created in
packages/modules/Connectivity directly, but this makes managing the
sources until the move harder as the module needs to pull sources from
two different locations. Considering that they do not have history to
move, just move them to frameworks/base/packages/Connectivity without
the commit history.

Bug: 171540887
Test: m
Change-Id: I1c7e83267014bff29eb938c002d6441332101248
2021-01-25 11:47:28 +09:00
Nucca Chen
2f1c2b25cd Merge changes I73f30477,I84db13ac
* changes:
  [NFCT.TETHER.8] Prepare the upstream information for IPv4 offload rule
  [NFCT.TETHER.7] Prepare the downstream information for IPv4 offload rule
2021-01-23 13:40:30 +00:00
Maciej Żenczykowski
fc4f6540be bpf tether offload - do not offload TCP SYN/FIN/RST packets
We want connection establishment/shutdown to flow through
the kernel code path so connection tracking state is at least
somewhat correct.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iee97baa65750188f3436937b16c9b320f0495a5a
2021-01-23 07:11:07 +00:00
Roland Levillain
86654be2d8 Merge "Added aidl for qos callback" 2021-01-22 14:19:58 +00:00
Daniel Bright
c16bfcc7f7 Added aidl for qos callback
Bug: 155176305
Change-Id: I62958d041a8f544dbd98d5434e97ce89f843c5cb
2021-01-22 14:03:47 +00:00
Hungming Chen
347dd90620 [NFCT.TETHER.9] Build IPv4 offload BPF rules for raw ip
Build the upstream and upstream rules when the conntrack event is
received.

Test: atest TetheringCoverageTests
Change-Id: Ibb52c7b75812bd586091d809e260bc9206c06262
2021-01-22 19:37:37 +08:00
Hungming Chen
8784a60eab [NFCT.TETHER.8] Prepare the upstream information for IPv4 offload rule
Add upstream interface index and its IPv4 address mapping

Required for building IPv4 forwarding rule when a conntrack event is
received.

Test: atest TetheringCoverageTests
Change-Id: I73f304777704f09481b80d18751e0bab5bab2edc
2021-01-22 19:37:31 +08:00
Hungming Chen
d71c06ec71 [NFCT.TETHER.7] Prepare the downstream information for IPv4 offload rule
Add and remove downstream client information to BpfCoordinator

Required for building IPv4 forwarding rule when a conntrack event is
received. The IpServer provides the following elements of a rule which
is not included in conntrack event:
- Downstream interface index
- Downstream Mac address
- Client IP address to Client Mac address

Test: atest TetheringCoverageTests
Change-Id: I84db13acc047ace5730d17f0d3dd99544f516084
2021-01-22 19:37:24 +08:00