Commit Graph

1052 Commits

Author SHA1 Message Date
Lorenzo Colitti
17b18ca6c2 Add IPv4 counters. am: d561b7f67c am: d2956a1964
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1580287

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic66884108ae7fde4c1688847f7b2092c8d6e941d
2021-02-10 06:54:53 +00:00
Lorenzo Colitti
7081e9f184 Dump counters in "dumpsys tethering bpf". am: 4e92da06fa am: e033a1e543
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575051

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib449565583901259f0c21764d566637eace5f5f8
2021-02-10 05:31:03 +00:00
Lorenzo Colitti
d561b7f67c Add IPv4 counters.
Test: dumpsys tethering bpf
Change-Id: Ie21fee8ad12430ecd21c3903587d25b8dd2a96c4
2021-02-10 04:44:35 +00:00
Lorenzo Colitti
4e92da06fa Dump counters in "dumpsys tethering bpf".
This CL adds the counters collected by the tethering programs to
the output of "dumpsys tethering bpf". The counter names are
fetched by JNI code at startup and then read by the debugging
code on demand.

Example from my device:

  Forwarding errors:
    TCP_CONTROL_PACKET: 67
    NON_GLOBAL_SRC: 13
    NON_GLOBAL_DST: 17
    LOCAL_SRC_DST: 7

Test: manual (debug-only code)
Change-Id: I7ec7992612556a4bca5f1b6bb52c655d6d870201
2021-02-10 04:43:03 +00:00
Lorenzo Colitti
a47891732f Don't leak map fds in BpfCoordinator#dump. am: 555472a186 am: a6c9626b5d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1581523

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id5a3c980a0f9409b9342672935b9567c89422305
2021-02-09 22:50:01 +00:00
Lorenzo Colitti
555472a186 Don't leak map fds in BpfCoordinator#dump.
Currently, the dump methods open BpfMap objects and never close
them. This leaks filedescriptors, and if dump is called often
enough, will crash the networkstack process.

Fix this by using try-with-resources statements that
automatically close the map when exiting the try block.

Change the signature of BpfMap#close from "throws Exception" to
"throws ErrnoException" since it does not throw any other type
of checked exceptions.

Test: "lsof | grep network_st" while running "dumpsys tethering bpf" in a loop
Change-Id: I66c407454c2715bf41bf3a2e81bd582f9ea5a905
2021-02-09 23:30:25 +09:00
Lorenzo Colitti
29f8e3550b Merge "offload - finish ipv4 tethering" am: 4431655a4d am: 76a663683c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1562765

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I386c9e5230fb978856437a9afc0b3920edfcf051
2021-02-09 13:00:08 +00:00
Lorenzo Colitti
4431655a4d Merge "offload - finish ipv4 tethering" 2021-02-09 11:08:06 +00:00
Lorenzo Colitti
b9b629f273 Improve BPF tethering counters. am: 72ec3ba88a am: 66609d3f3e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1580284

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I19117620a162ecf6a3c14118cebf3413ffbe667b
2021-02-09 07:06:44 +00:00
Maciej Żenczykowski
79079db8af Merge changes I3fcd7eb8,I4bf2c762 am: d46b3d8ef8 am: 0681ae3e9a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575050

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I187698dad1d3bf8641e7b9987be3e6e4aeba55b5
2021-02-09 04:25:48 +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
Martin Stjernholm
b9e5c3b247 Revert "Don't crash Tethering service when WiFi feature is missing" am: 199641d451 am: b329062b20
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1575305

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I56f5136bd9cc4f7527c3600b9a307bcd7ec9f33c
2021-02-05 15:01:25 +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
Tomasz Wasilczyk
86be613c85 Don't crash Tethering service when WiFi feature is missing am: f6a1052f4e am: 75c7cb992a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1559422

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1a57e832b8c9700fce7b935bd5caf01b10eeb5ae
2021-02-04 15:02:56 +00: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
a4863a3491 Merge "Add NetdStaticLibTestsLib into TetheringCoverageTests" am: c0bae3c8c5 am: 09193eba96
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1552317

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id61cfe8a61a7e74739770d621afdbf87cbdc5000
2021-02-02 04:41:37 +00:00
Lucas Lin
c0bae3c8c5 Merge "Add NetdStaticLibTestsLib into TetheringCoverageTests" 2021-02-02 03:38:37 +00: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
24ee1bb6a0 Merge "Dump BPF offload rules for upstream IPv4 and IPv6." am: 0f7f9b6e40 am: 959cc0be9f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1560404

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I11f2ca833264943c0bab575c90b6d6ba7aca78e7
2021-01-27 08:28:28 +00:00
Treehugger Robot
b33e05d475 Merge "merge Tether{Down,Up}stream6Value -> Tether6Value" am: 33848955b0 am: 99d1eeebff
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1561296

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ieb398ac4c2eb1dcbd13391b06f6277c1a671e540
2021-01-27 08:28:04 +00:00
Treehugger Robot
0f7f9b6e40 Merge "Dump BPF offload rules for upstream IPv4 and IPv6." 2021-01-27 07:23:55 +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
798f4b0e56 Merge changes Iaac422d7,Ia7638b31 am: 0913a7a415 am: 51875f6043
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1560403

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ia3c2de8b5fe3f64fba280e2637a8d9e9d3e0ea40
2021-01-27 04:11:05 +00: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
08a003ab33 fix comments am: cff64c8561 am: ec92651a11
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1561295

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9fc86e6049d847fbb3f0af8eddb455539d83fa37
2021-01-27 01:36:46 +00:00
Lorenzo Colitti
bb226600c1 Add an isEmpty convenience method to BpfMap. am: 77262cea76 am: 63585e9630
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1560402

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I61adb34e62da8862b50a56c27dfee5cd78b705b6
2021-01-27 01:36:07 +00:00
Lorenzo Colitti
a350221089 Address a TODO in BpfMapTest. am: 7bf39e56e1 am: b62a70bcd2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1560401

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If988eb90c7be8176ffa13f0be425428ce4ae7e8a
2021-01-27 01:36:06 +00:00
Lorenzo Colitti
8c49368ee2 Program the upstream IPv6 map in BpfCoordinator. am: 5b1ed508cf am: e9eb340e3e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1557099

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I563a8f0d7013a0d6572f90f0dd6c9c165ba89207
2021-01-27 01:36:05 +00:00
Lorenzo Colitti
80ede0e4d9 Rename TetherDownstream6Value to Tether6Value. am: d69a886235 am: 6482088003
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1560395

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I4a949d07a8a1e353030c0957462f20ee3a38ab7b
2021-01-27 01:36:04 +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
177975f25b Merge changes from topic "bpf_tether4_rename" am: 3c35666892 am: 7d0693f6dc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1559687

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I056bdd8ef3117a89ff0f4f28a87978f703a325a2
2021-01-26 14:23:58 +00: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
8688028150 Mark the EntitlementManager PendingIntents as immutable. am: a36d65da0a am: ec93812466
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1557108

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ieb900d82e5b8a67ae2be1e448966f6199986539d
2021-01-26 12:03:36 +00:00
Lorenzo Colitti
9d829044e9 Fix a WTF in IpServerTest. am: ae27ecf5ad am: 595a330cc6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1557107

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ie29e806685ee0930ec00ad85f8f9c15ace3e6cf6
2021-01-26 12:03:33 +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